/* replace them with FindFirstFile, etc. */ long _findfirst( char *file, struct _finddata_t *fi ) { HANDLE h; WIN32_FIND_DATAA fda; int fNumber = get_NewFileNumber(); if ( fNumber == 0 ) return -1; h = FindFirstFileA( file, &fda ); if( h==NULL ) { errno = EINVAL; return -1; } fi->attrib = fda.dwFileAttributes; fi->time_create = wce_FILETIME2time_t( &fda.ftCreationTime ); fi->time_access = wce_FILETIME2time_t( &fda.ftLastAccessTime ); fi->time_write = wce_FILETIME2time_t( &fda.ftLastWriteTime ); fi->size = fda.nFileSizeLow + (fda.nFileSizeHigh<<32); strcpy( fi->name, fda.cFileName ); set_FileNumber(fNumber,h); return fNumber; }
int winec7_ftime(struct timeb *tp){ SYSTEMTIME s; FILETIME f; GetLocalTime(&s); SystemTimeToFileTime( &s, &f ); s.wMilliseconds = 500;/// no milliseconds, someone could complain tp->time = wce_FILETIME2time_t(&f); tp->millitm = s.wMilliseconds; return 0; }
int _findnext( long handle, struct _finddata_t *fi ) { WIN32_FIND_DATAA fda; BOOL b; b = FindNextFileA( (HANDLE)handle, &fda ); if( b==FALSE ) { errno = ENOENT; return -1; } fi->attrib = fda.dwFileAttributes; fi->time_create = wce_FILETIME2time_t( &fda.ftCreationTime ); fi->time_access = wce_FILETIME2time_t( &fda.ftLastAccessTime ); fi->time_write = wce_FILETIME2time_t( &fda.ftLastWriteTime ); fi->size = fda.nFileSizeLow + (fda.nFileSizeHigh<<32); strcpy( fi->name, fda.cFileName ); return 0; }
int fstat(int file, struct stat *sbuf) { /* GetFileSize & GetFileTime */ DWORD dwSize; FILETIME ctime, atime, mtime; dwSize = GetFileSize( (HANDLE)file, NULL ); if( dwSize == 0xFFFFFFFF ) return -1; sbuf->st_size = dwSize; sbuf->st_dev = 0; sbuf->st_rdev = 0; sbuf->st_mode = _S_IFREG; sbuf->st_nlink= 1; GetFileTime( (HANDLE)file, &ctime, &atime, &mtime ); sbuf->st_ctime = wce_FILETIME2time_t(&ctime); sbuf->st_atime = wce_FILETIME2time_t(&atime); sbuf->st_mtime = wce_FILETIME2time_t(&mtime); return 0; }
int ftime(struct timeb *tp) { SYSTEMTIME s; FILETIME f; GetLocalTime(&s); SystemTimeToFileTime( &s, &f ); tp->dstflag = 0; tp->timezone = _timezone/60; tp->time = wce_FILETIME2time_t(&f); tp->millitm = s.wMilliseconds; return 0; }
time_t mktime(struct tm* pt) { SYSTEMTIME ss, ls, s; FILETIME sf, lf, f; __int64 diff; GetSystemTime(&ss); GetLocalTime(&ls); SystemTimeToFileTime( &ss, &sf ); SystemTimeToFileTime( &ls, &lf ); diff = (wce_FILETIME2int64(lf)-wce_FILETIME2int64(sf))/_onesec_in100ns; s = wce_tm2SYSTEMTIME(pt); SystemTimeToFileTime( &s, &f ); return wce_FILETIME2time_t(&f) - (time_t)diff; }
/* time.h difinition */ time_t time( time_t *timer ) { SYSTEMTIME s; FILETIME f; time_t t; GetSystemTime( &s ); SystemTimeToFileTime( &s, &f ); t = wce_FILETIME2time_t(&f); if( timer==NULL ) return t; else *timer = t; return *timer; }
int _stat(const char *filename, struct _stat *st) { DWORD dwAttribute; HANDLE h; DWORD dwSizeLow=0, dwSizeHigh=0, dwError=0; WIN32_FIND_DATAW fd; wchar_t *wfilename; // wfilename = wce_mbtowc(filename); wfilename = wce_replaceRelativeDir(filename); dwAttribute = GetFileAttributesW(wfilename); if(dwAttribute==0xFFFFFFFF) { free(wfilename); return -1; } st->st_mode = 0; if((dwAttribute & FILE_ATTRIBUTE_DIRECTORY) != 0) st->st_mode += S_IFDIR; else st->st_mode += S_IFREG; /* initialize */ st->st_atime = 0; st->st_mtime = 0; st->st_ctime = 0; st->st_size = 0; st->st_dev = 0; h = FindFirstFileW(wfilename, &fd); if(h == INVALID_HANDLE_VALUE) { if(wfilename[wcslen(wfilename)-1] == L'\\') { wfilename[wcslen(wfilename)-1] = L'\0'; h = FindFirstFileW(wfilename, &fd); if(h == INVALID_HANDLE_VALUE) { free(wfilename); return 0; } } else { free(wfilename); return 0; } } /* FILETIME -> time_t */ st->st_atime = wce_FILETIME2time_t(&fd.ftLastAccessTime); st->st_mtime = wce_FILETIME2time_t(&fd.ftLastWriteTime); st->st_ctime = wce_FILETIME2time_t(&fd.ftCreationTime); st->st_size = fd.nFileSizeLow; FindClose( h ); free(wfilename); return 0; }