2
* GPAC - Multimedia Framework C SDK
4
* Copyright (c) Jean Le Feuvre 2000-2005
7
* This file is part of GPAC / common tools sub-project
9
* GPAC is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU Lesser General Public License as published by
11
* the Free Software Foundation; either version 2, or (at your option)
14
* GPAC is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU Lesser General Public License for more details.
19
* You should have received a copy of the GNU Lesser General Public
20
* License along with this library; see the file COPYING. If not, write to
21
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
25
#include <gpac/tools.h>
28
#include <sys/timeb.h>
38
static u32 clock_init = 0;
40
/*TODO: add queryperformancetimer stuff for win32*/
41
void gf_sys_clock_start()
43
if (!clock_init) timeBeginPeriod(1);
47
void gf_sys_clock_stop()
51
if (!clock_init) timeEndPeriod(1);
60
void gf_delete_file(char *fileName)
67
void gf_rand_init(Bool Reset)
72
srand( (u32) time(NULL) );
82
#ifndef GPAC_READ_ONLY
83
FILE *gf_temp_file_new()
90
void gf_utc_time_since_1970(u32 *sec, u32 *msec)
99
void gf_get_user_name(char *buf, u32 buf_size)
101
strcpy(buf, "mpeg4-user");
110
GetUserName(buf, &len);
113
if (t) strcpy(buf, t);
119
/*enumerate directories*/
120
GF_Err gf_enum_directory(const char *dir, Bool enum_directory, gf_enum_dir_item enum_dir_fct, void *cbck)
122
unsigned char path[GF_MAX_PATH], item_path[GF_MAX_PATH];
123
WIN32_FIND_DATA FindData;
126
if (!dir || !enum_dir_fct) return GF_BAD_PARAM;
127
if (dir[strlen(dir) - 1] == GF_PATH_SEPARATOR) {
128
sprintf(path, "%s*", dir);
130
sprintf(path, "%s%c*", dir, GF_PATH_SEPARATOR);
133
SearchH= FindFirstFile(path, &FindData);
134
if (SearchH == INVALID_HANDLE_VALUE) return GF_IO_ERR;
136
path[strlen(path)-1] = 0;
138
while (SearchH != INVALID_HANDLE_VALUE) {
139
if (!strcmp(FindData.cFileName, ".")) goto next;
140
if (!strcmp(FindData.cFileName, "..")) goto next;
142
if (!enum_directory && (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) goto next;
143
if (enum_directory && !(FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) goto next;
145
strcpy(item_path, path);
146
strcat(item_path, FindData.cFileName);
147
if (enum_dir_fct(cbck, FindData.cFileName, item_path)) {
153
if (!FindNextFile(SearchH, &FindData)) {
162
u64 gf_f64_tell(FILE *fp)
165
if (fgetpos(fp, &pos))
171
u64 gf_f64_seek(FILE *fp, s64 offset, s32 whence)
174
if (whence == SEEK_CUR) {
176
pos += (fpos_t) offset;
178
else if (whence == SEEK_END)
179
pos = (fpos_t) (_filelengthi64(fileno(fp)) + offset);
180
else if (whence == SEEK_SET)
181
pos = (fpos_t) offset;
182
return fsetpos(fp, &pos);
185
FILE *gf_f64_open(const char *file_name, const char *mode)
187
return fopen(file_name, mode);