|
|
| version 1.1, 2003/10/16 17:59:32 | version 1.4, 2004/01/12 08:01:00 |
|---|---|
| Line 162 UINT file_getsize(FILEH handle) { | Line 162 UINT file_getsize(FILEH handle) { |
| return(GetFileSize(handle, NULL)); | return(GetFileSize(handle, NULL)); |
| } | } |
| short file_getdatetime(FILEH handle, DOSDATE *dosdate, DOSTIME *dostime) { | static BOOL cnvdatetime(FILETIME *file, DOSDATE *dosdate, DOSTIME *dostime) { |
| FILETIME lastwrite; | FILETIME localtime; |
| FILETIME localwrite; | SYSTEMTIME systime; |
| SYSTEMTIME syswrite; | |
| if ((GetFileTime(handle, NULL, NULL, &lastwrite) == 0) || | if ((FileTimeToLocalFileTime(file, &localtime) == 0) || |
| (FileTimeToLocalFileTime(&lastwrite, &localwrite) == 0) || | (FileTimeToSystemTime(&localtime, &systime) == 0)) { |
| (FileTimeToSystemTime(&localwrite, &syswrite) == 0)) { | return(FAILURE); |
| return(-1); | |
| } | } |
| if (dosdate) { | if (dosdate) { |
| dosdate->year = (WORD)syswrite.wYear; | dosdate->year = (UINT16)systime.wYear; |
| dosdate->month = (BYTE)syswrite.wMonth; | dosdate->month = (UINT8)systime.wMonth; |
| dosdate->day = (BYTE)syswrite.wDay; | dosdate->day = (UINT8)systime.wDay; |
| } | } |
| if (dostime) { | if (dostime) { |
| dostime->hour = (BYTE)syswrite.wHour; | dostime->hour = (UINT8)systime.wHour; |
| dostime->minute = (BYTE)syswrite.wMinute; | dostime->minute = (UINT8)systime.wMinute; |
| dostime->second = (BYTE)syswrite.wSecond; | dostime->second = (UINT8)systime.wSecond; |
| } | |
| return(SUCCESS); | |
| } | |
| short file_getdatetime(FILEH handle, DOSDATE *dosdate, DOSTIME *dostime) { | |
| FILETIME lastwrite; | |
| if ((GetFileTime(handle, NULL, NULL, &lastwrite) == 0) || | |
| (cnvdatetime(&lastwrite, dosdate, dostime) != SUCCESS)) { | |
| return(-1); | |
| } | } |
| return(0); | return(0); |
| } | } |
| Line 253 short file_attr_c(const char *path) { | Line 262 short file_attr_c(const char *path) { |
| } | } |
| FILEFINDH file_find1st(const char *path, FILEFINDT *fft) { | static BOOL setflist(WIN32_FIND_DATA *w32fd, FLINFO *fli) { |
| HANDLE hdl; | #if !defined(_WIN32_WCE) |
| WIN32_FIND_DATA w32fd; | if ((w32fd->dwFileAttributes & FILEATTR_DIRECTORY) && |
| ((!file_cmpname(w32fd->cFileName, ".")) || | |
| hdl = FindFirstFile_A(path, &w32fd); | (!file_cmpname(w32fd->cFileName, "..")))) { |
| if (hdl == INVALID_HANDLE_VALUE) { | return(FAILURE); |
| return(FILEFINDH_INVALID); | |
| } | } |
| if (fft) { | #endif |
| fli->caps = FLICAPS_SIZE | FLICAPS_ATTR | FLICAPS_DATE | FLICAPS_TIME; | |
| fli->size = w32fd->nFileSizeLow; | |
| fli->attr = w32fd->dwFileAttributes; | |
| cnvdatetime(&w32fd->ftLastWriteTime, &fli->date, &fli->time); | |
| #if defined(UNICODE) | #if defined(UNICODE) |
| WideCharToMultiByte(CP_ACP, 0, w32fd.cFileName, -1, | WideCharToMultiByte(CP_ACP, 0, w32fd->cFileName, -1, |
| fft->path, sizeof(fft->path), NULL, NULL); | fli->path, sizeof(fli->path), NULL, NULL); |
| #else | #else |
| milstr_ncpy(fft->path, w32fd.cFileName, sizeof(fft->path)); | milstr_ncpy(fli->path, w32fd->cFileName, sizeof(fli->path)); |
| #endif | #endif |
| fft->size = w32fd.nFileSizeLow; | return(SUCCESS); |
| fft->attr = w32fd.dwFileAttributes; | |
| } | |
| return(hdl); | |
| } | } |
| BOOL file_findnext(FILEFINDH hdl, FILEFINDT *fft) { | FLISTH file_list1st(const char *dir, FLINFO *fli) { |
| char path[MAX_PATH]; | |
| HANDLE hdl; | |
| WIN32_FIND_DATA w32fd; | WIN32_FIND_DATA w32fd; |
| if (!FindNextFile(hdl, &w32fd)) { | milsjis_ncpy(path, dir, sizeof(path)); |
| return(FAILURE); | file_setseparator(path, sizeof(path)); |
| } | milsjis_ncat(path, "*.*", sizeof(path)); |
| if (fft) { | TRACEOUT(("file_list1st %s", path)); |
| #if defined(UNICODE) | hdl = FindFirstFile_A(path, &w32fd); |
| WideCharToMultiByte(CP_ACP, 0, w32fd.cFileName, -1, | if (hdl != INVALID_HANDLE_VALUE) { |
| fft->path, sizeof(fft->path), NULL, NULL); | do { |
| #else | if (setflist(&w32fd, fli) == SUCCESS) { |
| milstr_ncpy(fft->path, w32fd.cFileName, sizeof(fft->path)); | return(hdl); |
| #endif | } |
| fft->size = w32fd.nFileSizeLow; | } while(FindNextFile(hdl, &w32fd)); |
| fft->attr = w32fd.dwFileAttributes; | FindClose(hdl); |
| } | } |
| return(SUCCESS); | return(FLISTH_INVALID); |
| } | } |
| void file_findclose(FILEFINDH hdl) { | BOOL file_listnext(FLISTH hdl, FLINFO *fli) { |
| if (hdl) { | WIN32_FIND_DATA w32fd; |
| FindClose(hdl); | |
| while(FindNextFile(hdl, &w32fd)) { | |
| if (setflist(&w32fd, fli) == SUCCESS) { | |
| return(SUCCESS); | |
| } | |
| } | } |
| return(FAILURE); | |
| } | |
| void file_listclose(FLISTH hdl) { | |
| FindClose(hdl); | |
| } | } |