|
|
| version 1.6, 2003/12/19 16:08:01 | version 1.7, 2004/01/13 16:30:21 |
|---|---|
| Line 113 file_attr(const char *path) | Line 113 file_attr(const char *path) |
| return -1; | return -1; |
| } | } |
| short | static BOOL |
| file_getdatetime(FILEH handle, DOSDATE *dosdate, DOSTIME *dostime) | cnvdatetime(struct stat *sb, DOSDATE *dosdate, DOSTIME *dostime) |
| { | { |
| struct stat sb; | |
| struct tm *ftime; | struct tm *ftime; |
| if (fstat(fileno(handle), &sb) == 0) { | ftime = localtime(&sb->st_mtime); |
| ftime = localtime(&sb.st_mtime); | if (ftime) { |
| if (ftime) { | if (dosdate) { |
| if (dosdate) { | dosdate->year = ftime->tm_year + 1900; |
| dosdate->year = ftime->tm_year + 1900; | dosdate->month = ftime->tm_mon + 1; |
| dosdate->month = ftime->tm_mon + 1; | dosdate->day = ftime->tm_mday; |
| dosdate->day = ftime->tm_mday; | } |
| } | if (dostime) { |
| if (dostime) { | dostime->hour = ftime->tm_hour; |
| dostime->hour = ftime->tm_hour; | dostime->minute = ftime->tm_min; |
| dostime->minute = ftime->tm_min; | dostime->second = ftime->tm_sec; |
| dostime->second = ftime->tm_sec; | |
| } | |
| return 0; | |
| } | } |
| return SUCCESS; | |
| } | } |
| return FAILURE; | |
| } | |
| short | |
| file_getdatetime(FILEH handle, DOSDATE *dosdate, DOSTIME *dostime) | |
| { | |
| struct stat sb; | |
| if ((fstat(fileno(handle), &sb) == 0) | |
| && (cnvdatetime(&sb, dosdate, dostime))) | |
| return 0; | |
| return -1; | return -1; |
| } | } |
| Line 217 file_attr_c(const char *sjis) | Line 225 file_attr_c(const char *sjis) |
| return file_attr_c(curpath); | return file_attr_c(curpath); |
| } | } |
| FILEFINDH | FLISTH |
| file_find1st(const char *dir, FILEFINDT *fft) | file_list1st(const char *dir, FLINFO *fli) |
| { | { |
| char eucpath[MAX_PATH]; | |
| DIR *ret; | DIR *ret; |
| ret = opendir(dir); | mileuc_ncpy(eucpath, dir, sizeof(eucpath)); |
| file_setseparator(eucpath, sizeof(eucpath)); | |
| ret = opendir(eucpath); | |
| if (ret == NULL) { | if (ret == NULL) { |
| return FILEFINDH_INVALID; | return FLISTH_INVALID; |
| } | } |
| if (file_findnext((FILEFINDH)ret, fft) == SUCCESS) { | if (file_listnext((FLISTH)ret, fli) == SUCCESS) { |
| return (FILEFINDH)ret; | return (FLISTH)ret; |
| } | } |
| closedir(ret); | closedir(ret); |
| return FILEFINDH_INVALID; | return FLISTH_INVALID; |
| } | } |
| BOOL | BOOL |
| file_findnext(FILEFINDH hdl, FILEFINDT *fft) | file_listnext(FLISTH hdl, FLINFO *fli) |
| { | { |
| struct dirent *de; | struct dirent *de; |
| struct stat sb; | struct stat sb; |
| UINT32 attr; | |
| UINT32 size; | |
| de = readdir((DIR *)hdl); | de = readdir((DIR *)hdl); |
| if (de == NULL) { | if (de == NULL) { |
| return FAILURE; | return FAILURE; |
| } | } |
| if (fft) { | if (stat(de->d_name, &sb) != 0) { |
| mileuc_ncpy(fft->path, de->d_name, sizeof(fft->path)); | return FAILURE; |
| size = 0; | } |
| attr = 0; | |
| if (stat(de->d_name, &sb) == 0) { | fli->caps = FLICAPS_SIZE | FLICAPS_ATTR | FLICAPS_DATE | FLICAPS_TIME; |
| size = sb.st_size; | fli->size = sb.st_size; |
| if (S_ISDIR(sb.st_mode)) { | if (S_ISDIR(sb.st_mode)) { |
| attr = FILEATTR_DIRECTORY; | fli->attr |= FILEATTR_DIRECTORY; |
| } | |
| else if (!(sb.st_mode & S_IWUSR)) { | |
| attr = FILEATTR_READONLY; | |
| } | |
| } | |
| fft->size = size; | |
| fft->attr = attr; | |
| } | } |
| if (!(sb.st_mode & S_IWUSR)) { | |
| fli->attr |= FILEATTR_READONLY; | |
| } | |
| cnvdatetime(&sb, &fli->date, &fli->time); | |
| mileuc_ncpy(fli->path, de->d_name, sizeof(fli->path)); | |
| return SUCCESS; | return SUCCESS; |
| } | } |
| void | void |
| file_findclose(FILEFINDH hdl) | file_listclose(FLISTH hdl) |
| { | { |
| closedir((DIR *)hdl); | closedir((DIR *)hdl); |