Diff for /np2/wince/dosio.cpp between versions 1.8 and 1.9

version 1.8, 2004/06/20 11:19:46 version 1.9, 2005/02/12 12:13:59
Line 1 Line 1
 #include        "compiler.h"  #include        "compiler.h"
   #if defined(UNICODE) && defined(OSLANG_UTF8)
   #include        "codecnv.h"
   #endif
 #include        "dosio.h"  #include        "dosio.h"
   
   
Line 11  static OEMCHAR *curfilep = curpath; Line 14  static OEMCHAR *curfilep = curpath;
 void dosio_init(void) { }  void dosio_init(void) { }
 void dosio_term(void) { }  void dosio_term(void) { }
   
                                                                                         // ファイル操作  
 #if defined(UNICODE) && defined(OSLANG_SJIS)  
 static HANDLE _CreateFile(const OEMCHAR *lpFileName,  
                                         DWORD dwDesiredAccess,  
                                         DWORD dwShareMode,  
                                         LPSECURITY_ATTRIBUTES lpSecurityAttributes,  
                                         DWORD dwCreationDisposition,  
                                         DWORD dwFlagsAndAttributes,  
                                         HANDLE hTemplateFile) {  
   
         UINT16  ucs2[MAX_PATH];  
   
         MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, lpFileName, -1,                                                                                          // ファイル操作
                                                                                                         ucs2, NELEMENTS(ucs2));  FILEH file_open(const OEMCHAR *path) {
         return(CreateFile(ucs2, dwDesiredAccess, dwShareMode,  
                                                 lpSecurityAttributes, dwCreationDisposition,  
                                                 dwFlagsAndAttributes, hTemplateFile));  
 }  
 #elif defined(OSLANG_UTF8)  
 static HANDLE _CreateFile(const OEMCHAR *lpFileName,  
                                         DWORD dwDesiredAccess,  
                                         DWORD dwShareMode,  
                                         LPSECURITY_ATTRIBUTES lpSecurityAttributes,  
                                         DWORD dwCreationDisposition,  
                                         DWORD dwFlagsAndAttributes,  
                                         HANDLE hTemplateFile) {  
   
         UINT16  ucs2[MAX_PATH];          FILEH   ret;
   
         ucscnv_utf8toucs2(ucs2, NELEMENTS(ucs2), lpFileName, (UINT)-1);  #if defined(UNICODE) && defined(OSLANG_SJIS)
         return(CreateFile(ucs2, dwDesiredAccess, dwShareMode,          UINT16  oempath[MAX_PATH];
                                                 lpSecurityAttributes, dwCreationDisposition,          MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, path, -1,
                                                 dwFlagsAndAttributes, hTemplateFile));                                                                                                  oempath, NELEMENTS(oempath));
 }  #elif defined(UNICODE) && defined(OSLANG_UTF8)
           UINT16  oempath[MAX_PATH];
           codecnv_utf8toucs2(oempath, NELEMENTS(oempath), path, (UINT)-1);
 #else  #else
 #define _CreateFile(a, b, c, d, e, f, g)        CreateFile(a, b, c, d, e, f, g)  const OEMCHAR *oempath;
           oempath = path;
 #endif  #endif
   
           ret = CreateFile(oempath, GENERIC_READ | GENERIC_WRITE,
 FILEH file_open(const OEMCHAR *path) {                                                  0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
           if (ret == INVALID_HANDLE_VALUE) {
         FILEH   ret;                  ret = CreateFile(oempath, GENERIC_READ,
                                                   0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
         if ((ret = _CreateFile(path, GENERIC_READ | GENERIC_WRITE,                  if (ret == INVALID_HANDLE_VALUE) {
                                                 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL))  
                                                                                                         == INVALID_HANDLE_VALUE) {  
                 if ((ret = _CreateFile(path, GENERIC_READ,  
                                                 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL))  
                                                                                                         == INVALID_HANDLE_VALUE) {  
                         return(FILEH_INVALID);                          return(FILEH_INVALID);
                 }                  }
         }          }
Line 70  FILEH file_open_rb(const OEMCHAR *path)  Line 48  FILEH file_open_rb(const OEMCHAR *path) 
   
         FILEH   ret;          FILEH   ret;
   
         if ((ret = _CreateFile(path, GENERIC_READ, FILE_SHARE_READ, 0,  #if defined(UNICODE) && defined(OSLANG_SJIS)
                                                                 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL))          UINT16  oempath[MAX_PATH];
                                                                                                         == INVALID_HANDLE_VALUE) {          MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, path, -1,
                                                                                                   oempath, NELEMENTS(oempath));
   #elif defined(UNICODE) && defined(OSLANG_UTF8)
           UINT16  oempath[MAX_PATH];
           codecnv_utf8toucs2(oempath, NELEMENTS(oempath), path, (UINT)-1);
   #else
   const OEMCHAR *oempath;
           oempath = path;
   #endif
   
           ret = CreateFile(oempath, GENERIC_READ, FILE_SHARE_READ, 0,
                                                                   OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
           if (ret != INVALID_HANDLE_VALUE) {
                   return(ret);
           }
           else {
                 return(FILEH_INVALID);                  return(FILEH_INVALID);
         }          }
         return(ret);  
 }  }
   
 FILEH file_create(const OEMCHAR *path) {  FILEH file_create(const OEMCHAR *path) {
   
         FILEH   ret;          FILEH   ret;
   
         if ((ret = _CreateFile(path, GENERIC_READ | GENERIC_WRITE,  #if defined(UNICODE) && defined(OSLANG_SJIS)
                                                  0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL))          UINT16  oempath[MAX_PATH];
                                                                                         == INVALID_HANDLE_VALUE) {          MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, path, -1,
                                                                                                   oempath, NELEMENTS(oempath));
   #elif defined(UNICODE) && defined(OSLANG_UTF8)
           UINT16  oempath[MAX_PATH];
           codecnv_utf8toucs2(oempath, NELEMENTS(oempath), path, (UINT)-1);
   #else
   const OEMCHAR *oempath;
           oempath = path;
   #endif
           ret = CreateFile(oempath, GENERIC_READ | GENERIC_WRITE,
                                                    0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
           if (ret != INVALID_HANDLE_VALUE) {
                   return(ret);
           }
           else {
                 return(FILEH_INVALID);                  return(FILEH_INVALID);
         }          }
         return(ret);  
 }  }
   
 long file_seek(FILEH handle, long pointer, int method) {  long file_seek(FILEH handle, long pointer, int method) {
Line 167  short file_getdatetime(FILEH handle, DOS Line 172  short file_getdatetime(FILEH handle, DOS
 short file_delete(const OEMCHAR *path) {  short file_delete(const OEMCHAR *path) {
   
 #if defined(UNICODE) && defined(OSLANG_SJIS)  #if defined(UNICODE) && defined(OSLANG_SJIS)
         UINT16  ucs2[MAX_PATH];          UINT16  oempath[MAX_PATH];
         MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, path, -1,          MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, path, -1,
                                                                                                         ucs2, NELEMENTS(ucs2));                                                                                                  oempath, NELEMENTS(oempath));
         return(DeleteFile(ucs2)?0:-1);  #elif defined(UNICODE) && defined(OSLANG_UTF8)
 #elif defined(OSLANG_UTF8)          UINT16  oempath[MAX_PATH];
         UINT16  ucs2[MAX_PATH];          codecnv_utf8toucs2(oempath, NELEMENTS(oempath), path, (UINT)-1);
         ucscnv_utf8toucs2(ucs2, NELEMENTS(ucs2), path, (UINT)-1);  
         return(DeleteFile(ucs2)?0:-1);  
 #else  #else
         return(DeleteFile(path)?0:-1);  const OEMCHAR *oempath;
           oempath = path;
 #endif  #endif
           return(DeleteFile(oempath)?0:-1);
 }  }
   
 short file_attr(const OEMCHAR *path) {  short file_attr(const OEMCHAR *path) {
   
 #if defined(UNICODE) && defined(OSLANG_SJIS)  #if defined(UNICODE) && defined(OSLANG_SJIS)
         UINT16  ucs2[MAX_PATH];          UINT16  oempath[MAX_PATH];
         MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, path, -1,          MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, path, -1,
                                                                                                         ucs2, NELEMENTS(ucs2));                                                                                                  oempath, NELEMENTS(oempath));
         return((short)GetFileAttributes(ucs2));  
 #elif defined(OSLANG_UTF8)  
         UINT16  ucs2[MAX_PATH];  
         ucscnv_utf8toucs2(ucs2, NELEMENTS(ucs2), path, (UINT)-1);  
         return((short)GetFileAttributes(ucs2));          return((short)GetFileAttributes(ucs2));
   #elif defined(UNICODE) && defined(OSLANG_UTF8)
           UINT16  oempath[MAX_PATH];
           codecnv_utf8toucs2(oempath, NELEMENTS(oempath), path, (UINT)-1);
 #else  #else
         return((short)GetFileAttributes(path));  const OEMCHAR *oempath;
           oempath = path;
 #endif  #endif
           return((short)GetFileAttributes(oempath));
 }  }
   
 short file_dircreate(const OEMCHAR *path) {  short file_dircreate(const OEMCHAR *path) {
   
 #if defined(UNICODE) && defined(OSLANG_SJIS)  #if defined(UNICODE) && defined(OSLANG_SJIS)
         UINT16  ucs2[MAX_PATH];          UINT16  oempath[MAX_PATH];
         MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, path, -1,          MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, path, -1,
                                                                                                         ucs2, NELEMENTS(ucs2));                                                                                                  oempath, NELEMENTS(oempath));
         return(CreateDirectory(ucs2, NULL)?0:-1);  #elif defined(UNICODE) && defined(OSLANG_UTF8)
 #elif defined(OSLANG_UTF8)          UINT16  oempath[MAX_PATH];
         UINT16  ucs2[MAX_PATH];          codecnv_utf8toucs2(oempath, NELEMENTS(oempath), path, (UINT)-1);
         ucscnv_utf8toucs2(ucs2, NELEMENTS(ucs2), path, (UINT)-1);  
         return(CreateDirectory(ucs2, NULL)?0:-1);  
 #else  #else
         return(CreateDirectory(path, NULL)?0:-1);  const OEMCHAR *oempath;
           oempath = path;
 #endif  #endif
           return(CreateDirectory(oempath, NULL)?0:-1);
 }  }
   
   
