/* 7zFile.c -- File IO\r
-2008-11-22 : Igor Pavlov : Public domain */\r
+2009-11-24 : Igor Pavlov : Public domain */\r
+\r
+#include "Precomp.h"\r
\r
#include "7zFile.h"\r
\r
#ifndef USE_WINDOWS_FILE\r
\r
+#ifndef UNDER_CE\r
#include <errno.h>\r
-\r
#endif\r
\r
-#ifdef USE_WINDOWS_FILE\r
+#else\r
\r
/*\r
ReadFile and WriteFile functions in Windows have BUG:\r
#endif\r
}\r
\r
+#if !defined(UNDER_CE) || !defined(USE_WINDOWS_FILE)\r
static WRes File_Open(CSzFile *p, const char *name, int writeMode)\r
{\r
#ifdef USE_WINDOWS_FILE\r
return (p->handle != INVALID_HANDLE_VALUE) ? 0 : GetLastError();\r
#else\r
p->file = fopen(name, writeMode ? "wb+" : "rb");\r
- return (p->file != 0) ? 0 : errno;\r
+ return (p->file != 0) ? 0 :\r
+ #ifdef UNDER_CE\r
+ 2; /* ENOENT */\r
+ #else\r
+ errno;\r
+ #endif\r
#endif\r
}\r
\r
WRes InFile_Open(CSzFile *p, const char *name) { return File_Open(p, name, 0); }\r
WRes OutFile_Open(CSzFile *p, const char *name) { return File_Open(p, name, 1); }\r
+#endif\r
+\r
+#ifdef USE_WINDOWS_FILE\r
+static WRes File_OpenW(CSzFile *p, const WCHAR *name, int writeMode)\r
+{\r
+ p->handle = CreateFileW(name,\r
+ writeMode ? GENERIC_WRITE : GENERIC_READ,\r
+ FILE_SHARE_READ, NULL,\r
+ writeMode ? CREATE_ALWAYS : OPEN_EXISTING,\r
+ FILE_ATTRIBUTE_NORMAL, NULL);\r
+ return (p->handle != INVALID_HANDLE_VALUE) ? 0 : GetLastError();\r
+}\r
+WRes InFile_OpenW(CSzFile *p, const WCHAR *name) { return File_OpenW(p, name, 0); }\r
+WRes OutFile_OpenW(CSzFile *p, const WCHAR *name) { return File_OpenW(p, name, 1); }\r
+#endif\r
\r
WRes File_Close(CSzFile *p)\r
{\r