Diff for /np2/win9x/dosio.cpp between versions 1.10 and 1.12

version 1.10, 2005/02/13 02:36:16 version 1.12, 2005/03/20 13:12:49
Line 1 Line 1
 #include        "compiler.h"  #include        "compiler.h"
   #include        "oemtext.h"
 #include        "dosio.h"  #include        "dosio.h"
   
   
Line 14  void dosio_term(void) { } Line 15  void dosio_term(void) { }
                                                                                         // ファイル操作                                                                                          // ファイル操作
 FILEH DOSIOCALL file_open(const OEMCHAR *path) {  FILEH DOSIOCALL file_open(const OEMCHAR *path) {
   
         FILEH   ret;  
   
         if ((ret = CreateFile(path, GENERIC_READ | GENERIC_WRITE,  #if defined(OSLANG_UTF8)
                                                 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL))          TCHAR tchr[MAX_PATH];
                                                                                                         == INVALID_HANDLE_VALUE) {          oemtotchar(tchr, NELEMENTS(tchr), path, -1);
                 if ((ret = CreateFile(path, GENERIC_READ,  #else
                                                 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL))          const TCHAR *tchr = path;
                                                                                                         == INVALID_HANDLE_VALUE) {  #endif
           FILEH ret;
           ret = CreateFile(tchr, GENERIC_READ | GENERIC_WRITE,
                                                   0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
           if (ret == INVALID_HANDLE_VALUE) {
                   ret = CreateFile(tchr, GENERIC_READ,
                                                   0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
                   if (ret == INVALID_HANDLE_VALUE) {
                         return(FILEH_INVALID);                          return(FILEH_INVALID);
                 }                  }
         }          }
Line 30  FILEH DOSIOCALL file_open(const OEMCHAR  Line 37  FILEH DOSIOCALL file_open(const OEMCHAR 
   
 FILEH DOSIOCALL file_open_rb(const OEMCHAR *path) {  FILEH DOSIOCALL file_open_rb(const OEMCHAR *path) {
   
         FILEH   ret;  #if defined(OSLANG_UTF8)
           TCHAR tchr[MAX_PATH];
         if ((ret = CreateFile(path, GENERIC_READ, FILE_SHARE_READ, 0,          oemtotchar(tchr, NELEMENTS(tchr), path, -1);
                                                                 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL))  #else
                                                                                                         == INVALID_HANDLE_VALUE) {          const TCHAR *tchr = path;
   #endif
           FILEH ret;
           ret = CreateFile(tchr, GENERIC_READ, FILE_SHARE_READ, 0,
                                                                   OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
           if (ret == INVALID_HANDLE_VALUE) {
                 return(FILEH_INVALID);                  return(FILEH_INVALID);
         }          }
         return(ret);          return(ret);
Line 42  FILEH DOSIOCALL file_open_rb(const OEMCH Line 54  FILEH DOSIOCALL file_open_rb(const OEMCH
   
 FILEH DOSIOCALL file_create(const OEMCHAR *path) {  FILEH DOSIOCALL file_create(const OEMCHAR *path) {
   
         FILEH   ret;  #if defined(OSLANG_UTF8)
           TCHAR tchr[MAX_PATH];
         if ((ret = CreateFile(path, GENERIC_READ | GENERIC_WRITE,          oemtotchar(tchr, NELEMENTS(tchr), path, -1);
                                                  0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL))  #else
                                                                                         == INVALID_HANDLE_VALUE) {          const TCHAR *tchr = path;
   #endif
           FILEH ret;
           ret = CreateFile(tchr, GENERIC_READ | GENERIC_WRITE,
                                                    0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
           if (ret == INVALID_HANDLE_VALUE) {
                 return(FILEH_INVALID);                  return(FILEH_INVALID);
         }          }
         return(ret);          return(ret);
Line 128  short DOSIOCALL file_getdatetime(FILEH h Line 145  short DOSIOCALL file_getdatetime(FILEH h
   
 short DOSIOCALL file_delete(const OEMCHAR *path) {  short DOSIOCALL file_delete(const OEMCHAR *path) {
   
         return(DeleteFile(path)?0:-1);  #if defined(OSLANG_UTF8)
           TCHAR tchr[MAX_PATH];
           oemtotchar(tchr, NELEMENTS(tchr), path, -1);
   #else
           const TCHAR *tchr = path;
   #endif
           return(DeleteFile(tchr)?0:-1);
 }  }
   
 short DOSIOCALL file_attr(const OEMCHAR *path) {  short DOSIOCALL file_attr(const OEMCHAR *path) {
   
         return((short)GetFileAttributes(path));  #if defined(OSLANG_UTF8)
           TCHAR tchr[MAX_PATH];
           oemtotchar(tchr, NELEMENTS(tchr), path, -1);
   #else
           const TCHAR *tchr = path;
   #endif
           return((short)GetFileAttributes(tchr));
 }  }
   
 short DOSIOCALL file_dircreate(const OEMCHAR *path) {  short DOSIOCALL file_dircreate(const OEMCHAR *path) {
   
         return(CreateDirectory(path, NULL)?0:-1);  #if defined(OSLANG_UTF8)
           TCHAR tchr[MAX_PATH];
           oemtotchar(tchr, NELEMENTS(tchr), path, -1);
   #else
           const TCHAR *tchr = path;
   #endif
           return(CreateDirectory(tchr, NULL)?0:-1);
 }  }
   
   
Line 152  void DOSIOCALL file_setcd(const OEMCHAR  Line 187  void DOSIOCALL file_setcd(const OEMCHAR 
   
 OEMCHAR * DOSIOCALL file_getcd(const OEMCHAR *path) {  OEMCHAR * DOSIOCALL file_getcd(const OEMCHAR *path) {
   
         file_cpyname(curfilep, path, sizeof(curpath) - (curfilep - curpath));          file_cpyname(curfilep, path, NELEMENTS(curpath) - (curfilep - curpath));
         return(curpath);          return(curpath);
 }  }
   
 FILEH DOSIOCALL file_open_c(const OEMCHAR *path) {  FILEH DOSIOCALL file_open_c(const OEMCHAR *path) {
   
         file_cpyname(curfilep, path, sizeof(curpath) - (curfilep - curpath));          file_cpyname(curfilep, path, NELEMENTS(curpath) - (curfilep - curpath));
         return(file_open(curpath));          return(file_open(curpath));
 }  }
   
 FILEH DOSIOCALL file_open_rb_c(const OEMCHAR *path) {  FILEH DOSIOCALL file_open_rb_c(const OEMCHAR *path) {
   
         file_cpyname(curfilep, path, sizeof(curpath) - (curfilep - curpath));          file_cpyname(curfilep, path, NELEMENTS(curpath) - (curfilep - curpath));
         return(file_open_rb(curpath));          return(file_open_rb(curpath));
 }  }
   
 FILEH DOSIOCALL file_create_c(const OEMCHAR *path) {  FILEH DOSIOCALL file_create_c(const OEMCHAR *path) {
   
         file_cpyname(curfilep, path, sizeof(curpath) - (curfilep - curpath));          file_cpyname(curfilep, path, NELEMENTS(curpath) - (curfilep - curpath));
         return(file_create(curpath));          return(file_create(curpath));
 }  }
   
 short DOSIOCALL file_delete_c(const OEMCHAR *path) {  short DOSIOCALL file_delete_c(const OEMCHAR *path) {
   
         file_cpyname(curfilep, path, sizeof(curpath) - (curfilep - curpath));          file_cpyname(curfilep, path, NELEMENTS(curpath) - (curfilep - curpath));
         return(file_delete(curpath));          return(file_delete(curpath));
 }  }
   
 short DOSIOCALL file_attr_c(const OEMCHAR *path) {  short DOSIOCALL file_attr_c(const OEMCHAR *path) {
   
         file_cpyname(curfilep, path, sizeof(curpath) - (curfilep - curpath));          file_cpyname(curfilep, path, NELEMENTS(curpath) - (curfilep - curpath));
         return(file_attr(curpath));          return(file_attr(curpath));
 }  }
   
Line 191  static BRESULT DOSIOCALL setflist(WIN32_ Line 226  static BRESULT DOSIOCALL setflist(WIN32_
   
 #if !defined(_WIN32_WCE)  #if !defined(_WIN32_WCE)
         if ((w32fd->dwFileAttributes & FILEATTR_DIRECTORY) &&          if ((w32fd->dwFileAttributes & FILEATTR_DIRECTORY) &&
                 ((!file_cmpname(w32fd->cFileName, OEMTEXT("."))) ||                  ((!lstrcmp(w32fd->cFileName, _T("."))) ||
                 (!file_cmpname(w32fd->cFileName, OEMTEXT(".."))))) {                  (!lstrcmp(w32fd->cFileName, _T(".."))))) {
                 return(FAILURE);                  return(FAILURE);
         }          }
 #endif  #endif
Line 200  static BRESULT DOSIOCALL setflist(WIN32_ Line 235  static BRESULT DOSIOCALL setflist(WIN32_
         fli->size = w32fd->nFileSizeLow;          fli->size = w32fd->nFileSizeLow;
         fli->attr = w32fd->dwFileAttributes;          fli->attr = w32fd->dwFileAttributes;
         cnvdatetime(&w32fd->ftLastWriteTime, &fli->date, &fli->time);          cnvdatetime(&w32fd->ftLastWriteTime, &fli->date, &fli->time);
   #if defined(OSLANG_UTF8)
           tchartooem(fli->path, NELEMENTS(fli->path), w32fd->cFileName, -1);
   #else
         milstr_ncpy(fli->path, w32fd->cFileName, NELEMENTS(fli->path));          milstr_ncpy(fli->path, w32fd->cFileName, NELEMENTS(fli->path));
   #endif
         return(SUCCESS);          return(SUCCESS);
 }  }
   
 FLISTH DOSIOCALL file_list1st(const OEMCHAR *dir, FLINFO *fli) {  FLISTH DOSIOCALL file_list1st(const OEMCHAR *dir, FLINFO *fli) {
   
         OEMCHAR                 path[MAX_PATH];  
         HANDLE                  hdl;  
         WIN32_FIND_DATA w32fd;  
   
           OEMCHAR path[MAX_PATH];
         milstr_ncpy(path, dir, NELEMENTS(path));          milstr_ncpy(path, dir, NELEMENTS(path));
         file_setseparator(path, NELEMENTS(path));          file_setseparator(path, NELEMENTS(path));
         milstr_ncat(path, OEMTEXT("*.*"), NELEMENTS(path));          milstr_ncat(path, OEMTEXT("*.*"), NELEMENTS(path));
         TRACEOUT(("file_list1st %s", path));          TRACEOUT(("file_list1st %s", path));
         hdl = FindFirstFile(path, &w32fd);  #if defined(OSLANG_UTF8)
           TCHAR tchr[MAX_PATH];
           oemtotchar(tchr, NELEMENTS(tchr), path, -1);
   #else
           const TCHAR *tchr = path;
   #endif
           HANDLE hdl;
           WIN32_FIND_DATA w32fd;
           hdl = FindFirstFile(tchr, &w32fd);
         if (hdl != INVALID_HANDLE_VALUE) {          if (hdl != INVALID_HANDLE_VALUE) {
                 do {                  do {
                         if (setflist(&w32fd, fli) == SUCCESS) {                          if (setflist(&w32fd, fli) == SUCCESS) {

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


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