wrowe 01/01/20 13:39:05
Modified: dso/win32 dso.c
file_io/os2 filestat.c seek.c
file_io/unix fileacc.c filestat.c seek.c
file_io/win32 dir.c filedup.c filestat.c open.c pipe.c
seek.c
include/arch/unix fileio.h
include/arch/win32 fileio.h
test testmmap.c
Log:
The platform changes in apr to support the APR_FINFO_wanted declaration
changes for apr_stat/lstat/getfileinfo. Much, much work to do here,
but this gets us started.
Revision Changes Path
1.18 +6 -4 apr/dso/win32/dso.c
Index: dso.c
===================================================================
RCS file: /home/cvs/apr/dso/win32/dso.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- dso.c 2001/01/19 09:56:32 1.17
+++ dso.c 2001/01/20 21:39:02 1.18
@@ -81,10 +81,12 @@
apr_oslevel_e os_level;
if (!apr_get_oslevel(ctx, &os_level) && os_level >= APR_WIN_NT)
{
- apr_wchar_t *wpath = utf8_to_unicode_path(path, ctx);
- if (!wpath)
- return APR_ENAMETOOLONG;
-
+ apr_wchar_t wpath[8192];
+ apr_status_t rv;
+ if (rv = utf8_to_unicode_path(wpath, sizeof(wpath)
+ / sizeof(apr_wchar_t), path)) {
+ return rv;
+ }
/* Prevent ugly popups from killing our app */
em = SetErrorMode(SEM_FAILCRITICALERRORS);
os_handle = LoadLibraryExW(wpath, NULL,
LOAD_WITH_ALTERED_SEARCH_PATH);
1.16 +13 -4 apr/file_io/os2/filestat.c
Index: filestat.c
===================================================================
RCS file: /home/cvs/apr/file_io/os2/filestat.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- filestat.c 2000/11/14 06:40:03 1.15
+++ filestat.c 2001/01/20 21:39:02 1.16
@@ -113,7 +113,8 @@
-apr_status_t apr_getfileinfo(apr_finfo_t *finfo, apr_file_t *thefile)
+apr_status_t apr_getfileinfo(apr_finfo_t *finfo, apr_int32_t wanted,
+ apr_file_t *thefile)
{
ULONG rc;
FILESTATUS3 fstatus;
@@ -125,6 +126,8 @@
if (rc == 0) {
FS3_to_finfo(finfo, &fstatus);
+ /* XXX: This is wrong, but it will work for today */
+ finfo->valid = APR_FINFO_NORM;
if (finfo->filetype == APR_REG) {
if (thefile->isopen) {
@@ -146,7 +149,8 @@
}
-apr_status_t apr_stat(apr_finfo_t *finfo, const char *fname, apr_pool_t
*cont)
+apr_status_t apr_stat(apr_finfo_t *finfo, const char *fname,
+ apr_int32_wanted, apr_pool_t *cont)
{
ULONG rc;
FILESTATUS3 fstatus;
@@ -156,9 +160,13 @@
rc = DosQueryPathInfo(fname, FIL_STANDARD, &fstatus, sizeof(fstatus));
if (rc == 0) {
+ /* XXX: This is wrong, but it will work for today */
+ finfo->valid = APR_FINFO_NORM;
FS3_to_finfo(finfo, &fstatus);
return APR_SUCCESS;
} else if (rc == ERROR_INVALID_ACCESS) {
+ /* XXX: This is wrong, but it will work for today */
+ finfo->valid = APR_FINFO_NORM;
memset(finfo, 0, sizeof(apr_finfo_t));
finfo->protection = 0444;
finfo->filetype = APR_CHR;
@@ -170,7 +178,8 @@
-apr_status_t apr_lstat(apr_finfo_t *finfo, const char *fname, apr_pool_t
*cont)
+apr_status_t apr_lstat(apr_finfo_t *finfo, const char *fname,
+ apr_int32_wanted, apr_pool_t *cont)
{
- return apr_stat(finfo, fname, cont);
+ return apr_stat(finfo, fname, wanted, cont);
}
1.12 +1 -1 apr/file_io/os2/seek.c
Index: seek.c
===================================================================
RCS file: /home/cvs/apr/file_io/os2/seek.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- seek.c 2000/11/14 06:40:03 1.11
+++ seek.c 2001/01/20 21:39:02 1.12
@@ -109,7 +109,7 @@
break;
case APR_END:
- rc = apr_getfileinfo(&finfo, thefile);
+ rc = apr_getfileinfo(&finfo, APR_FINFO_NORM, thefile);
if (rc == APR_SUCCESS)
rc = setptr(thefile, finfo.size - *offset);
break;
1.46 +0 -15 apr/file_io/unix/fileacc.c
Index: fileacc.c
===================================================================
RCS file: /home/cvs/apr/file_io/unix/fileacc.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- fileacc.c 2001/01/18 20:07:14 1.45
+++ fileacc.c 2001/01/20 21:39:03 1.46
@@ -60,22 +60,7 @@
APR_DECLARE(apr_status_t) apr_get_filename(const char **fname,
apr_file_t *thefile)
{
-#ifdef WIN32 /* this test is only good until some other platform trys wchar*
*/
-#if APR_HAS_UNICODE_FS
- apr_oslevel_e os_level;
- if (!apr_get_oslevel(thefile->cntxt, &os_level) && os_level >=
APR_WIN_NT)
- {
- *fname = unicode_to_utf8_path(thefile->w.fname, thefile->cntxt);
- if (!*fname)
- return APR_ENAMETOOLONG;
- }
- else
-#endif /* !APR_HAS_UNICODE_FS */
- *fname = thefile->n.fname;
-
-#else /* !def Win32 */
*fname = thefile->fname;
-#endif
return APR_SUCCESS;
}
1.34 +52 -21 apr/file_io/unix/filestat.c
Index: filestat.c
===================================================================
RCS file: /home/cvs/apr/file_io/unix/filestat.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- filestat.c 2000/11/14 06:40:03 1.33
+++ filestat.c 2001/01/20 21:39:03 1.34
@@ -55,6 +55,7 @@
#include "fileio.h"
#include "apr_file_io.h"
#include "apr_general.h"
+#include "apr_strings.h"
#include "apr_errno.h"
static apr_filetype_e filetype_from_mode(int mode)
@@ -80,11 +81,14 @@
return type;
}
-apr_status_t apr_getfileinfo(apr_finfo_t *finfo, apr_file_t *thefile)
+apr_status_t apr_getfileinfo(apr_finfo_t *finfo, apr_int32_t wanted,
+ apr_file_t *thefile)
{
struct stat info;
if (fstat(thefile->filedes, &info) == 0) {
+ finfo->cntxt = thefile->cntxt;
+ finfo->valid = APR_FINFO_MIN| APR_FINFO_IDENT | APR_FINFO_OWNER |
APR_FINFO_PROT;
finfo->protection = apr_unix_mode2perms(info.st_mode);
finfo->filetype = filetype_from_mode(info.st_mode);
finfo->user = info.st_uid;
@@ -92,9 +96,18 @@
finfo->size = info.st_size;
finfo->inode = info.st_ino;
finfo->device = info.st_dev;
+ finfo->nlinks = info.st_nlink;
apr_ansi_time_to_apr_time(&finfo->atime, info.st_atime);
apr_ansi_time_to_apr_time(&finfo->mtime, info.st_mtime);
apr_ansi_time_to_apr_time(&finfo->ctime, info.st_ctime);
+ finfo->filepath = thefile->fname;
+ if (wanted & APR_FINFO_CSIZE) {
+ finfo->csize = info.st_blocks * 512;
+ finfo->valid |= APR_FINFO_CSIZE;
+ }
+ if (finfo->filetype = APR_LNK)
+ finfo->valid |= APR_FINFO_LINK
+ }
return APR_SUCCESS;
}
else {
@@ -111,11 +124,20 @@
return APR_SUCCESS;
}
-apr_status_t apr_stat(apr_finfo_t *finfo, const char *fname, apr_pool_t
*cont)
+apr_status_t apr_stat(apr_finfo_t *finfo, const char *fname,
+ apr_int32_t wanted, apr_pool_t *cont)
{
struct stat info;
+ int srv;
- if (stat(fname, &info) == 0) {
+ if (wanted & APR_FINFO_LINK)
+ srv = lstat(fname, &info);
+ else
+ srv = stat(fname,info);
+
+ if (srv == 0) {
+ finfo->cntxt = cont;
+ finfo->valid = APR_FINFO_MIN| APR_FINFO_IDENT | APR_FINFO_OWNER |
APR_FINFO_PROT;
finfo->protection = apr_unix_mode2perms(info.st_mode);
finfo->filetype = filetype_from_mode(info.st_mode);
finfo->user = info.st_uid;
@@ -123,9 +145,18 @@
finfo->size = info.st_size;
finfo->inode = info.st_ino;
finfo->device = info.st_dev;
+ finfo->nlinks = info.st_nlink;
apr_ansi_time_to_apr_time(&finfo->atime, info.st_atime);
apr_ansi_time_to_apr_time(&finfo->mtime, info.st_mtime);
apr_ansi_time_to_apr_time(&finfo->ctime, info.st_ctime);
+ finfo->filepath = fname;
+ if (wanted & APR_FINFO_CSIZE) {
+ finfo->csize = info.st_blocks * 512;
+ finfo->valid |= APR_FINFO_CSIZE;
+ }
+ if (finfo->filetype = APR_LNK)
+ finfo->valid |= APR_FINFO_LINK
+ }
return APR_SUCCESS;
}
else {
@@ -163,24 +194,24 @@
}
}
-apr_status_t apr_lstat(apr_finfo_t *finfo, const char *fname, apr_pool_t
*cont)
+/* Perhaps this becomes nothing but a macro?
+ */
+apr_status_t apr_lstat(apr_finfo_t *finfo, const char *fname,
+ apr_int32_t wanted, apr_pool_t *cont)
{
- struct stat info;
+ return apr_stat(finfo, fname, wanted | APR_FINFO_LINK, cont);
+}
- if (lstat(fname, &info) == 0) {
- finfo->protection = apr_unix_mode2perms(info.st_mode);
- finfo->filetype = filetype_from_mode(info.st_mode);
- finfo->user = info.st_uid;
- finfo->group = info.st_gid;
- finfo->size = info.st_size;
- finfo->inode = info.st_ino;
- finfo->device = info.st_dev;
- apr_ansi_time_to_apr_time(&finfo->atime, info.st_atime);
- apr_ansi_time_to_apr_time(&finfo->mtime, info.st_mtime);
- apr_ansi_time_to_apr_time(&finfo->ctime, info.st_ctime);
- return APR_SUCCESS;
- }
- else {
- return errno;
- }
+/* XXX: This is wrong for case-insensitive, case-preserving mount points.
+ * Unfortuantely, I don't have a clue about tweaking this code for unix,
+ * other than the basic stratagy of stat, then walk dirread for dev/inode.
+ */
+APR_DECLARE(apr_status_t) apr_get_filename_case(char **fname,
+ const char *fspec,
+ apr_pool_t *cont)
+{
+ *fname = strrchr(fspec, '/');
+ if (!*fname)
+ *fname = fspec;
+ return APR_SUCCESS;
}
1.18 +1 -1 apr/file_io/unix/seek.c
Index: seek.c
===================================================================
RCS file: /home/cvs/apr/file_io/unix/seek.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- seek.c 2000/11/14 06:40:03 1.17
+++ seek.c 2001/01/20 21:39:03 1.18
@@ -104,7 +104,7 @@
break;
case APR_END:
- rc = apr_getfileinfo(&finfo, thefile);
+ rc = apr_getfileinfo(&finfo, APR_FINFO_SIZE, thefile);
if (rc == APR_SUCCESS)
rc = setptr(thefile, finfo.size - *offset);
break;
1.43 +53 -82 apr/file_io/win32/dir.c
Index: dir.c
===================================================================
RCS file: /home/cvs/apr/file_io/win32/dir.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- dir.c 2001/01/18 20:07:15 1.42
+++ dir.c 2001/01/20 21:39:03 1.43
@@ -72,7 +72,7 @@
#include <sys/stat.h>
#endif
-apr_status_t dir_cleanup(void *thedir)
+static apr_status_t dir_cleanup(void *thedir)
{
apr_dir_t *dir = thedir;
if (dir->dirhand != INVALID_HANDLE_VALUE && !FindClose(dir->dirhand)) {
@@ -85,88 +85,43 @@
APR_DECLARE(apr_status_t) apr_dir_open(apr_dir_t **new, const char *dirname,
apr_pool_t *cont)
{
- /* 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
- * neither will any other file name within the directory.
- * The length not including the trailing '*' is stored as rootlen, to
- * skip over all paths which are too long.
- */
- int len = strlen(dirname);
#if APR_HAS_UNICODE_FS
apr_oslevel_e os_level;
+#endif
+ int len = strlen(dirname);
+ (*new) = apr_pcalloc(cont, sizeof(apr_dir_t));
+ (*new)->dirname = apr_palloc(cont, len + 3);
+ memcpy((*new)->dirname, dirname, len);
+ if (len && (*new)->dirname[len - 1] != '/') {
+ (*new)->dirname[len++] = '/';
+ }
+ (*new)->dirname[len++] = '*';
+ (*new)->dirname[len] = '\0';
+
+#if APR_HAS_UNICODE_FS
if (!apr_get_oslevel(cont, &os_level) && os_level >= APR_WIN_NT)
{
- /* While there is now a generic accessor to convert to Unicode,
- * we do something special here to provide a few extra wchars
- * for the /* (really \*) suffix
- *
- * Note that the \\?\ form only works for local drive paths, and
- * not for UNC paths.
+ /* Create a buffer for the longest file name we will ever see
*/
- int srcremains = len;
- int dirremains = len;
- apr_wchar_t *wch;
- (*new) = apr_pcalloc(cont, sizeof(apr_dir_t));
(*new)->w.entry = apr_pcalloc(cont, sizeof(WIN32_FIND_DATAW));
- if (dirname[1] == ':' && dirname[2] == '/') {
- (*new)->w.dirname = apr_palloc(cont, (dirremains + 7) * 2);
- wcscpy((*new)->w.dirname, L"\\\\?\\");
- wch = (*new)->w.dirname + 4;
- }
- else if (dirname[0] == '/' && dirname[1] == '/') {
- /* Skip the leading slashes */
- dirname += 2;
- srcremains = dirremains = (len -= 2);
- (*new)->w.dirname = apr_palloc(cont, (dirremains + 11) * 2);
- wcscpy ((*new)->w.dirname, L"\\\\?\\UNC\\");
- wch = (*new)->w.dirname + 8;
- }
- else
- wch = (*new)->w.dirname = apr_palloc(cont, (dirremains + 3) * 2);
-
- if (conv_utf8_to_ucs2(dirname, &srcremains,
- wch, &dirremains) || srcremains) {
- (*new) = NULL;
- return APR_ENAMETOOLONG;
- }
- len -= dirremains;
- if (len && wch[len - 1] != '/') {
- wch[len++] = L'/';
- }
- wch[len++] = L'*';
- wch[len] = L'\0';
- if (wch != (*new)->w.dirname)
- {
- if (len >= MAX_PATH ) {
- (*new) = NULL;
- return APR_ENAMETOOLONG;
- }
- (*new)->rootlen = len - 1;
- }
- else /* we don't care, since the path isn't limited in length */
- (*new)->rootlen = 0;
- for (; *wch; ++wch)
- if (*wch == L'/')
- *wch = L'\\';
+ (*new)->name = apr_pcalloc(cont, MAX_PATH * 3 + 1);
}
else
#endif
{
- (*new) = apr_pcalloc(cont, sizeof(apr_dir_t));
- (*new)->n.entry = apr_pcalloc(cont, sizeof(WIN32_FIND_DATA));
- (*new)->n.dirname = apr_palloc(cont, len + 3);
- memcpy((*new)->n.dirname, dirname, len);
- if (len && (*new)->n.dirname[len - 1] != '/') {
- (*new)->n.dirname[len++] = '/';
- }
- (*new)->n.dirname[len++] = '*';
- (*new)->n.dirname[len] = '\0';
- (*new)->rootlen = len - 1;
- if (len >= MAX_PATH ){
+ /* 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
+ * neither will any other file name within the directory.
+ * The length not including the trailing '*' is stored as rootlen, to
+ * skip over all paths which are too long.
+ */
+ if (len >= MAX_PATH) {
(*new) = NULL;
return APR_ENAMETOOLONG;
}
+ (*new)->n.entry = apr_pcalloc(cont, sizeof(WIN32_FIND_DATAW));
}
+ (*new)->rootlen = len - 1;
(*new)->cntxt = cont;
(*new)->dirhand = INVALID_HANDLE_VALUE;
apr_register_cleanup((*new)->cntxt, (void *)(*new), dir_cleanup,
@@ -192,8 +147,16 @@
apr_oslevel_e os_level;
if (!apr_get_oslevel(thedir->cntxt, &os_level) && os_level >= APR_WIN_NT)
{
- if (thedir->dirhand == INVALID_HANDLE_VALUE) {
- thedir->dirhand = FindFirstFileW(thedir->w.dirname,
thedir->w.entry);
+ if (thedir->dirhand == INVALID_HANDLE_VALUE)
+ {
+ apr_wchar_t wdirname[8192];
+ apr_status_t rv;
+ if (rv = utf8_to_unicode_path(wdirname, sizeof(wdirname)
+ / sizeof(apr_wchar_t),
+ thedir->dirname)) {
+ return rv;
+ }
+ thedir->dirhand = FindFirstFileW(wdirname, thedir->w.entry);
if (thedir->dirhand == INVALID_HANDLE_VALUE) {
return apr_get_os_error();
}
@@ -213,7 +176,8 @@
#endif
{
if (thedir->dirhand == INVALID_HANDLE_VALUE) {
- thedir->dirhand = FindFirstFile(thedir->n.dirname,
thedir->n.entry);
+ thedir->dirhand = FindFirstFileA(thedir->dirname,
+ thedir->n.entry);
if (thedir->dirhand == INVALID_HANDLE_VALUE) {
return apr_get_os_error();
}
@@ -249,9 +213,12 @@
apr_oslevel_e os_level;
if (!apr_get_oslevel(cont, &os_level) && os_level >= APR_WIN_NT)
{
- apr_wchar_t *wpath = utf8_to_unicode_path(path, cont);
- if (!wpath)
- return APR_ENAMETOOLONG;
+ apr_wchar_t wpath[8192];
+ apr_status_t rv;
+ if (rv = utf8_to_unicode_path(wpath, sizeof(wpath)
+ / sizeof(apr_wchar_t), path)) {
+ return rv;
+ }
if (!CreateDirectoryW(wpath, NULL)) {
return apr_get_os_error();
}
@@ -270,9 +237,12 @@
apr_oslevel_e os_level;
if (!apr_get_oslevel(cont, &os_level) && os_level >= APR_WIN_NT)
{
- apr_wchar_t *wpath = utf8_to_unicode_path(path, cont);
- if (!wpath)
- return APR_ENAMETOOLONG;
+ apr_wchar_t wpath[8192];
+ apr_status_t rv;
+ if (rv = utf8_to_unicode_path(wpath, sizeof(wpath)
+ / sizeof(apr_wchar_t), path)) {
+ return rv;
+ }
if (!RemoveDirectoryW(wpath)) {
return apr_get_os_error();
}
@@ -332,10 +302,11 @@
apr_oslevel_e os_level;
if (!apr_get_oslevel(thedir->cntxt, &os_level) && os_level >= APR_WIN_NT)
{
- (*new) = unicode_to_utf8_path(thedir->w.entry->cFileName,
- thedir->cntxt);
- if (!*new)
- return APR_ENAMETOOLONG;
+ apr_status_t rv;
+ if (rv = unicode_to_utf8_path(thedir->name, MAX_PATH * 3 + 1,
+ thedir->w.entry->cFileName))
+ return rv;
+ (*new) = thedir->name;
}
else
#endif
1.29 +1 -23 apr/file_io/win32/filedup.c
Index: filedup.c
===================================================================
RCS file: /home/cvs/apr/file_io/win32/filedup.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- filedup.c 2001/01/18 20:07:15 1.28
+++ filedup.c 2001/01/20 21:39:03 1.29
@@ -63,7 +63,6 @@
{
BOOLEAN isStdHandle = FALSE;
HANDLE hCurrentProcess = GetCurrentProcess();
- apr_oslevel_e os_level;
if ((*new_file) == NULL) {
if (p == NULL) {
@@ -105,29 +104,8 @@
}
(*new_file)->cntxt = old_file->cntxt;
-#if APR_HAS_UNICODE_FS
- if (!apr_get_oslevel(old_file->cntxt, &os_level) && os_level >=
APR_WIN_NT)
- {
- int len = wcslen(old_file->w.fname) + 1;
- (*new_file)->w.fname = apr_palloc(old_file->cntxt, len * 2);
- memcpy((*new_file)->w.fname, old_file->w.fname, len * 2);
- }
- else
-#endif
- (*new_file)->n.fname = apr_pstrdup(old_file->cntxt,
old_file->n.fname);
-
-/* (*new_file)->demonfname = apr_pstrdup(old_file->cntxt,
old_file->demonfname);
- * (*new_file)->lowerdemonfname = apr_pstrdup(old_file->cntxt,
old_file->lowerdemonfname);
- */
+ (*new_file)->fname = apr_pstrdup(old_file->cntxt, old_file->fname);
(*new_file)->append = old_file->append;
-/* (*new_file)->protection = old_file->protection;
- * (*new_file)->user = old_file->user;
- * (*new_file)->group = old_file->group;
- */
- (*new_file)->size = old_file->size;
- (*new_file)->atime = old_file->atime;
- (*new_file)->mtime = old_file->mtime;
- (*new_file)->ctime = old_file->ctime;
(*new_file)->buffered = FALSE;
if (!isStdHandle) {
1.38 +56 -84 apr/file_io/win32/filestat.c
Index: filestat.c
===================================================================
RCS file: /home/cvs/apr/file_io/win32/filestat.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- filestat.c 2001/01/18 20:07:15 1.37
+++ filestat.c 2001/01/20 21:39:03 1.38
@@ -56,6 +56,7 @@
#include "win32/fileio.h"
#include "apr_file_io.h"
#include "apr_general.h"
+#include "apr_strings.h"
#include "apr_errno.h"
#include "apr_time.h"
#include <sys/stat.h>
@@ -74,32 +75,8 @@
#define FILE_FLAG_OPEN_REPARSE_POINT 0x00200000
#endif
-BOOLEAN is_exe(const char* fname, apr_pool_t *cont) {
- /*
- * Sleeping code, see notes under apr_stat()
- */
- const char* exename;
- const char* ext;
- exename = strrchr(fname, '/');
- if (!exename) {
- exename = strrchr(fname, '\\');
- }
- if (!exename) {
- exename = fname;
- }
- else {
- exename++;
- }
- ext = strrchr(exename, '.');
- if (ext && (!strcasecmp(ext,".exe") || !strcasecmp(ext,".com") ||
- !strcasecmp(ext,".bat") || !strcasecmp(ext,".cmd"))) {
- return TRUE;
- }
- return FALSE;
-}
-
-APR_DECLARE(apr_status_t) apr_getfileinfo(apr_finfo_t *finfo,
+APR_DECLARE(apr_status_t) apr_getfileinfo(apr_finfo_t *finfo, apr_int32_t
wanted,
apr_file_t *thefile)
{
BY_HANDLE_FILE_INFORMATION FileInformation;
@@ -199,7 +176,7 @@
}
APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname,
- apr_pool_t *cont)
+ apr_int32_t wanted, apr_pool_t *cont)
{
apr_oslevel_e os_level;
/*
@@ -211,7 +188,7 @@
*/
if (!apr_get_oslevel(cont, &os_level) && os_level >= APR_WIN_NT)
{
- apr_file_t thefile;
+ apr_file_t *thefile = NULL;
apr_status_t rv;
/*
* NT5 (W2K) only supports symlinks in the same manner as mount
points.
@@ -221,22 +198,38 @@
* We must open the file with READ_CONTROL if we plan to retrieve the
* user, group or permissions.
*/
- thefile.cntxt = cont;
- thefile.w.fname = utf8_to_unicode_path(fname, cont);
- if (!thefile.w.fname)
- return APR_ENAMETOOLONG;
- thefile.filehand = CreateFileW(thefile.w.fname,
- 0 /* READ_CONTROL */,
- FILE_SHARE_READ | FILE_SHARE_WRITE
- | FILE_SHARE_DELETE, NULL,
- OPEN_EXISTING,
- FILE_FLAG_BACKUP_SEMANTICS
- | FILE_FLAG_OPEN_NO_RECALL, NULL);
- if (thefile.filehand == INVALID_HANDLE_VALUE)
- return apr_get_os_error();
- rv = apr_getfileinfo(finfo, &thefile);
- CloseHandle(thefile.filehand);
- return rv;
+
+ if (rv = apr_open(&thefile, fname,
+ ((wanted & APR_FINFO_LINK) ? APR_OPENLINK : 0)
+ | ((wanted & (APR_FINFO_PROT | APR_FINFO_OWNER))
+ ? APR_READCONTROL : 0), APR_OS_DEFAULT, cont))
+ {
+ /* We have a backup plan. Perhaps we couldn't grab READ_CONTROL?
+ * proceed with the alternate...
+ */
+ if (wanted & (APR_FINFO_PROT | APR_FINFO_OWNER)) {
+ rv = apr_open(&thefile, fname,
+ ((wanted & APR_FINFO_LINK) ? APR_OPENLINK : 0),
+ APR_OS_DEFAULT, cont);
+ wanted &= ~(APR_FINFO_PROT | APR_FINFO_OWNER);
+ }
+ if (rv)
+ return rv;
+ }
+
+ /*
+ * NT5 (W2K) only supports symlinks in the same manner as mount
points.
+ * This code should eventually take that into account, for now treat
+ * every reparse point as a symlink...
+ *
+ * We must open the file with READ_CONTROL if we plan to retrieve the
+ * user, group or permissions.
+ */
+ rv = apr_getfileinfo(finfo, wanted, thefile);
+ finfo->cntxt = thefile->cntxt;
+ finfo->fname = thefile->fname;
+ finfo->filehand = thefile;
+ return (rv);
}
else
{
@@ -298,7 +291,7 @@
finfo->protection |= S_IREAD | S_IWRITE | S_IEXEC;
}
- /* Is this an executable? Guess based on the file extension.
+ /* Is this an executable? Guess based on the file extension?
* This is a rather silly test, IMHO... we are looking to test
* if the user 'may' execute a file (permissions),
* not if the filetype is executable.
@@ -308,10 +301,6 @@
* types (invoking without an extension.) Perhaps a registry
* key test is even appropriate here.
*/
- /* if (is_exe(fname, cont)) {
- * finfo->protection |= S_IEXEC;
- * }
- */
/* File times */
FileTimeToAprTime(&finfo->atime, &FileInformation.ftLastAccessTime);
@@ -328,44 +317,27 @@
}
APR_DECLARE(apr_status_t) apr_lstat(apr_finfo_t *finfo, const char *fname,
- apr_pool_t *cont)
+ apr_int32_t wanted, apr_pool_t *cont)
{
+ return apr_stat(finfo, fname, wanted & APR_FINFO_LINK, cont);
+}
+
+#if 0
apr_oslevel_e os_level;
- if (apr_get_oslevel(cont, &os_level) || os_level < APR_WIN_2000)
- {
- /* Windows 9x doesn't support links whatsoever, and NT 4.0
- * only supports hard links. Just fall through
- */
- return apr_stat(finfo, fname, cont);
- }
- else
+ if (!apr_get_oslevel(cont, &os_level) && os_level >= APR_WIN_NT)
{
- apr_file_t thefile;
- apr_status_t rv;
- /*
- * NT5 (W2K) only supports symlinks in the same manner as mount
points.
- * This code should eventually take that into account, for now treat
- * every reparse point as a symlink...
- *
- * We must open the file with READ_CONTROL if we plan to retrieve the
- * user, group or permissions.
- */
- thefile.cntxt = cont;
- thefile.w.fname = utf8_to_unicode_path(fname, cont);
- if (!thefile.w.fname)
+ WIN32_FIND_DATAW FileInformation;
+ HANDLE hFind;
+ apr_wchar_t *wname;
+ if (strchr(fspec, '*') || strchr(fspec, '?'))
+ return APR_ENOENT;
+ wname = utf8_to_unicode_path(fspec, cont);
+ if (!wname)
return APR_ENAMETOOLONG;
- thefile.filehand = CreateFileW(thefile.w.fname,
- 0 /* READ_CONTROL */,
- FILE_SHARE_READ | FILE_SHARE_WRITE
- | FILE_SHARE_DELETE, NULL,
- OPEN_EXISTING,
- FILE_FLAG_OPEN_REPARSE_POINT
- | FILE_FLAG_BACKUP_SEMANTICS
- | FILE_FLAG_OPEN_NO_RECALL, NULL);
- if (thefile.filehand == INVALID_HANDLE_VALUE)
+ hFind = FindFirstFileW(wname, &FileInformation);
+ if (hFind == INVALID_HANDLE_VALUE)
return apr_get_os_error();
- rv = apr_getfileinfo(finfo, &thefile);
- CloseHandle(thefile.filehand);
- return rv;
- }
-}
+ else
+ FindClose(hFind);
+ *fname = unicode_to_utf8_path(FileInformation.cFileName, cont);
+#endif
\ No newline at end of file
1.62 +120 -93 apr/file_io/win32/open.c
Index: open.c
===================================================================
RCS file: /home/cvs/apr/file_io/win32/open.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -r1.61 -r1.62
--- open.c 2001/01/18 20:07:15 1.61
+++ open.c 2001/01/20 21:39:03 1.62
@@ -65,7 +65,8 @@
#include "misc.h"
#if APR_HAS_UNICODE_FS
-apr_wchar_t *utf8_to_unicode_path(const char* srcstr, apr_pool_t *p)
+apr_status_t utf8_to_unicode_path(apr_wchar_t* retstr, apr_size_t retlen,
+ const char* srcstr)
{
/* TODO: The computations could preconvert the string to determine
* the true size of the retstr, but that's a memory over speed
@@ -81,84 +82,84 @@
*/
int srcremains = strlen(srcstr) + 1;
int retremains = srcremains;
- apr_wchar_t *retstr, *t;
+ apr_wchar_t *t = retstr;
+ apr_status_t rv;
if (srcstr[1] == ':' && srcstr[2] == '/') {
- retstr = apr_palloc(p, (retremains + 4) * 2);
wcscpy (retstr, L"\\\\?\\");
- t = retstr + 4;
+ retlen -= 4;
+ t += 4;
}
else if (srcstr[0] == '/' && srcstr[1] == '/') {
/* Skip the slashes */
srcstr += 2;
- retremains = (srcremains -= 2);
- retstr = apr_palloc(p, (retremains + 8) * 2);
wcscpy (retstr, L"\\\\?\\UNC\\");
- t = retstr + 8;
+ retlen -= 8;
+ t += 8;
}
- else
- t = retstr = apr_palloc(p, retremains * 2);
- if (conv_utf8_to_ucs2(srcstr, &srcremains,
- t, &retremains) || srcremains)
- return NULL;
+
+ if (rv = conv_utf8_to_ucs2(srcstr, &srcremains, t, &retremains)) {
+ return rv;
+ }
+ if (srcremains) {
+ return APR_ENAMETOOLONG;
+ }
for (; *t; ++t)
if (*t == L'/')
*t = L'\\';
- return retstr;
+ return APR_SUCCESS;
}
-char *unicode_to_utf8_path(const apr_wchar_t* srcstr, apr_pool_t *p)
+apr_status_t unicode_to_utf8_path(char* retstr, apr_size_t retlen,
+ const apr_wchar_t* srcstr)
{
- /* TODO: The computations could preconvert the string to determine
- * the true size of the retstr, but that's a memory over speed
- * tradeoff that isn't appropriate this early in development.
- *
- * Skip the leading 4 characters if the path begins \\?\, or substitute
+ /* Skip the leading 4 characters if the path begins \\?\, or substitute
* // for the \\?\UNC\ path prefix, allocating the maximum string
* length based on the remaining string, plus the trailing null.
* then transform \\'s back into /'s since the \\?\ form never
* allows '/' path seperators, and APR always uses '/'s.
*/
int srcremains = wcslen(srcstr) + 1;
- int retremains = (srcremains - 1) * 3 + 1;
- char *t, *retstr;
+ apr_status_t rv;
+ char *t = retstr;
if (srcstr[0] == L'\\' && srcstr[1] == L'\\' &&
srcstr[2] == L'?' && srcstr[3] == L'\\') {
if (srcstr[4] == L'U' && srcstr[5] == L'N' &&
srcstr[6] == L'C' && srcstr[7] == L'\\') {
srcremains -= 8;
- retremains -= 24;
srcstr += 8;
- retstr = apr_palloc(p, retremains + 2);
strcpy(retstr, "//");
- t = retstr + 2;
+ retlen -= 2;
+ t += 2;
}
else {
srcremains -= 4;
- retremains -= 12;
srcstr += 4;
- t = retstr = apr_palloc(p, retremains);
}
}
- else
- t = retstr = apr_palloc(p, retremains);
- if (conv_ucs2_to_utf8(srcstr, &srcremains,
- t, &retremains) || srcremains)
- return NULL;
+ if (rv = conv_ucs2_to_utf8(srcstr, &srcremains, t, &retlen)) {
+ return rv;
+ }
+ if (srcremains) {
+ return APR_ENAMETOOLONG;
+ }
for (; *t; ++t)
if (*t == L'/')
*t = L'\\';
- return retstr;
+ return APR_SUCCESS;
}
#endif
apr_status_t file_cleanup(void *thefile)
{
apr_file_t *file = thefile;
- CloseHandle(file->filehand);
- file->filehand = INVALID_HANDLE_VALUE;
+ if (file->filehand != INVALID_HANDLE_VALUE) {
+ CloseHandle(file->filehand);
+ file->filehand = INVALID_HANDLE_VALUE;
+ }
if (file->pOverlapped) {
CloseHandle(file->pOverlapped->hEvent);
+ file->pOverlapped = NULL;
}
return APR_SUCCESS;
}
@@ -167,54 +168,30 @@
apr_int32_t flag, apr_fileperms_t perm,
apr_pool_t *cont)
{
+ /* XXX: The default FILE_FLAG_SEQUENTIAL_SCAN is _wrong_ for
+ * sdbm and any other random files! We _must_ rethink
+ * this approach.
+ */
+ HANDLE handle = INVALID_HANDLE_VALUE;
DWORD oflags = 0;
DWORD createflags = 0;
- DWORD attributes = 0;
+ DWORD attributes = FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN;
DWORD sharemode = FILE_SHARE_READ | FILE_SHARE_WRITE;
apr_oslevel_e os_level;
apr_status_t rv;
- (*new) = (apr_file_t *)apr_pcalloc(cont, sizeof(apr_file_t));
- (*new)->cntxt = cont;
-
if (flag & APR_READ) {
oflags |= GENERIC_READ;
}
if (flag & APR_WRITE) {
oflags |= GENERIC_WRITE;
- }
- if (!(flag & APR_READ) && !(flag & APR_WRITE)) {
- (*new)->filehand = INVALID_HANDLE_VALUE;
- return APR_EACCES;
- }
-
- (*new)->buffered = (flag & APR_BUFFERED) > 0;
-
- if ((*new)->buffered) {
- (*new)->buffer = apr_palloc(cont, APR_FILE_BUFSIZE);
- rv = apr_create_lock(&(*new)->mutex, APR_MUTEX, APR_INTRAPROCESS,
NULL, cont);
-
- if (rv)
- return rv;
}
-
+
if (!apr_get_oslevel(cont, &os_level) && os_level >= APR_WIN_NT)
sharemode |= FILE_SHARE_DELETE;
else
os_level = 0;
-#if APR_HAS_UNICODE_FS
- if (os_level >= APR_WIN_NT)
- {
- (*new)->w.fname = utf8_to_unicode_path(fname, cont);
- if (!(*new)->w.fname)
- /* XXX: really bad file name */
- return APR_ENAMETOOLONG;
- }
- else
-#endif
- (*new)->n.fname = apr_pstrdup(cont, fname);
-
if (flag & APR_CREATE) {
if (flag & APR_EXCL) {
/* only create new if file does not already exist */
@@ -235,36 +212,77 @@
}
if ((flag & APR_EXCL) && !(flag & APR_CREATE)) {
- (*new)->filehand = INVALID_HANDLE_VALUE;
return APR_EACCES;
}
-
- if (flag & APR_APPEND) {
- (*new)->append = 1;
- }
- else {
- (*new)->append = 0;
- }
-
- attributes = FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN;
+
if (flag & APR_DELONCLOSE) {
attributes |= FILE_FLAG_DELETE_ON_CLOSE;
}
+ if (flag & APR_OPENLINK) {
+ attributes |= FILE_FLAG_OPEN_REPARSE_POINT;
+ }
+ if (!(flag & (APR_READ | APR_WRITE)) && (os_level >= APR_WIN_NT)) {
+ /* We once failed here, but this is how one opens
+ * a directory as a file under winnt. Accelerate
+ * further by not hitting storage, we don't need to.
+ */
+ attributes |= FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_NO_RECALL;
+ }
+ if (flag & APR_XTHREAD) {
+ /* This win32 specific feature is required
+ * to allow multiple threads to work with the file.
+ */
+ attributes |= FILE_FLAG_OVERLAPPED;
+ }
#if APR_HAS_UNICODE_FS
- if (os_level >= APR_WIN_NT)
- (*new)->filehand = CreateFileW((*new)->w.fname, oflags, sharemode,
- NULL, createflags, attributes, 0);
+ if (os_level >= APR_WIN_NT) {
+ apr_wchar_t wfname[8192];
+ if (rv = utf8_to_unicode_path(wfname, sizeof(wfname)
+ / sizeof(apr_wchar_t), fname))
+ return rv;
+ handle = CreateFileW(wfname, oflags, sharemode,
+ NULL, createflags, attributes, 0);
+ }
else
#endif
- (*new)->filehand = CreateFile((*new)->n.fname, oflags, sharemode,
- NULL, createflags, attributes, 0);
- if ((*new)->filehand == INVALID_HANDLE_VALUE) {
+ handle = CreateFileA((*new)->fname, oflags, sharemode,
+ NULL, createflags, attributes, 0);
+
+ if (handle == INVALID_HANDLE_VALUE) {
return apr_get_os_error();
}
+
+ (*new) = (apr_file_t *)apr_pcalloc(cont, sizeof(apr_file_t));
+ (*new)->cntxt = cont;
+ (*new)->filehand = handle;
+ (*new)->fname = apr_pstrdup(cont, fname);
+
if (flag & APR_APPEND) {
+ (*new)->append = 1;
SetFilePointer((*new)->filehand, 0, NULL, FILE_END);
}
+ else {
+ (*new)->append = 0;
+ }
+
+ if (flag & APR_BUFFERED) {
+ (*new)->buffered = 1;
+ (*new)->buffer = apr_palloc(cont, APR_FILE_BUFSIZE);
+ rv = apr_create_lock(&(*new)->mutex, APR_MUTEX, APR_INTRAPROCESS,
NULL, cont);
+
+ if (rv) {
+ if (file_cleanup(*new) == APR_SUCCESS) {
+ apr_kill_cleanup(cont, *new, file_cleanup);
+ }
+ return rv;
+ }
+ }
+ else {
+ (*new)->buffered = 0;
+ (*new)->buffer = apr_palloc(cont, APR_FILE_BUFSIZE);
+ (*new)->mutex = NULL;
+ }
(*new)->pipe = 0;
(*new)->timeout = -1;
@@ -302,9 +320,12 @@
apr_oslevel_e os_level;
if (!apr_get_oslevel(cont, &os_level) && os_level >= APR_WIN_NT)
{
- apr_wchar_t *wpath = utf8_to_unicode_path(path, cont);
- if (!wpath)
- return APR_ENAMETOOLONG;
+ apr_wchar_t wpath[8192];
+ apr_status_t rv;
+ if (rv = utf8_to_unicode_path(wpath, sizeof(wpath)
+ / sizeof(apr_wchar_t), path)) {
+ return rv;
+ }
if (DeleteFileW(wpath))
return APR_SUCCESS;
}
@@ -315,26 +336,32 @@
return apr_get_os_error();
}
-APR_DECLARE(apr_status_t) apr_rename_file(const char *from_path,
- const char *to_path,
+APR_DECLARE(apr_status_t) apr_rename_file(const char *frompath,
+ const char *topath,
apr_pool_t *cont)
{
#if APR_HAS_UNICODE_FS
apr_oslevel_e os_level;
if (!apr_get_oslevel(cont, &os_level) && os_level >= APR_WIN_NT)
{
- apr_wchar_t *wfrompath = utf8_to_unicode_path(from_path, cont);
- apr_wchar_t *wtopath = utf8_to_unicode_path(to_path, cont);
- if (!wfrompath || !wtopath)
- return APR_ENAMETOOLONG;
+ apr_wchar_t wfrompath[8192], wtopath[8192];
+ apr_status_t rv;
+ if (rv = utf8_to_unicode_path(wfrompath, sizeof(wfrompath)
+ / sizeof(apr_wchar_t), frompath))
{
+ return rv;
+ }
+ if (rv = utf8_to_unicode_path(wtopath, sizeof(wtopath)
+ / sizeof(apr_wchar_t), topath))
{
+ return rv;
+ }
if (MoveFileExW(wfrompath, wtopath, MOVEFILE_REPLACE_EXISTING |
MOVEFILE_COPY_ALLOWED))
return APR_SUCCESS;
}
else
#endif
- if (MoveFileEx(from_path, to_path, MOVEFILE_REPLACE_EXISTING |
- MOVEFILE_COPY_ALLOWED))
+ if (MoveFileEx(frompath, topath, MOVEFILE_REPLACE_EXISTING |
+ MOVEFILE_COPY_ALLOWED))
return APR_SUCCESS;
return apr_get_os_error();
}
@@ -383,7 +410,7 @@
if ((*thefile)->filehand == INVALID_HANDLE_VALUE)
return apr_get_os_error();
(*thefile)->cntxt = cont;
- (*thefile)->n.fname = "\0\0"; // What was this??? : "STD_ERROR_HANDLE";
*/
+ (*thefile)->fname = "\0"; // What was this??? : "STD_ERROR_HANDLE"; */
(*thefile)->eof_hit = 0;
return APR_SUCCESS;
1.34 +4 -4 apr/file_io/win32/pipe.c
Index: pipe.c
===================================================================
RCS file: /home/cvs/apr/file_io/win32/pipe.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- pipe.c 2001/01/18 20:07:15 1.33
+++ pipe.c 2001/01/20 21:39:03 1.34
@@ -91,7 +91,7 @@
(*in) = (apr_file_t *)apr_pcalloc(p, sizeof(apr_file_t));
(*in)->cntxt = p;
- (*in)->n.fname = "\0\0"; // What was this??? : apr_pstrdup(p, "PIPE"); */
+ (*in)->fname = "\0"; // What was this??? : apr_pstrdup(p, "PIPE"); */
(*in)->pipe = 1;
(*in)->timeout = -1;
(*in)->ungetchar = -1;
@@ -103,7 +103,7 @@
(*out) = (apr_file_t *)apr_pcalloc(p, sizeof(apr_file_t));
(*out)->cntxt = p;
- (*in)->n.fname = "\0\0"; // What was this??? : apr_pstrdup(p, "PIPE"); */
+ (*in)->fname = "\0"; // What was this??? : apr_pstrdup(p, "PIPE"); */
(*out)->pipe = 1;
(*out)->timeout = -1;
(*out)->ungetchar = -1;
@@ -161,7 +161,7 @@
(*in) = (apr_file_t *)apr_pcalloc(p, sizeof(apr_file_t));
(*in)->cntxt = p;
- (*in)->n.fname = "\0\0"; // What was this??? : apr_pstrdup(p, "PIPE"); */
+ (*in)->fname = "\0"; // What was this??? : apr_pstrdup(p, "PIPE"); */
(*in)->pipe = 1;
(*in)->timeout = -1;
(*in)->ungetchar = -1;
@@ -174,7 +174,7 @@
(*out) = (apr_file_t *)apr_pcalloc(p, sizeof(apr_file_t));
(*out)->cntxt = p;
- (*in)->n.fname = "\0\0"; // What was this??? : apr_pstrdup(p, "PIPE"); */
+ (*in)->fname = "\0"; // What was this??? : apr_pstrdup(p, "PIPE"); */
(*out)->pipe = 1;
(*out)->timeout = -1;
(*out)->ungetchar = -1;
1.13 +2 -2 apr/file_io/win32/seek.c
Index: seek.c
===================================================================
RCS file: /home/cvs/apr/file_io/win32/seek.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- seek.c 2001/01/18 20:07:16 1.12
+++ seek.c 2001/01/20 21:39:03 1.13
@@ -105,8 +105,8 @@
break;
case APR_END:
- rc = apr_getfileinfo(&finfo, thefile);
- if (rc == APR_SUCCESS)
+ rc = apr_getfileinfo(&finfo, APR_FINFO_SIZE, thefile);
+ if (rc == APR_SUCCESS && (finfo.valid & APR_FINFO_SIZE))
rc = setptr(thefile, finfo.size - *offset);
break;
}
1.29 +1 -17 apr/include/arch/unix/fileio.h
Index: fileio.h
===================================================================
RCS file: /home/cvs/apr/include/arch/unix/fileio.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- fileio.h 2000/12/22 16:54:51 1.28
+++ fileio.h 2001/01/20 21:39:04 1.29
@@ -113,26 +113,10 @@
#define APR_FILE_BUFSIZE 4096
-typedef struct apr_canon_elem_t {
-/* A possible comparison mechanism to play with once we start
- * implementing case insensitive mount poinbt semantices
- * int dev;
- * int inode;
- * apr_time_t cached; --for timeout?
- */
- int pathlen;
- char *element;
-} apr_canon_elem_t;
-
-struct apr_canon_t {
- apr_pool_t *cntxt;
- apr_array_header_t *elems;
-};
-
struct apr_file_t {
apr_pool_t *cntxt;
int filedes;
- char * fname;
+ char *fname;
int oflags;
int eof_hit;
int pipe;
1.40 +22 -66 apr/include/arch/win32/fileio.h
Index: fileio.h
===================================================================
RCS file: /home/cvs/apr/include/arch/win32/fileio.h,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- fileio.h 2001/01/18 20:07:27 1.39
+++ fileio.h 2001/01/20 21:39:04 1.40
@@ -87,6 +87,18 @@
#include <sys/uio.h>
#endif
+#if APR_HAS_UNICODE_FS
+#include "i18n.h"
+#include <wchar.h>
+
+typedef apr_int16_t apr_wchar_t;
+
+apr_status_t utf8_to_unicode_path(apr_wchar_t* dststr, apr_size_t dstchars,
+ const char* srcstr);
+apr_status_t unicode_to_utf8_path(char* dststr, apr_size_t dstchars,
+ const apr_wchar_t* srcstr);
+#endif
+
#define APR_FILE_BUFSIZE 4096
/* obscure ommissions from msvc's sys/stat.h */
@@ -98,59 +110,17 @@
#define S_IFWHT 0160000 /* Whiteout */
#endif
-#if APR_HAS_UNICODE_FS
-#include "i18n.h"
-#include <wchar.h>
-
-typedef apr_int16_t apr_wchar_t;
-
-apr_wchar_t *utf8_to_unicode_path(const char* srcstr, apr_pool_t *p);
-char *unicode_to_utf8_path(const apr_wchar_t* srcstr, apr_pool_t *p);
-#endif
+/* Internal Flags for apr_open */
+#define APR_OPENLINK 8192 /* Open a link itself, if supported */
+#define APR_READCONTROL 4096 /* Read the file's owner/perms */
+#define APR_WRITECONTROL 2048 /* Modifythe file's owner/perms */
-typedef enum apr_canon_case_e {
- APR_CANON_CASE_GIVEN,
- APR_CANON_CASE_LOWER,
- APR_CANON_CASE_TRUE
-} apr_canon_case_e;
-
-typedef enum apr_canon_path_e {
- APR_CANON_PATH_VIRUTAL,
- APR_CANON_PATH_ABSOLUTE,
- APR_CANON_PATH_RELATIVE
-} apr_canon_path_e;
-
-/*
- * Internal canonical filename elements for the apr_canon_t elems
- * ccase tracks the mechanism used to resolve this element
- * pathlen is the full path length to the end of this element
- * name slash is prefix, as appropriate
-
- */
-typedef struct apr_canon_elem_t {
- apr_canon_case_e ccase;
- int pathlen;
- char *name;
-} apr_canon_elem_t;
-/* warning: win32 canonical path "/" resolves to a
- * zero'th element of the empty string for testing the
- * psudo-root for the system
- */
-struct apr_canon_t {
- apr_pool_t *cntxt;
- apr_array_header_t *elems;
- apr_canon_path_e type;
-};
/* quick run-down of fields in windows' apr_file_t structure that may have
* obvious uses.
* fname -- the filename as passed to the open call.
* dwFileAttricutes -- Attributes used to open the file.
- * demonfname -- the canonicalized filename. Used to store the result from
- * apr_os_canonicalize_filename.
- * lowerdemonfname -- inserted at Ken Parzygnat's request, because of the
- * ugly way windows deals with case in the filesystem.
* append -- Windows doesn't support the append concept when opening files.
* APR needs to keep track of this, and always make sure we append
* correctly when writing to a file with this flag set TRUE.
@@ -164,25 +134,13 @@
apr_interval_time_t timeout;
/* File specific info */
- union {
-#if APR_HAS_UNICODE_FS
- struct {
- apr_wchar_t *fname;
- } w;
-#endif
- struct {
- char *fname;
- } n;
- };
+ apr_finfo_t *finfo;
+ char *fname;
DWORD dwFileAttributes;
int eof_hit;
BOOLEAN buffered; // Use buffered I/O?
int ungetchar; // Last char provided by an unget op. (-1 =
no char)
int append;
- off_t size;
- apr_time_t atime;
- apr_time_t mtime;
- apr_time_t ctime;
/* Stuff for buffered mode */
char *buffer;
@@ -192,24 +150,23 @@
apr_ssize_t filePtr; // position in file of handle
apr_lock_t *mutex; // mutex semaphore, must be owned to access
the above fields
- /* Pipe specific info */
-
+ /* Pipe specific info */
};
struct apr_dir_t {
apr_pool_t *cntxt;
HANDLE dirhand;
apr_size_t rootlen;
+ char *dirname;
+ char *name;
union {
#if APR_HAS_UNICODE_FS
struct {
- apr_wchar_t *dirname;
WIN32_FIND_DATAW *entry;
} w;
#endif
struct {
- char *dirname;
- WIN32_FIND_DATA *entry;
+ WIN32_FIND_DATAA *entry;
} n;
};
};
@@ -224,4 +181,3 @@
BOOLEAN bAsyncRead, BOOLEAN bAsyncWrite,
apr_pool_t *p);
#endif /* ! FILE_IO_H */
-
1.22 +1 -1 apr/test/testmmap.c
Index: testmmap.c
===================================================================
RCS file: /home/cvs/apr/test/testmmap.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- testmmap.c 2001/01/08 23:51:59 1.21
+++ testmmap.c 2001/01/20 21:39:05 1.22
@@ -115,7 +115,7 @@
}
fprintf(stderr, "Getting file size...................");
- rv = apr_getfileinfo(&finfo, thefile);
+ rv = apr_getfileinfo(&finfo, APR_FINFO_NORM, thefile);
if (rv != APR_SUCCESS) {
fprintf(stderr,
"Didn't get file information: %d/%s\n",