Diff for /np2/x11/dosio.c between versions 1.7 and 1.10

version 1.7, 2004/01/13 16:30:21 version 1.10, 2004/02/06 16:51:21
Line 1 Line 1
   /*      $Id$    */
   
 #include "compiler.h"  #include "compiler.h"
   
 #include <sys/stat.h>  
 #include <time.h>  #include <time.h>
 #include <dirent.h>  
   
 #include "codecnv.h"  #include "codecnv.h"
 #include "dosio.h"  #include "dosio.h"
Line 228  file_attr_c(const char *sjis) Line 228  file_attr_c(const char *sjis)
 FLISTH  FLISTH
 file_list1st(const char *dir, FLINFO *fli)  file_list1st(const char *dir, FLINFO *fli)
 {  {
         char eucpath[MAX_PATH];          FLISTH ret;
         DIR *ret;  
   
         mileuc_ncpy(eucpath, dir, sizeof(eucpath));          ret = (FLISTH)malloc(sizeof(_FLISTH));
         file_setseparator(eucpath, sizeof(eucpath));  
         ret = opendir(eucpath);  
         if (ret == NULL) {          if (ret == NULL) {
                   VERBOSE(("file_list1st: couldn't alloc memory (size = %d)", sizeof(_FLISTH)));
                   return FLISTH_INVALID;
           }
   
           mileuc_ncpy(ret->path, dir, sizeof(ret->path));
           file_setseparator(ret->path, sizeof(ret->path));
           ret->hdl = opendir(ret->path);
           VERBOSE(("file_list1st: opendir(%s)", ret->path));
           if (ret->hdl == NULL) {
                   VERBOSE(("file_list1st: opendir failure"));
                   free(ret);
                 return FLISTH_INVALID;                  return FLISTH_INVALID;
         }          }
         if (file_listnext((FLISTH)ret, fli) == SUCCESS) {          if (file_listnext((FLISTH)ret, fli) == SUCCESS) {
                 return (FLISTH)ret;                  return (FLISTH)ret;
         }          }
         closedir(ret);          VERBOSE(("file_list1st: file_listnext failure"));
           closedir(ret->hdl);
           free(ret);
         return FLISTH_INVALID;          return FLISTH_INVALID;
 }  }
   
 BOOL  BOOL
 file_listnext(FLISTH hdl, FLINFO *fli)  file_listnext(FLISTH hdl, FLINFO *fli)
 {  {
           char buf[MAX_PATH];
         struct dirent *de;          struct dirent *de;
         struct stat sb;          struct stat sb;
   
         de = readdir((DIR *)hdl);          de = readdir(hdl->hdl);
         if (de == NULL) {          if (de == NULL) {
                   VERBOSE(("file_listnext: readdir failure"));
                 return FAILURE;                  return FAILURE;
         }          }
         if (stat(de->d_name, &sb) != 0) {  
           milstr_ncpy(buf, hdl->path, sizeof(buf));
           mileuc_ncat(buf, de->d_name, sizeof(buf));
           if (stat(buf, &sb) != 0) {
                   VERBOSE(("file_listnext: stat failure. (path = %s)", buf));
                 return FAILURE;                  return FAILURE;
         }          }
   
         fli->caps = FLICAPS_SIZE | FLICAPS_ATTR | FLICAPS_DATE | FLICAPS_TIME;          fli->caps = FLICAPS_SIZE | FLICAPS_ATTR | FLICAPS_DATE | FLICAPS_TIME;
         fli->size = sb.st_size;          fli->size = sb.st_size;
           fli->attr = 0;
         if (S_ISDIR(sb.st_mode)) {          if (S_ISDIR(sb.st_mode)) {
                 fli->attr |= FILEATTR_DIRECTORY;                  fli->attr |= FILEATTR_DIRECTORY;
         }          }
Line 268  file_listnext(FLISTH hdl, FLINFO *fli) Line 285  file_listnext(FLISTH hdl, FLINFO *fli)
         }          }
         cnvdatetime(&sb, &fli->date, &fli->time);          cnvdatetime(&sb, &fli->date, &fli->time);
         mileuc_ncpy(fli->path, de->d_name, sizeof(fli->path));          mileuc_ncpy(fli->path, de->d_name, sizeof(fli->path));
           VERBOSE(("file_listnext: success"));
         return SUCCESS;          return SUCCESS;
 }  }
   
Line 276  void Line 293  void
 file_listclose(FLISTH hdl)  file_listclose(FLISTH hdl)
 {  {
   
         closedir((DIR *)hdl);          if (hdl) {
                   closedir(hdl->hdl);
                   free(hdl);
           }
 }  }
   
 static int  static int

Removed from v.1.7  
changed lines
  Added in v.1.10


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