|
|
| version 1.11, 2004/02/08 07:31:47 | version 1.12, 2004/07/08 14:21:50 |
|---|---|
| Line 173 file_setcd(const char *exepath) | Line 173 file_setcd(const char *exepath) |
| } | } |
| char * | char * |
| file_getcd(const char *sjis) | file_getcd(const char *filename) |
| { | { |
| *curfilep = '\0'; | *curfilep = '\0'; |
| file_catname(curpath, sjis, sizeof(curpath)); | file_catname(curpath, filename, sizeof(curpath)); |
| return curpath; | return curpath; |
| } | } |
| FILEH | FILEH |
| file_open_c(const char *sjis) | file_open_c(const char *filename) |
| { | { |
| *curfilep = '\0'; | *curfilep = '\0'; |
| file_catname(curpath, sjis, sizeof(curpath)); | file_catname(curpath, filename, sizeof(curpath)); |
| return file_open(curpath); | return file_open(curpath); |
| } | } |
| FILEH | FILEH |
| file_open_rb_c(const char *sjis) | file_open_rb_c(const char *filename) |
| { | { |
| *curfilep = '\0'; | *curfilep = '\0'; |
| file_catname(curpath, sjis, sizeof(curpath)); | file_catname(curpath, filename, sizeof(curpath)); |
| return file_open_rb(curpath); | return file_open_rb(curpath); |
| } | } |
| FILEH | FILEH |
| file_create_c(const char *sjis) | file_create_c(const char *filename) |
| { | { |
| *curfilep = '\0'; | *curfilep = '\0'; |
| file_catname(curpath, sjis, sizeof(curpath)); | file_catname(curpath, filename, sizeof(curpath)); |
| return file_create(curpath); | return file_create(curpath); |
| } | } |
| short | short |
| file_delete_c(const char *sjis) | file_delete_c(const char *filename) |
| { | { |
| *curfilep = '\0'; | *curfilep = '\0'; |
| file_catname(curpath, sjis, sizeof(curpath)); | file_catname(curpath, filename, sizeof(curpath)); |
| return file_delete(curpath); | return file_delete(curpath); |
| } | } |
| short | short |
| file_attr_c(const char *sjis) | file_attr_c(const char *filename) |
| { | { |
| *curfilep = '\0'; | *curfilep = '\0'; |
| file_catname(curpath, sjis, sizeof(curpath)); | file_catname(curpath, filename, sizeof(curpath)); |
| return file_attr_c(curpath); | return file_attr_c(curpath); |
| } | } |
| Line 231 file_list1st(const char *dir, FLINFO *fl | Line 231 file_list1st(const char *dir, FLINFO *fl |
| { | { |
| FLISTH ret; | FLISTH ret; |
| ret = (FLISTH)malloc(sizeof(_FLISTH)); | ret = (FLISTH)_MALLOC(sizeof(_FLISTH), "FLISTH"); |
| if (ret == NULL) { | if (ret == NULL) { |
| VERBOSE(("file_list1st: couldn't alloc memory (size = %d)", sizeof(_FLISTH))); | VERBOSE(("file_list1st: couldn't alloc memory (size = %d)", sizeof(_FLISTH))); |
| return FLISTH_INVALID; | return FLISTH_INVALID; |
| } | } |
| mileuc_ncpy(ret->path, dir, sizeof(ret->path)); | milstr_ncpy(ret->path, dir, sizeof(ret->path)); |
| file_setseparator(ret->path, sizeof(ret->path)); | file_setseparator(ret->path, sizeof(ret->path)); |
| ret->hdl = opendir(ret->path); | ret->hdl = opendir(ret->path); |
| VERBOSE(("file_list1st: opendir(%s)", ret->path)); | VERBOSE(("file_list1st: opendir(%s)", ret->path)); |
| if (ret->hdl == NULL) { | if (ret->hdl == NULL) { |
| VERBOSE(("file_list1st: opendir failure")); | VERBOSE(("file_list1st: opendir failure")); |
| free(ret); | _MFREE(ret); |
| return FLISTH_INVALID; | return FLISTH_INVALID; |
| } | } |
| if (file_listnext((FLISTH)ret, fli) == SUCCESS) { | if (file_listnext((FLISTH)ret, fli) == SUCCESS) { |
| Line 251 file_list1st(const char *dir, FLINFO *fl | Line 251 file_list1st(const char *dir, FLINFO *fl |
| } | } |
| VERBOSE(("file_list1st: file_listnext failure")); | VERBOSE(("file_list1st: file_listnext failure")); |
| closedir(ret->hdl); | closedir(ret->hdl); |
| free(ret); | _MFREE(ret); |
| return FLISTH_INVALID; | return FLISTH_INVALID; |
| } | } |
| Line 269 file_listnext(FLISTH hdl, FLINFO *fli) | Line 269 file_listnext(FLISTH hdl, FLINFO *fli) |
| } | } |
| milstr_ncpy(buf, hdl->path, sizeof(buf)); | milstr_ncpy(buf, hdl->path, sizeof(buf)); |
| mileuc_ncat(buf, de->d_name, sizeof(buf)); | milstr_ncat(buf, de->d_name, sizeof(buf)); |
| if (stat(buf, &sb) != 0) { | if (stat(buf, &sb) != 0) { |
| VERBOSE(("file_listnext: stat failure. (path = %s)", buf)); | VERBOSE(("file_listnext: stat failure. (path = %s)", buf)); |
| return FAILURE; | return FAILURE; |
| Line 285 file_listnext(FLISTH hdl, FLINFO *fli) | Line 285 file_listnext(FLISTH hdl, FLINFO *fli) |
| fli->attr |= FILEATTR_READONLY; | fli->attr |= FILEATTR_READONLY; |
| } | } |
| cnvdatetime(&sb, &fli->date, &fli->time); | cnvdatetime(&sb, &fli->date, &fli->time); |
| mileuc_ncpy(fli->path, de->d_name, sizeof(fli->path)); | milstr_ncpy(fli->path, de->d_name, sizeof(fli->path)); |
| VERBOSE(("file_listnext: success")); | VERBOSE(("file_listnext: success")); |
| return SUCCESS; | return SUCCESS; |
| } | } |
| Line 296 file_listclose(FLISTH hdl) | Line 296 file_listclose(FLISTH hdl) |
| if (hdl) { | if (hdl) { |
| closedir(hdl->hdl); | closedir(hdl->hdl); |
| free(hdl); | _MFREE(hdl); |
| } | } |
| } | } |
| Line 304 static int | Line 304 static int |
| euckanji1st(const char *str, int pos) | euckanji1st(const char *str, int pos) |
| { | { |
| int ret; | int ret; |
| int c; | |
| ret = 0; | for (ret = 0; pos >= 0; ret ^= 1) { |
| while ((pos >= 0) && (((str[pos--] - 0xa1) & 0xff) < 0x5d)) { | c = (UINT8)str[pos--]; |
| ret ^= 1; | if (!ISKANJI(c)) |
| break; | |
| } | } |
| return ret; | return ret; |
| } | } |
| Line 317 file_cpyname(char *dst, const char *src, | Line 319 file_cpyname(char *dst, const char *src, |
| { | { |
| int i; | int i; |
| if (maxlen--) { | if (maxlen-- > 0) { |
| for (i = 0; i < maxlen && src[i] != '\0'; i++) { | for (i = 0; i < maxlen && src[i] != '\0'; i++) { |
| dst[i] = src[i]; | dst[i] = src[i]; |
| } | } |
| Line 331 file_cpyname(char *dst, const char *src, | Line 333 file_cpyname(char *dst, const char *src, |
| } | } |
| void | void |
| file_catname(char *path, const char *sjis, int maxlen) | file_catname(char *path, const char *filename, int maxlen) |
| { | { |
| while (maxlen) { | for (; maxlen > 0; path++, maxlen--) { |
| if (*path == '\0') { | if (*path == '\0') { |
| break; | break; |
| } | } |
| path++; | |
| maxlen--; | |
| } | } |
| if (maxlen) { | if (maxlen > 0) { |
| codecnv_sjis2euc(path, maxlen, sjis, (UINT)-1); | milstr_ncpy(path, filename, maxlen); |
| for (; path[0] != '\0'; path++) { | for (; *path != '\0'; path++) { |
| if (!ISKANJI(path[0])) { | if (!ISKANJI(*path)) { |
| if (path[1] == '\0') { | path++; |
| if (*path == '\0') { | |
| break; | break; |
| } | } |
| path++; | } else if (((*path - 0x41) & 0xff) < 26) { |
| } else if ((((path[0]) - 0x41) & 0xff) < 26) { | *path |= 0x20; |
| path[0] |= 0x20; | } else if (*path == '\\') { |
| } else if (path[0] == '\\') { | *path = '/'; |
| path[0] = '/'; | |
| } | } |
| } | } |
| } | } |
| } | } |
| BOOL | BOOL |
| file_cmpname(const char *path, const char *sjis) | file_cmpname(const char *path, const char *path2) |
| { | { |
| char euc[MAX_PATH]; | |
| codecnv_sjis2euc(euc, sizeof(euc), sjis, (UINT)-1); | return strcmp(path, path2); |
| return strcmp(path, euc); | |
| } | } |
| char * | char * |
| Line 372 file_getname(char *path) | Line 370 file_getname(char *path) |
| { | { |
| char *ret; | char *ret; |
| for (ret = path; path[0] != '\0'; path++) { | for (ret = path; *path != '\0'; path++) { |
| if (ISKANJI(path[0])) { | if (ISKANJI(*path)) { |
| if (path[1] == '\0') { | path++; |
| if (*path == '\0') { | |
| break; | break; |
| } | } |
| path++; | } else if (*path == '/') { |
| } else if (path[0] == '/') { | |
| ret = path + 1; | ret = path + 1; |
| } | } |
| } | } |
| Line 397 file_cutname(char *path) | Line 395 file_cutname(char *path) |
| char * | char * |
| file_getext(char *path) | file_getext(char *path) |
| { | { |
| char *p; | char *p, *q; |
| char *q; | |
| p = file_getname(path); | for (p = file_getname(path), q = NULL; *p != '\0'; p++) { |
| q = NULL; | |
| while (*p != '\0') { | |
| if (*p == '.') { | if (*p == '.') { |
| q = p + 1; | q = p + 1; |
| } | } |
| p++; | |
| } | } |
| if (q == NULL) { | if (q == NULL) { |
| q = p; | q = p; |
| Line 417 file_getext(char *path) | Line 411 file_getext(char *path) |
| void | void |
| file_cutext(char *path) | file_cutext(char *path) |
| { | { |
| char *p; | char *p, *q; |
| char *q; | |
| p = file_getname(path); | for (p = file_getname(path), q = NULL; *p != '\0'; p++) { |
| q = NULL; | |
| while (*p != '\0') { | |
| if (*p == '.') { | if (*p == '.') { |
| q = p; | q = p; |
| } | } |
| p++; | |
| } | } |
| if (q != NULL) { | if (q != NULL) { |
| *q = '\0'; | *q = '\0'; |