Diff for /np2/wince/dosio.cpp between versions 1.11 and 1.12

version 1.11, 2005/03/24 04:40:33 version 1.12, 2005/04/01 15:35:50
Line 1 Line 1
 #include        "compiler.h"  #include        "compiler.h"
 #if defined(UNICODE) && defined(OSLANG_UTF8)  #include        "oemtext.h"
 #include        "codecnv.h"  
 #endif  
 #include        "dosio.h"  #include        "dosio.h"
   
   
Line 18  void dosio_term(void) { } Line 16  void dosio_term(void) { }
                                                                                         // ファイル操作                                                                                          // ファイル操作
 FILEH file_open(const OEMCHAR *path) {  FILEH file_open(const OEMCHAR *path) {
   
         FILEH   ret;  #if defined(OEMCHAR_SAME_TCHAR)
           const TCHAR *tcharpath = path;
 #if defined(UNICODE) && defined(OSLANG_SJIS)  
         UINT16  oempath[MAX_PATH];  
         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  #else
 const OEMCHAR *oempath;          TCHAR tcharpath[MAX_PATH];
         oempath = path;          oemtotchar(tcharpath, NELEMENTS(tcharpath), path, (UINT)-1);
 #endif  #endif
           FILEH ret;
         ret = CreateFile(oempath, GENERIC_READ | GENERIC_WRITE,          ret = CreateFile(tcharpath, GENERIC_READ | GENERIC_WRITE,
                                                 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);                                                  0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
         if (ret == INVALID_HANDLE_VALUE) {          if (ret == INVALID_HANDLE_VALUE) {
                 ret = CreateFile(oempath, GENERIC_READ,                  ret = CreateFile(tcharpath, GENERIC_READ,
                                                 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);                                                  0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
                 if (ret == INVALID_HANDLE_VALUE) {                  if (ret == INVALID_HANDLE_VALUE) {
                         return(FILEH_INVALID);                          return(FILEH_INVALID);
Line 46  const OEMCHAR *oempath; Line 37  const OEMCHAR *oempath;
   
 FILEH file_open_rb(const OEMCHAR *path) {  FILEH file_open_rb(const OEMCHAR *path) {
   
         FILEH   ret;  #if defined(OEMCHAR_SAME_TCHAR)
           const TCHAR *tcharpath = path;
 #if defined(UNICODE) && defined(OSLANG_SJIS)  
         UINT16  oempath[MAX_PATH];  
         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  #else
 const OEMCHAR *oempath;          TCHAR tcharpath[MAX_PATH];
         oempath = path;          oemtotchar(tcharpath, NELEMENTS(tcharpath), path, (UINT)-1);
 #endif  #endif
           FILEH ret;
         ret = CreateFile(oempath, GENERIC_READ, FILE_SHARE_READ, 0,          ret = CreateFile(tcharpath, GENERIC_READ, FILE_SHARE_READ, 0,
                                                                 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);                                                                  OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
         if (ret != INVALID_HANDLE_VALUE) {          if (ret != INVALID_HANDLE_VALUE) {
                 return(ret);                  return(ret);
Line 72  const OEMCHAR *oempath; Line 56  const OEMCHAR *oempath;
   
 FILEH file_create(const OEMCHAR *path) {  FILEH file_create(const OEMCHAR *path) {
   
         FILEH   ret;  #if defined(OEMCHAR_SAME_TCHAR)
           const TCHAR *tcharpath = path;
 #if defined(UNICODE) && defined(OSLANG_SJIS)  
         UINT16  oempath[MAX_PATH];  
         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  #else
 const OEMCHAR *oempath;          TCHAR tcharpath[MAX_PATH];
         oempath = path;          oemtotchar(tcharpath, NELEMENTS(tcharpath), path, (UINT)-1);
 #endif  #endif
         ret = CreateFile(oempath, GENERIC_READ | GENERIC_WRITE,          FILEH ret;
           ret = CreateFile(tcharpath, GENERIC_READ | GENERIC_WRITE,
                                                  0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);                                                   0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
         if (ret != INVALID_HANDLE_VALUE) {          if (ret != INVALID_HANDLE_VALUE) {
                 return(ret);                  return(ret);
Line 136  UINT file_getsize(FILEH handle) { Line 114  UINT file_getsize(FILEH handle) {
         return(GetFileSize(handle, NULL));          return(GetFileSize(handle, NULL));
 }  }
   
 static BOOL cnvdatetime(FILETIME *file, DOSDATE *dosdate, DOSTIME *dostime) {  static BRESULT cnvdatetime(const FILETIME *file,
                                                                                   DOSDATE *dosdate, DOSTIME *dostime) {
   
         FILETIME        localtime;          FILETIME        localtime;
         SYSTEMTIME      systime;          SYSTEMTIME      systime;
Line 171  short file_getdatetime(FILEH handle, DOS Line 150  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(OEMCHAR_SAME_TCHAR)
         UINT16  oempath[MAX_PATH];          const TCHAR *tcharpath = path;
         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  #else
 const OEMCHAR *oempath;          TCHAR tcharpath[MAX_PATH];
         oempath = path;          oemtotchar(tcharpath, NELEMENTS(tcharpath), path, (UINT)-1);
 #endif  #endif
         return(DeleteFile(oempath)?0:-1);          return(DeleteFile(tcharpath)?0:-1);
 }  }
   
 short file_attr(const OEMCHAR *path) {  short file_attr(const OEMCHAR *path) {
   
 #if defined(UNICODE) && defined(OSLANG_SJIS)  #if defined(OEMCHAR_SAME_TCHAR)
         UINT16  oempath[MAX_PATH];  const TCHAR *tcharpath = path;
         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  #else
 const OEMCHAR *oempath;          TCHAR tcharpath[MAX_PATH];
         oempath = path;          oemtotchar(tcharpath, NELEMENTS(tcharpath), path, (UINT)-1);
 #endif  #endif
         return((short)GetFileAttributes(oempath));          return((short)GetFileAttributes(tcharpath));
 }  }
   
 short file_dircreate(const OEMCHAR *path) {  short file_dircreate(const OEMCHAR *path) {
   
 #if defined(UNICODE) && defined(OSLANG_SJIS)  #if defined(OEMCHAR_SAME_TCHAR)
         UINT16  oempath[MAX_PATH];          const TCHAR *tcharpath = path;
         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  #else
 const OEMCHAR *oempath;          TCHAR tcharpath[MAX_PATH];
         oempath = path;          oemtotchar(tcharpath, NELEMENTS(tcharpath), path, (UINT)-1);
 #endif  #endif
         return(CreateDirectory(oempath, NULL)?0:-1);          return(CreateDirectory(tcharpath, NULL)?0:-1);
 }  }
   
   
Line 266  short file_attr_c(const OEMCHAR *path) { Line 230  short file_attr_c(const OEMCHAR *path) {
 // ----  // ----
   
 #if !defined(_WIN32_WCE)  #if !defined(_WIN32_WCE)
 static const OEMCHAR str_selfdir[] = OEMTEXT(".");  static const TCHAR str_selfdir[] = _T(".");
 static const OEMCHAR str_parentdir[] = OEMTEXT("..");  static const TCHAR str_parentdir[] = _T("..");
 #endif  #endif
 static const OEMCHAR str_wildcard[] = OEMTEXT("*.*");  static const OEMCHAR str_wildcard[] = OEMTEXT("*.*");
   
 static BRESULT setflist(WIN32_FIND_DATA *w32fd, FLINFO *fli) {  static BRESULT setflist(const WIN32_FIND_DATA *w32fd, FLINFO *fli) {
   
 #if defined(UNICODE) && defined(OSLANG_SJIS)  
         WideCharToMultiByte(CP_ACP, 0, w32fd->cFileName, -1,  
                                                                 fli->path, NELEMENTS(fli->path), NULL, NULL);  
 #elif defined(UNICODE) && defined(OSLANG_UTF8)  
         codecnv_ucs2toutf8(fli->path, NELEMENTS(fli->path), w32fd->cFileName, -1);  
 #else  
         file_cpyname(fli->path, w32fd->cFileName, NELEMENTS(fli->path));  
 #endif  
 #if !defined(_WIN32_WCE)  #if !defined(_WIN32_WCE)
         if ((w32fd->dwFileAttributes & FILEATTR_DIRECTORY) &&          if ((w32fd->dwFileAttributes & FILEATTR_DIRECTORY) &&
                 ((!file_cmpname(fli->path, str_selfdir)) ||                  ((!lstrcmp(w32fd->cFileName, str_selfdir)) ||
                 (!file_cmpname(fli->path, str_parentdir)))) {                  (!lstrcmp(w32fd->cFileName, str_parentdir)))) {
                 return(FAILURE);                  return(FAILURE);
         }          }
 #endif  #endif
Line 292  static BRESULT setflist(WIN32_FIND_DATA  Line 248  static BRESULT setflist(WIN32_FIND_DATA 
         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(OEMCHAR_SAME_TCHAR)
           file_cpyname(fli->path, w32fd->cFileName, NELEMENTS(fli->path));
   #else
           tchartooem(fli->path, NELEMENTS(fli->path), w32fd->cFileName, (UINT)-1);
   #endif
         return(SUCCESS);          return(SUCCESS);
 }  }
   
 FLISTH file_list1st(const OEMCHAR *dir, FLINFO *fli) {  FLISTH file_list1st(const OEMCHAR *dir, FLINFO *fli) {
   
         OEMCHAR                 path[MAX_PATH];          OEMCHAR path[MAX_PATH];
         HANDLE                  hdl;  
         WIN32_FIND_DATA w32fd;  
   
         file_cpyname(path, dir, NELEMENTS(path));          file_cpyname(path, dir, NELEMENTS(path));
         file_setseparator(path, NELEMENTS(path));          file_setseparator(path, NELEMENTS(path));
         file_catname(path, str_wildcard, NELEMENTS(path));          file_catname(path, str_wildcard, NELEMENTS(path));
         TRACEOUT(("file_list1st %s", path));          TRACEOUT(("file_list1st %s", path));
   #if defined(OEMCHAR_SAME_TCHAR)
 #if defined(UNICODE) && defined(OSLANG_SJIS)  const TCHAR *tcharpath = path;
         UINT16  ucs2[MAX_PATH];  
         MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, path, -1,  
                                                                                                         ucs2, NELEMENTS(ucs2));  
         hdl = FindFirstFile(ucs2, &w32fd);  
 #elif defined(UNICODE) && defined(OSLANG_UTF8)  
         UINT16  ucs2[MAX_PATH];  
         codecnv_utf8toucs2(ucs2, NELEMENTS(ucs2), path, (UINT)-1);  
         hdl = FindFirstFile(ucs2, &w32fd);  
 #else  #else
         hdl = FindFirstFile(path, &w32fd);          TCHAR tcharpath[MAX_PATH];
           oemtotchar(tcharpath, NELEMENTS(tcharpath), path, (UINT)-1);
 #endif  #endif
           HANDLE hdl;
           WIN32_FIND_DATA w32fd;
           hdl = FindFirstFile(tcharpath, &w32fd);
         if (hdl != INVALID_HANDLE_VALUE) {          if (hdl != INVALID_HANDLE_VALUE) {
                 do {                  do {
                         if (setflist(&w32fd, fli) == SUCCESS) {                          if (setflist(&w32fd, fli) == SUCCESS) {
Line 329  FLISTH file_list1st(const OEMCHAR *dir,  Line 283  FLISTH file_list1st(const OEMCHAR *dir, 
         return(FLISTH_INVALID);          return(FLISTH_INVALID);
 }  }
   
 BOOL file_listnext(FLISTH hdl, FLINFO *fli) {  BRESULT file_listnext(FLISTH hdl, FLINFO *fli) {
   
         WIN32_FIND_DATA w32fd;          WIN32_FIND_DATA w32fd;
   
Line 349  void file_listclose(FLISTH hdl) { Line 303  void file_listclose(FLISTH hdl) {
   
 OEMCHAR *file_getname(const OEMCHAR *path) {  OEMCHAR *file_getname(const OEMCHAR *path) {
   
         int                     csize;  
 const OEMCHAR   *ret;  const OEMCHAR   *ret;
           int                     csize;
   
         ret = path;          ret = path;
         while((csize = milstr_charsize(path)) != 0) {          while((csize = milstr_charsize(path)) != 0) {
Line 373  void file_cutname(OEMCHAR *path) { Line 327  void file_cutname(OEMCHAR *path) {
   
 OEMCHAR *file_getext(const OEMCHAR *path) {  OEMCHAR *file_getext(const OEMCHAR *path) {
   
         OEMCHAR *p;  const OEMCHAR   *p;
         OEMCHAR *q;  const OEMCHAR   *q;
         int             csize;          int                     csize;
   
         p = file_getname(path);          p = file_getname(path);
         q = NULL;          q = NULL;
Line 385  OEMCHAR *file_getext(const OEMCHAR *path Line 339  OEMCHAR *file_getext(const OEMCHAR *path
                 }                  }
                 p += csize;                  p += csize;
         }          }
         if (!q) {          if (q == NULL) {
                 q = p;                  q = p;
         }          }
         return((OEMCHAR *)q);          return((OEMCHAR *)q);

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


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