|
|
| version 1.5, 2004/01/12 08:01:00 | version 1.7, 2004/06/21 02:01:32 |
|---|---|
| Line 25 void dosio_term(void) { | Line 25 void dosio_term(void) { |
| /* ファイル操作 */ | /* ファイル操作 */ |
| FILEH file_open(const char *path) { | FILEH file_open(const char *path) { |
| #if defined(WIN32) && defined(OSLANG_EUC) | |
| char sjis[MAX_PATH]; | |
| codecnv_euc2sjis(sjis, sizeof(sjis), path, (UINT)-1); | |
| return(fopen(sjis, "rb+")); | |
| #else | |
| return(fopen(path, "rb+")); | return(fopen(path, "rb+")); |
| #endif | |
| } | } |
| FILEH file_open_rb(const char *path) { | FILEH file_open_rb(const char *path) { |
| #if defined(WIN32) && defined(OSLANG_EUC) | |
| char sjis[MAX_PATH]; | |
| codecnv_euc2sjis(sjis, sizeof(sjis), path, (UINT)-1); | |
| return(fopen(sjis, "rb+")); | |
| #else | |
| return(fopen(path, "rb+")); | return(fopen(path, "rb+")); |
| #endif | |
| } | } |
| FILEH file_create(const char *path) { | FILEH file_create(const char *path) { |
| #if defined(WIN32) && defined(OSLANG_EUC) | |
| char sjis[MAX_PATH]; | |
| codecnv_euc2sjis(sjis, sizeof(sjis), path, (UINT)-1); | |
| return(fopen(sjis, "wb+")); | |
| #else | |
| return(fopen(path, "wb+")); | return(fopen(path, "wb+")); |
| #endif | |
| } | } |
| long file_seek(FILEH handle, long pointer, int method) { | long file_seek(FILEH handle, long pointer, int method) { |
| Line 151 short file_dircreate(const char *path) { | Line 169 short file_dircreate(const char *path) { |
| /* カレントファイル操作 */ | /* カレントファイル操作 */ |
| void file_setcd(const char *exepath) { | void file_setcd(const char *exepath) { |
| milstr_ncpy(curpath, exepath, sizeof(curpath)); | file_cpyname(curpath, exepath, sizeof(curpath)); |
| curfilep = file_getname(curpath); | curfilep = file_getname(curpath); |
| *curfilep = '\0'; | *curfilep = '\0'; |
| } | } |
| char *file_getcd(const char *path) { | char *file_getcd(const char *path) { |
| milstr_ncpy(curfilep, path, sizeof(curpath) - (curfilep - curpath)); | file_cpyname(curfilep, path, sizeof(curpath) - (curfilep - curpath)); |
| return(curpath); | return(curpath); |
| } | } |
| FILEH file_open_c(const char *path) { | FILEH file_open_c(const char *path) { |
| milstr_ncpy(curfilep, path, sizeof(curpath) - (curfilep - curpath)); | file_cpyname(curfilep, path, sizeof(curpath) - (curfilep - curpath)); |
| return(file_open(curpath)); | return(file_open(curpath)); |
| } | } |
| FILEH file_open_rb_c(const char *path) { | FILEH file_open_rb_c(const char *path) { |
| milstr_ncpy(curfilep, path, sizeof(curpath) - (curfilep - curpath)); | file_cpyname(curfilep, path, sizeof(curpath) - (curfilep - curpath)); |
| return(file_open_rb(curpath)); | return(file_open_rb(curpath)); |
| } | } |
| FILEH file_create_c(const char *path) { | FILEH file_create_c(const char *path) { |
| milstr_ncpy(curfilep, path, sizeof(curpath) - (curfilep - curpath)); | file_cpyname(curfilep, path, sizeof(curpath) - (curfilep - curpath)); |
| return(file_create(curpath)); | return(file_create(curpath)); |
| } | } |
| short file_delete_c(const char *path) { | short file_delete_c(const char *path) { |
| milstr_ncpy(curfilep, path, sizeof(curpath) - (curfilep - curpath)); | file_cpyname(curfilep, path, sizeof(curpath) - (curfilep - curpath)); |
| return(file_delete(curpath)); | return(file_delete(curpath)); |
| } | } |
| short file_attr_c(const char *path) { | short file_attr_c(const char *path) { |
| milstr_ncpy(curfilep, path, sizeof(curpath) - (curfilep - curpath)); | file_cpyname(curfilep, path, sizeof(curpath) - (curfilep - curpath)); |
| return(file_attr_c(curpath)); | return(file_attr_c(curpath)); |
| } | } |
| Line 229 static BOOL setflist(WIN32_FIND_DATA *w3 | Line 247 static BOOL setflist(WIN32_FIND_DATA *w3 |
| == SUCCESS) { | == SUCCESS) { |
| fli->caps |= FLICAPS_DATE | FLICAPS_TIME; | fli->caps |= FLICAPS_DATE | FLICAPS_TIME; |
| } | } |
| milstr_ncpy(fli->path, w32fd->cFileName, sizeof(fli->path)); | #if defined(OSLANG_EUC) |
| codecnv_sjis2euc(fli->path, sizeof(fli->path), | |
| w32fd->cFileName, (UINT)-1); | |
| #else | |
| file_cpyname(fli->path, w32fd->cFileName, sizeof(fli->path)); | |
| #endif | |
| return(SUCCESS); | return(SUCCESS); |
| } | } |
| Line 239 FLISTH file_list1st(const char *dir, FLI | Line 262 FLISTH file_list1st(const char *dir, FLI |
| HANDLE hdl; | HANDLE hdl; |
| WIN32_FIND_DATA w32fd; | WIN32_FIND_DATA w32fd; |
| milsjis_ncpy(path, dir, sizeof(path)); | file_cpyname(path, dir, sizeof(path)); |
| file_setseparator(path, sizeof(path)); | file_setseparator(path, sizeof(path)); |
| milsjis_ncat(path, "*.*", sizeof(path)); | file_catname(path, "*.*", sizeof(path)); |
| hdl = FindFirstFile(path, &w32fd); | hdl = FindFirstFile(path, &w32fd); |
| if (hdl != INVALID_HANDLE_VALUE) { | if (hdl != INVALID_HANDLE_VALUE) { |
| do { | do { |
| Line 332 void file_listclose(FLISTH hdl) { | Line 355 void file_listclose(FLISTH hdl) { |
| void file_catname(char *path, const char *name, int maxlen) { | void file_catname(char *path, const char *name, int maxlen) { |
| char c; | int csize; |
| while(maxlen > 0) { | while(maxlen > 0) { |
| if (*path == '\0') { | if (*path == '\0') { |
| Line 341 void file_catname(char *path, const char | Line 364 void file_catname(char *path, const char |
| path++; | path++; |
| maxlen--; | maxlen--; |
| } | } |
| if (maxlen > 0) { | file_cpyname(path, name, maxlen); |
| maxlen--; | while((csize = milstr_charsize(path)) != 0) { |
| while(maxlen > 0) { | if ((csize == 1) && (*path == '\\')) { |
| maxlen--; | *path = '/'; |
| c = *name++; | |
| if (ISKANJI1ST(c)) { | |
| if ((maxlen == 0) || (*name == '\0')) { | |
| break; | |
| } | |
| *path++ = c; | |
| *path++ = *name++; | |
| } | |
| else if (c == '\\') { | |
| *path++ = '/'; | |
| } | |
| else if (c) { | |
| *path++ = c; | |
| } | |
| else { | |
| break; | |
| } | |
| } | } |
| *path = '\0'; | path += csize; |
| } | } |
| } | } |
| char *file_getname(char *path) { | char *file_getname(const char *path) { |
| char *ret; | const char *ret; |
| int csize; | |
| ret = path; | ret = path; |
| while(1) { | while((csize = milstr_charsize(path)) != 0) { |
| if (ISKANJI1ST(*path)) { | if ((csize == 1) && (*path == '/')) { |
| if (*(path+1) == '\0') { | |
| break; | |
| } | |
| path++; | |
| } | |
| else if (*path == '/') { | |
| ret = path + 1; | ret = path + 1; |
| } | } |
| else if (*path == '\0') { | path += csize; |
| break; | |
| } | |
| path++; | |
| } | } |
| return(ret); | return((char *)ret); |
| } | } |
| void file_cutname(char *path) { | void file_cutname(char *path) { |
| Line 398 void file_cutname(char *path) { | Line 396 void file_cutname(char *path) { |
| *p = '\0'; | *p = '\0'; |
| } | } |
| char *file_getext(char *path) { | char *file_getext(const char *path) { |
| char *p; | const char *p; |
| char *q; | const char *q; |
| p = file_getname(path); | p = file_getname(path); |
| q = NULL; | q = NULL; |
| Line 414 char *file_getext(char *path) { | Line 412 char *file_getext(char *path) { |
| if (q == NULL) { | if (q == NULL) { |
| q = p; | q = p; |
| } | } |
| return(q); | return((char *)q); |
| } | } |
| void file_cutext(char *path) { | void file_cutext(char *path) { |