diff options
author | wrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68> | 2002-01-28 15:56:08 +0000 |
---|---|---|
committer | wrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68> | 2002-01-28 15:56:08 +0000 |
commit | a577de0569e027dbfba6c9eafaaca3a759855020 (patch) | |
tree | c5a1e5b740f156a02ed930c512fafbf23e31789d /file_io | |
parent | 8ba2665ec4a2b9f0ebca405dc2afb701a0ebd37c (diff) | |
download | libapr-a577de0569e027dbfba6c9eafaaca3a759855020.tar.gz |
Mladen Turk's <mturk@mappingsoft.com> WinCE port.
Nearly, the apr.hw patch needs some review. In short, several quite
standard ansi headers (e.g. time.h) aren't present in the WinCT port,
but these changes require corresponding changes to apr.h.in.
I changed Mladen's #define'd symbol names for the macro blocks to
IF_WIN_OS_IS_UNICODE and ELSE_WIN_OS_IS_ANSI to make the code a bit more
readable, and drop the global apr_os_level from each macro invocation.
Also, I changed the scope of his APR_HAS_ANSI_FS to local scope, since
it has no application in the public headers.
Mladen's patch helps NT as well, allowing the /D WINNT flag to define
NT-only compilations. With WINNT defined, all UNICODE/ANSI os version
tests drop out entirely.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@62837 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'file_io')
-rw-r--r-- | file_io/win32/dir.c | 37 | ||||
-rw-r--r-- | file_io/win32/filestat.c | 10 | ||||
-rw-r--r-- | file_io/win32/filesys.c | 24 | ||||
-rw-r--r-- | file_io/win32/open.c | 27 |
4 files changed, 66 insertions, 32 deletions
diff --git a/file_io/win32/dir.c b/file_io/win32/dir.c index 0c6a21752..96484b574 100644 --- a/file_io/win32/dir.c +++ b/file_io/win32/dir.c @@ -100,15 +100,16 @@ APR_DECLARE(apr_status_t) apr_dir_open(apr_dir_t **new, const char *dirname, (*new)->dirname[len] = '\0'; #if APR_HAS_UNICODE_FS - if (apr_os_level >= APR_WIN_NT) + IF_WIN_OS_IS_UNICODE { /* Create a buffer for the longest file name we will ever see */ (*new)->w.entry = apr_pcalloc(cont, sizeof(WIN32_FIND_DATAW)); (*new)->name = apr_pcalloc(cont, APR_FILE_MAX * 3 + 1); } - else #endif +#if APR_HAS_ANSI_FS + ELSE_WIN_OS_IS_ANSI { /* Note that we won't open a directory that is greater than MAX_PATH, * including the trailing /* wildcard suffix. If a * won't fit, then @@ -122,6 +123,7 @@ APR_DECLARE(apr_status_t) apr_dir_open(apr_dir_t **new, const char *dirname, } (*new)->n.entry = apr_pcalloc(cont, sizeof(WIN32_FIND_DATAW)); } +#endif (*new)->rootlen = len - 1; (*new)->cntxt = cont; (*new)->dirhand = INVALID_HANDLE_VALUE; @@ -147,7 +149,7 @@ APR_DECLARE(apr_status_t) apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, #if APR_HAS_UNICODE_FS apr_wchar_t wdirname[APR_PATH_MAX]; apr_wchar_t *eos = NULL; - if (apr_os_level >= APR_WIN_NT) + IF_WIN_OS_IS_UNICODE { if (thedir->dirhand == INVALID_HANDLE_VALUE) { @@ -181,8 +183,9 @@ APR_DECLARE(apr_status_t) apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, return rv; fname = thedir->name; } - else #endif +#if APR_HAS_ANSI_FS + ELSE_WIN_OS_IS_ANSI { char *eop = strchr(thedir->dirname, '\0'); if (thedir->dirhand == INVALID_HANDLE_VALUE) { @@ -208,6 +211,7 @@ APR_DECLARE(apr_status_t) apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, } fname = thedir->n.entry->cFileName; } +#endif fillin_fileinfo(finfo, (WIN32_FILE_ATTRIBUTE_DATA *) thedir->w.entry, 0, wanted); @@ -220,7 +224,8 @@ APR_DECLARE(apr_status_t) apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, /* Go back and get more_info if we can't answer the whole inquiry */ #if APR_HAS_UNICODE_FS - if (apr_os_level >= APR_WIN_NT) { + IF_WIN_OS_IS_UNICODE + { /* Almost all our work is done. Tack on the wide file name * to the end of the wdirname (already / delimited) */ @@ -231,13 +236,16 @@ APR_DECLARE(apr_status_t) apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, eos[0] = '\0'; return rv; } - else { +#endif +#if APR_HAS_ANSI_FS + ELSE_WIN_OS_IS_ANSI + { +#if APR_HAS_UNICODE_FS /* Don't waste stack space on a second buffer, the one we set * aside for the wide directory name is twice what we need. */ char *fspec = (char*)wdirname; -#else /* !APR_HAS_UNICODE_FS */ - { +#else char fspec[APR_PATH_MAX]; #endif int dirlen = strlen(thedir->dirname); @@ -247,6 +255,7 @@ APR_DECLARE(apr_status_t) apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, apr_cpystrn(fspec + dirlen, fname, sizeof(fspec) - dirlen); return more_finfo(finfo, fspec, wanted, MORE_OF_FSPEC); } +#endif } return APR_SUCCESS; @@ -264,7 +273,7 @@ APR_DECLARE(apr_status_t) apr_dir_make(const char *path, apr_fileperms_t perm, apr_pool_t *cont) { #if APR_HAS_UNICODE_FS - if (apr_os_level >= APR_WIN_NT) + IF_WIN_OS_IS_UNICODE { apr_wchar_t wpath[APR_PATH_MAX]; apr_status_t rv; @@ -276,18 +285,20 @@ APR_DECLARE(apr_status_t) apr_dir_make(const char *path, apr_fileperms_t perm, return apr_get_os_error(); } } - else #endif +#if APR_HAS_ANSI_FS + ELSE_WIN_OS_IS_ANSI if (!CreateDirectory(path, NULL)) { return apr_get_os_error(); } +#endif return APR_SUCCESS; } APR_DECLARE(apr_status_t) apr_dir_remove(const char *path, apr_pool_t *cont) { #if APR_HAS_UNICODE_FS - if (apr_os_level >= APR_WIN_NT) + IF_WIN_OS_IS_UNICODE { apr_wchar_t wpath[APR_PATH_MAX]; apr_status_t rv; @@ -299,11 +310,13 @@ APR_DECLARE(apr_status_t) apr_dir_remove(const char *path, apr_pool_t *cont) return apr_get_os_error(); } } - else #endif +#if APR_HAS_ANSI_FS + ELSE_WIN_OS_IS_ANSI if (!RemoveDirectory(path)) { return apr_get_os_error(); } +#endif return APR_SUCCESS; } diff --git a/file_io/win32/filestat.c b/file_io/win32/filestat.c index 8952f79d0..0f2fe43e4 100644 --- a/file_io/win32/filestat.c +++ b/file_io/win32/filestat.c @@ -476,7 +476,8 @@ APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, } #if APR_HAS_UNICODE_FS - if (apr_os_level >= APR_WIN_NT) { + IF_WIN_OS_IS_UNICODE + { if (rv = utf8_to_unicode_path(wfname, sizeof(wfname) / sizeof(apr_wchar_t), fname)) return rv; @@ -505,8 +506,9 @@ APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, filename = apr_pstrdup(cont, tmpname); } } - else #endif +#if APR_HAS_ANSI_FS + ELSE_WIN_OS_IS_ANSI if ((apr_os_level >= APR_WIN_98) && (!(wanted & APR_FINFO_NAME) || isroot)) { /* cannot use FindFile on a Win98 root, it returns \* @@ -550,6 +552,7 @@ APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, FindClose(hFind); filename = apr_pstrdup(cont, FileInfo.n.cFileName); } +#endif if (ident_rv != APR_INCOMPLETE) { if (fillin_fileinfo(finfo, (WIN32_FILE_ATTRIBUTE_DATA *) &FileInfo, @@ -559,7 +562,8 @@ APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, * to reliably translate char devices to the path '\\.\device' * so go ask for the full path. */ - if (apr_os_level >= APR_WIN_NT) { + IF_WIN_OS_IS_UNICODE + { #if APR_HAS_UNICODE_FS apr_wchar_t tmpname[APR_FILE_MAX]; apr_wchar_t *tmpoff; diff --git a/file_io/win32/filesys.c b/file_io/win32/filesys.c index 09e1f9a72..9158472c7 100644 --- a/file_io/win32/filesys.c +++ b/file_io/win32/filesys.c @@ -120,7 +120,7 @@ apr_status_t filepath_drive_get(char **rootpath, char drive, { char path[APR_PATH_MAX]; #if APR_HAS_UNICODE_FS - if (apr_os_level >= APR_WIN_NT) + IF_WIN_OS_IS_UNICODE { apr_wchar_t *ignored; apr_wchar_t wdrive[8]; @@ -136,8 +136,9 @@ apr_status_t filepath_drive_get(char **rootpath, char drive, if ((rv = unicode_to_utf8_path(path, sizeof(path), wpath))) return rv; } - else #endif +#if APR_HAS_ANSI_FS + ELSE_WIN_OS_IS_ANSI { char *ignored; char drivestr[4]; @@ -148,6 +149,7 @@ apr_status_t filepath_drive_get(char **rootpath, char drive, if (!GetFullPathName(drivestr, sizeof(path), path, &ignored)) return apr_get_os_error(); } +#endif if (!(flags & APR_FILEPATH_NATIVE)) { for (*rootpath = path; **rootpath; ++*rootpath) { if (**rootpath == '\\') @@ -162,7 +164,7 @@ apr_status_t filepath_drive_get(char **rootpath, char drive, apr_status_t filepath_root_case(char **rootpath, char *root, apr_pool_t *p) { #if APR_HAS_UNICODE_FS - if (apr_os_level >= APR_WIN_NT) + IF_WIN_OS_IS_UNICODE { apr_wchar_t *ignored; apr_wchar_t wpath[APR_PATH_MAX]; @@ -183,8 +185,9 @@ apr_status_t filepath_root_case(char **rootpath, char *root, apr_pool_t *p) return rv; *rootpath = apr_pstrdup(p, (char*)wroot); } - else #endif +#if APR_HAS_ANSI_FS + ELSE_WIN_OS_IS_ANSI { char path[APR_PATH_MAX]; char *ignored; @@ -192,6 +195,7 @@ apr_status_t filepath_root_case(char **rootpath, char *root, apr_pool_t *p) return apr_get_os_error(); *rootpath = apr_pstrdup(p, path); } +#endif return APR_SUCCESS; } @@ -201,7 +205,7 @@ APR_DECLARE(apr_status_t) apr_filepath_get(char **rootpath, apr_int32_t flags, { char path[APR_PATH_MAX]; #if APR_HAS_UNICODE_FS - if (apr_os_level >= APR_WIN_NT) + IF_WIN_OS_IS_UNICODE { apr_wchar_t wpath[APR_PATH_MAX]; apr_status_t rv; @@ -210,12 +214,14 @@ APR_DECLARE(apr_status_t) apr_filepath_get(char **rootpath, apr_int32_t flags, if ((rv = unicode_to_utf8_path(path, sizeof(path), wpath))) return rv; } - else #endif +#if APR_HAS_ANSI_FS + ELSE_WIN_OS_IS_ANSI { if (!GetCurrentDirectory(sizeof(path), path)) return apr_get_os_error(); } +#endif if (!(flags & APR_FILEPATH_NATIVE)) { for (*rootpath = path; **rootpath; ++*rootpath) { if (**rootpath == '\\') @@ -231,7 +237,7 @@ APR_DECLARE(apr_status_t) apr_filepath_set(const char *rootpath, apr_pool_t *p) { #if APR_HAS_UNICODE_FS - if (apr_os_level >= APR_WIN_NT) + IF_WIN_OS_IS_UNICODE { apr_wchar_t wpath[APR_PATH_MAX]; apr_status_t rv; @@ -241,11 +247,13 @@ APR_DECLARE(apr_status_t) apr_filepath_set(const char *rootpath, if (!SetCurrentDirectoryW(wpath)) return apr_get_os_error(); } - else #endif +#if APR_HAS_ANSI_FS + ELSE_WIN_OS_IS_ANSI { if (!SetCurrentDirectory(rootpath)) return apr_get_os_error(); } +#endif return APR_SUCCESS; } diff --git a/file_io/win32/open.c b/file_io/win32/open.c index cbc57950a..af821c17c 100644 --- a/file_io/win32/open.c +++ b/file_io/win32/open.c @@ -168,7 +168,8 @@ apr_status_t unicode_to_utf8_path(char* retstr, apr_size_t retlen, void *res_name_from_filename(const char *file, int global, apr_pool_t *pool) { #if APR_HAS_UNICODE_FS - if (apr_os_level >= APR_WIN_NT) { + IF_WIN_OS_IS_UNICODE + { apr_wchar_t *wpre, *wfile, *ch; apr_size_t n = strlen(file) + 1; apr_size_t r, d; @@ -205,8 +206,9 @@ void *res_name_from_filename(const char *file, int global, apr_pool_t *pool) } return wfile; } - else #endif +#if APR_HAS_ANSI_FS + ELSE_WIN_OS_IS_ANSI { char *nfile, *ch; apr_size_t n = strlen(file) + 1; @@ -247,6 +249,7 @@ void *res_name_from_filename(const char *file, int global, apr_pool_t *pool) } return nfile; } +#endif } @@ -333,7 +336,8 @@ APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, const char *fname, } #if APR_HAS_UNICODE_FS - if (apr_os_level >= APR_WIN_NT) { + IF_WIN_OS_IS_UNICODE + { apr_wchar_t wfname[APR_PATH_MAX]; if (rv = utf8_to_unicode_path(wfname, sizeof(wfname) / sizeof(apr_wchar_t), fname)) @@ -341,11 +345,12 @@ APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, const char *fname, handle = CreateFileW(wfname, oflags, sharemode, NULL, createflags, attributes, 0); } - else #endif +#if APR_HAS_ANSI_FS + ELSE_WIN_OS_IS_ANSI handle = CreateFileA(fname, oflags, sharemode, NULL, createflags, attributes, 0); - +#endif if (handle == INVALID_HANDLE_VALUE) { return apr_get_os_error(); } @@ -424,7 +429,7 @@ APR_DECLARE(apr_status_t) apr_file_close(apr_file_t *file) APR_DECLARE(apr_status_t) apr_file_remove(const char *path, apr_pool_t *cont) { #if APR_HAS_UNICODE_FS - if (apr_os_level >= APR_WIN_NT) + IF_WIN_OS_IS_UNICODE { apr_wchar_t wpath[APR_PATH_MAX]; apr_status_t rv; @@ -435,10 +440,12 @@ APR_DECLARE(apr_status_t) apr_file_remove(const char *path, apr_pool_t *cont) if (DeleteFileW(wpath)) return APR_SUCCESS; } - else #endif +#if APR_HAS_ANSI_FS + ELSE_WIN_OS_IS_ANSI if (DeleteFile(path)) return APR_SUCCESS; +#endif return apr_get_os_error(); } @@ -446,7 +453,7 @@ APR_DECLARE(apr_status_t) apr_file_rename(const char *frompath, const char *topath, apr_pool_t *cont) { - if (apr_os_level >= APR_WIN_NT) + IF_WIN_OS_IS_UNICODE { #if APR_HAS_UNICODE_FS apr_wchar_t wfrompath[APR_PATH_MAX], wtopath[APR_PATH_MAX]; @@ -468,7 +475,8 @@ APR_DECLARE(apr_status_t) apr_file_rename(const char *frompath, return APR_SUCCESS; #endif } - else +#if APR_HAS_ANSI_FS + ELSE_WIN_OS_IS_ANSI { /* Windows 95 and 98 do not support MoveFileEx, so we'll use * the old MoveFile function. However, MoveFile requires that @@ -488,6 +496,7 @@ APR_DECLARE(apr_status_t) apr_file_rename(const char *frompath, if (MoveFile(frompath, topath)) return APR_SUCCESS; } +#endif return apr_get_os_error(); } |