Diff for /np2/x11/dosio.c between versions 1.8 and 1.9

version 1.8, 2004/01/14 16:15:49 version 1.9, 2004/02/05 13:45:06
Line 1 Line 1
 #define VERBOSE(s)      printf s  /*      $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 230  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);  
         VERBOSE(("file_list1st: opendir(%s)\n", 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"));                  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;
         }          }
         VERBOSE(("file_list1st: file_listnext failure\n"));          VERBOSE(("file_list1st: file_listnext failure"));
         closedir(ret);          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\n"));                  VERBOSE(("file_listnext: readdir failure"));
                 return FAILURE;                  return FAILURE;
         }          }
         if (stat(de->d_name, &sb) != 0) {  
                 VERBOSE(("file_listnext: stat failure\n"));          milstr_ncpy(buf, hdl->path, sizeof(buf));
           milstr_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 275  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"));
         VERBOSE(("file_listnext: success\n"));  
         return SUCCESS;          return SUCCESS;
 }  }
   
Line 284  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.8  
changed lines
  Added in v.1.9


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