Diff for /np2/sdl/dosio.c between versions 1.4 and 1.6

version 1.4, 2004/01/10 20:15:43 version 1.6, 2004/06/20 09:36:37
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 218  static BOOL cnvdatetime(FILETIME *file,  Line 236  static BOOL cnvdatetime(FILETIME *file, 
 static BOOL setflist(WIN32_FIND_DATA *w32fd, FLINFO *fli) {  static BOOL setflist(WIN32_FIND_DATA *w32fd, FLINFO *fli) {
   
         if ((w32fd->dwFileAttributes & FILEATTR_DIRECTORY) &&          if ((w32fd->dwFileAttributes & FILEATTR_DIRECTORY) &&
                 ((file_cmpname(w32fd->cFileName, ".")) ||                  ((!file_cmpname(w32fd->cFileName, ".")) ||
                 (file_cmpname(w32fd->cFileName, "..")))) {                  (!file_cmpname(w32fd->cFileName, "..")))) {
                 return(FAILURE);                  return(FAILURE);
         }          }
         fli->caps = FLICAPS_SIZE | FLICAPS_ATTR;          fli->caps = FLICAPS_SIZE | FLICAPS_ATTR;
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(char *path) {
   
         char    *ret;          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(ret);
 }  }

Removed from v.1.4  
changed lines
  Added in v.1.6


RetroPC.NET-CVS <cvs@retropc.net>