Line 266  static const OEMCHAR str_parentdir[] = O Line 272  static const OEMCHAR str_parentdir[] = O
 #endif  #endif
 static const OEMCHAR str_wildcard[] = OEMTEXT("*.*");  static const OEMCHAR str_wildcard[] = OEMTEXT("*.*");
   
 static BOOL setflist(WIN32_FIND_DATA *w32fd, FLINFO *fli) {  static BRESULT setflist(WIN32_FIND_DATA *w32fd, FLINFO *fli) {
   
 #if defined(UNICODE) && defined(OSLANG_SJIS)  #if defined(UNICODE) && defined(OSLANG_SJIS)
         WideCharToMultiByte(CP_ACP, 0, w32fd->cFileName, -1,          WideCharToMultiByte(CP_ACP, 0, w32fd->cFileName, -1,
                                                                 fli->path, NELEMENTS(fli->path), NULL, NULL);                                                                  fli->path, NELEMENTS(fli->path), NULL, NULL);
 #elif defined(OSLANG_UTF8)  #elif defined(UNICODE) && defined(OSLANG_UTF8)
         ucscnv_ucs2toutf8(fli->path, NELEMENTS(fli->path), w32fd->cFileName, -1);          codecnv_ucs2toutf8(fli->path, NELEMENTS(fli->path), w32fd->cFileName, -1);
 #else  #else
         file_cpyname(fli->path, w32fd->cFileName, NELEMENTS(fli->path));          file_cpyname(fli->path, w32fd->cFileName, NELEMENTS(fli->path));
 #endif  #endif
Line 306  FLISTH file_list1st(const OEMCHAR *dir,  Line 312  FLISTH file_list1st(const OEMCHAR *dir, 
         MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, path, -1,          MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, path, -1,
                                                                                                         ucs2, NELEMENTS(ucs2));                                                                                                          ucs2, NELEMENTS(ucs2));
         hdl = FindFirstFile(ucs2, &w32fd);          hdl = FindFirstFile(ucs2, &w32fd);
 #elif defined(OSLANG_UTF8)  #elif defined(UNICODE) && defined(OSLANG_UTF8)
         UINT16  ucs2[MAX_PATH];          UINT16  ucs2[MAX_PATH];
         ucscnv_utf8toucs2(ucs2, NELEMENTS(ucs2), path, (UINT)-1);          codecnv_utf8toucs2(ucs2, NELEMENTS(ucs2), path, (UINT)-1);
         hdl = FindFirstFile(ucs2, &w32fd);          hdl = FindFirstFile(ucs2, &w32fd);
 #else  #else
         hdl = FindFirstFile(path, &w32fd);          hdl = FindFirstFile(path, &w32fd);

Removed from v.1.8  
changed lines
  Added in v.1.9


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