wrowe 01/01/22 20:10:48
Modified: file_io/os2 dir.c
file_io/unix dir.c filestat.c
file_io/win32 dir.c filestat.c
include apr_file_info.h
include/arch/os2 fileio.h
include/arch/unix fileio.h
include/arch/win32 fileio.h
test testfile.c
Log:
apr_dir_read now accepts a pointer to the user's apr_finfo_t to gather
all known data discovered during the stat (using a wanted value of
APR_FINFO_DIRENT), and reports it through the ->valid entry. Specific
fields can be requested, and apr_dir_read -will- go out and get them
(when possible), but asserting a wanted value other than APR_FINFO_DIRENT
will be non-atomic on a subset of our supported platforms.
Added APR_FINFO_NLINK and apr_finfo_t .nlink to apr_finfo_t.
Changed apr_finfo_t .fcase to simply .name (as opposed to .fname,
the full file path name.)
Revision Changes Path
1.22 +52 -76 apr/file_io/os2/dir.c
Index: dir.c
===================================================================
RCS file: /home/cvs/apr/file_io/os2/dir.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- dir.c 2001/01/05 19:40:05 1.21
+++ dir.c 2001/01/23 04:10:46 1.22
@@ -64,7 +64,7 @@
static apr_status_t dir_cleanup(void *thedir)
{
apr_dir_t *dir = thedir;
- return apr_closedir(dir);
+ return apr_dir_close(dir);
}
@@ -91,7 +91,7 @@
-apr_status_t apr_closedir(apr_dir_t *thedir)
+apr_status_t apr_dir_close(apr_dir_t *thedir)
{
int rv = 0;
@@ -108,7 +108,8 @@
-apr_status_t apr_readdir(apr_dir_t *thedir)
+apr_status_t apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted,
+ apr_dir_t *thedir)
{
int rv;
ULONG entries = 1;
@@ -122,24 +123,66 @@
rv = DosFindNext(thedir->handle, &thedir->entry,
sizeof(thedir->entry), &entries);
}
- if (rv == 0 && entries == 1) {
+ /* No valid bit flag to test here - do we want one? */
+ finfo->cntxt = thedir->cntxt;
+ finfo->fname = NULL;
+
+ if (rv == 0 && entries == 1)
+ {
+ /* XXX: Optimize the heck out of this case - whatever we know,
report,
+ * and then stat only if we must (e.g. wanted & APR_FINFO_TYPE)
+ */
thedir->validentry = TRUE;
+
+ wanted &= ~(APR_FINFO_NAME | APR_FINFO_MTIME | APR_FINFO_SIZE);
+
+ if (wanted == APR_FINFO_TYPE && thedir->entry.attrFile &
FILE_DIRECTORY)
+ wanted = 0;
+
+ if (wanted)
+ {
+ char fspec[_MAXPATH];
+ int off;
+ apr_strcpyn(fspec, sizeof(fspec), thedir->dirname);
+ off = strlen(fspec);
+ if (fspec[off - 1] != '/')
+ fspec[off++] = '/';
+ apr_strcpyn(fspec + off, sizeof(fspec) - off,
thedir->entry->d_name);
+ /* ??? Or lstat below?, I know, OS2 doesn't do symlinks, yet */
+ ret = apr_stat(finfo, wanted, fspec, thedir->cntxt);
+ }
+ if (!wanted || ret) {
+ finfo->cntxt = thedir->cntxt;
+ finfo->valid = 0;
+ }
+ /* We passed a name off the stack that has popped */
+ finfo->fname = NULL;
+ finfo->valid |= APR_FINFO_NAME | APR_FINFO_MTIME | APR_FINFO_SIZE;
+ finfo->size = thedir->entry.cbFile;
+ apr_os2_time_to_apr_time(finfo->mtime, thedir->entry.fdateLastWrite,
+ thedir->entry.ftimeLastWrite);
+ finfo->name = thedir->entry.achName;
+ if (thedir->entry.attrFile & FILE_DIRECTORY) {
+ finfo->filetype = APR_DIR;
+ finfo->valid |= APR_FINFO_TYPE;
+ }
+
return APR_SUCCESS;
}
-
+
thedir->validentry = FALSE;
-
+
if (rv)
return APR_OS2_STATUS(rv);
-
+
return APR_ENOENT;
}
-apr_status_t apr_rewinddir(apr_dir_t *thedir)
+apr_status_t apr_dir_rewind(apr_dir_t *thedir)
{
- return apr_closedir(thedir);
+ return apr_dir_close(thedir);
}
@@ -158,72 +201,5 @@
-apr_status_t apr_dir_entry_size(apr_size_t *size, apr_dir_t *thedir)
-{
- if (thedir->validentry) {
- *size = thedir->entry.cbFile;
- return APR_SUCCESS;
- }
-
- return APR_ENOFILE;
-}
-
-
-
-apr_status_t apr_dir_entry_mtime(apr_time_t *time, apr_dir_t *thedir)
-{
- if (thedir->validentry) {
- apr_os2_time_to_apr_time(time, thedir->entry.fdateLastWrite,
- thedir->entry.ftimeLastWrite);
- return APR_SUCCESS;
- }
-
- return APR_ENOFILE;
-}
-
-apr_status_t apr_dir_entry_ftype(apr_filetype_e *type, apr_dir_t *thedir)
-{
- int rc;
- HFILE hFile;
- ULONG action, Type, Attr;
- apr_filetype_e typemap[8] = { APR_REG, APR_CHR, APR_PIPE };
-
- if (thedir->validentry) {
- if (thedir->entry.attrFile & FILE_DIRECTORY) {
- *type = APR_DIR;
- return APR_SUCCESS;
- } else {
- rc = DosOpen(apr_pstrcat(thedir->cntxt, thedir->dirname, "/",
thedir->entry.achName, NULL) ,
- &hFile, &action, 0, 0,
- OPEN_ACTION_FAIL_IF_NEW|OPEN_ACTION_OPEN_IF_EXISTS,
OPEN_SHARE_DENYNONE|OPEN_ACCESS_READONLY,
- NULL);
-
- if ( rc == 0 ) {
- rc = DosQueryHType( hFile, &Type, &Attr );
-
- if ( rc == 0 ) {
- *type = typemap[(Type & 0x0007)];
- }
- DosClose( hFile );
- }
-
- return APR_OS2_STATUS(rc);
- }
- }
-
- return APR_ENOFILE;
-}
-
-
-
-apr_status_t apr_get_dir_filename(const char **new, apr_dir_t *thedir)
-{
- if (thedir->validentry) {
- *new = thedir->entry.achName;
- return APR_SUCCESS;
- }
-
- return APR_ENOFILE;
-}
1.43 +46 -101 apr/file_io/unix/dir.c
Index: dir.c
===================================================================
RCS file: /home/cvs/apr/file_io/unix/dir.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- dir.c 2001/01/05 19:40:05 1.42
+++ dir.c 2001/01/23 04:10:46 1.43
@@ -95,7 +95,7 @@
}
}
-apr_status_t apr_closedir(apr_dir_t *thedir)
+apr_status_t apr_dir_close(apr_dir_t *thedir)
{
apr_status_t rv;
@@ -106,36 +106,69 @@
return rv;
}
-apr_status_t apr_readdir(apr_dir_t *thedir)
+apr_status_t apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted,
+ apr_dir_t *thedir)
{
-#if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS) \
- && !defined(READDIR_IS_THREAD_SAFE)
apr_status_t ret;
-#endif
-
#if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS) \
&& !defined(READDIR_IS_THREAD_SAFE)
+ dirent *retent;
+
+ ret = readdir_r(thedir->dirstruct, thedir->entry, &retent);
- ret = readdir_r(thedir->dirstruct, thedir->entry, &thedir->entry);
/* Avoid the Linux problem where at end-of-directory thedir->entry
* is set to NULL, but ret = APR_SUCCESS.
*/
- return (ret == APR_SUCCESS && thedir->entry == NULL) ? APR_ENOENT : ret;
+ if(!ret || thedir->entry != retent)
+ ret = APR_ENOENT;
#else
-
thedir->entry = readdir(thedir->dirstruct);
if (thedir->entry == NULL) {
/* If NULL was returned, this can NEVER be a success. Can it?! */
if (errno == APR_SUCCESS) {
- return APR_ENOENT;
+ ret = APR_ENOENT;
}
- return errno;
+ else
+ ret = errno;
}
- return APR_SUCCESS;
#endif
+
+ /* No valid bit flag to test here - do we want one? */
+ finfo->fname = NULL;
+
+ if (ret) {
+ finfo->valid = 0;
+ return ret;
+ }
+
+ /* What we already know */
+ /* XXX: Optimize here with d_fileno, d_type etc by platform */
+ wanted &= ~(APR_FINFO_NAME);
+ if (wanted)
+ {
+ char fspec[_MAXPATH];
+ int off;
+ apr_strcpyn(fspec, sizeof(fspec), thedir->dirname);
+ off = strlen(fspec);
+ if (fspec[off - 1] != '/')
+ fspec[off++] = '/';
+ apr_strcpyn(fspec + off, sizeof(fspec) - off, thedir->entry->d_name);
+ /* ??? Or lstat below? What is it we really want? */
+ ret = apr_stat(finfo, wanted, fspec, thedir->cntxt);
+ }
+ if (!wanted || ret) {
+ finfo->cntxt = thedir->cntxt;
+ finfo->valid = 0;
+ }
+ /* We passed a stack name that is now gone */
+ finfo->fname = NULL;
+ finfo->valid |= APR_FINFO_NAME;
+ /* XXX: Optimize here with d_fileno, d_type etc by platform */
+ finfo->name = thedir->entry->d_name;
+ return APR_SUCCESS;
}
-apr_status_t apr_rewinddir(apr_dir_t *thedir)
+apr_status_t apr_dir_rewind(apr_dir_t *thedir)
{
rewinddir(thedir->dirstruct);
return APR_SUCCESS;
@@ -161,94 +194,6 @@
else {
return errno;
}
-}
-
-apr_status_t apr_dir_entry_size(apr_size_t *size, apr_dir_t *thedir)
-{
- struct stat filestat;
- char *fname = NULL;
-
- if (thedir->entry == NULL) {
- *size = -1;
- return APR_ENOFILE;
- }
- fname = apr_pstrcat(thedir->cntxt, thedir->dirname, "/",
- thedir->entry->d_name, NULL);
- if (stat(fname, &filestat) == -1) {
- *size = 0;
- return errno;
- }
-
- *size = filestat.st_size;
- return APR_SUCCESS;
-}
-
-apr_status_t apr_dir_entry_mtime(apr_time_t *mtime, apr_dir_t *thedir)
-{
- struct stat filestat;
- char *fname = NULL;
-
- if (thedir->entry == NULL) {
- *mtime = -1;
- return APR_ENOFILE;
- }
-
- fname = apr_pstrcat(thedir->cntxt, thedir->dirname, "/",
- thedir->entry->d_name, NULL);
- if (stat(fname, &filestat) == -1) {
- *mtime = -1;
- return errno;
- }
-
- apr_ansi_time_to_apr_time(mtime, filestat.st_mtime);
- return APR_SUCCESS;
-}
-
-apr_status_t apr_dir_entry_ftype(apr_filetype_e *type, apr_dir_t *thedir)
-{
- struct stat filestat;
- char *fname = NULL;
-
- if (thedir->entry == NULL) {
- *type = APR_REG;
- return APR_ENOFILE;
- }
-
- fname = apr_pstrcat(thedir->cntxt, thedir->dirname, "/",
- thedir->entry->d_name, NULL);
- if (stat(fname, &filestat) == -1) {
- *type = APR_REG;
- return errno;
- }
-
- if (S_ISREG(filestat.st_mode))
- *type = APR_REG;
- if (S_ISDIR(filestat.st_mode))
- *type = APR_DIR;
- if (S_ISCHR(filestat.st_mode))
- *type = APR_CHR;
- if (S_ISBLK(filestat.st_mode))
- *type = APR_BLK;
- if (S_ISFIFO(filestat.st_mode))
- *type = APR_PIPE;
- if (S_ISLNK(filestat.st_mode))
- *type = APR_LNK;
-#ifndef BEOS
- if (S_ISSOCK(filestat.st_mode))
- *type = APR_SOCK;
-#endif
- return APR_SUCCESS;
-}
-
-apr_status_t apr_get_dir_filename(const char **new, apr_dir_t *thedir)
-{
- /* Detect End-Of-File */
- if (thedir == NULL || thedir->entry == NULL) {
- *new = NULL;
- return APR_ENOENT;
- }
- (*new) = thedir->entry->d_name;
- return APR_SUCCESS;
}
apr_status_t apr_get_os_dir(apr_os_dir_t **thedir, apr_dir_t *dir)
1.38 +1 -4 apr/file_io/unix/filestat.c
Index: filestat.c
===================================================================
RCS file: /home/cvs/apr/file_io/unix/filestat.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- filestat.c 2001/01/22 00:59:26 1.37
+++ filestat.c 2001/01/23 04:10:46 1.38
@@ -93,10 +93,7 @@
finfo->size = info.st_size;
finfo->inode = info.st_ino;
finfo->device = info.st_dev;
-
-/* We don't have nlinks in the finfo structure. Are we going to add it?
RBB*/
-/* finfo->nlinks = info.st_nlink; */
-
+ finfo->nlink = 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);
1.44 +32 -77 apr/file_io/win32/dir.c
Index: dir.c
===================================================================
RCS file: /home/cvs/apr/file_io/win32/dir.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- dir.c 2001/01/20 21:39:03 1.43
+++ dir.c 2001/01/23 04:10:46 1.44
@@ -129,7 +129,7 @@
return APR_SUCCESS;
}
-APR_DECLARE(apr_status_t) apr_closedir(apr_dir_t *dir)
+APR_DECLARE(apr_status_t) apr_dir_close(apr_dir_t *dir)
{
if (dir->dirhand != INVALID_HANDLE_VALUE && !FindClose(dir->dirhand)) {
return apr_get_os_error();
@@ -138,7 +138,8 @@
return APR_SUCCESS;
}
-APR_DECLARE(apr_status_t) apr_readdir(apr_dir_t *thedir)
+APR_DECLARE(apr_status_t) apr_dir_read(apr_finfo_t *finfo, apr_int32_t
wanted,
+ apr_dir_t *thedir)
{
/* The while loops below allow us to skip all invalid file names, so that
* we aren't reporting any files where their absolute paths are too long.
@@ -147,6 +148,7 @@
apr_oslevel_e os_level;
if (!apr_get_oslevel(thedir->cntxt, &os_level) && os_level >= APR_WIN_NT)
{
+ apr_status_t rv;
if (thedir->dirhand == INVALID_HANDLE_VALUE)
{
apr_wchar_t wdirname[8192];
@@ -171,6 +173,10 @@
return apr_get_os_error();
}
}
+ if (rv = unicode_to_utf8_path(thedir->name, MAX_PATH * 3 + 1,
+ thedir->w.entry->cFileName))
+ return rv;
+ finfo->name = thedir->name;
}
else
#endif
@@ -192,11 +198,31 @@
return apr_get_os_error();
}
}
+ finfo->name = thedir->n.entry->cFileName;
+ }
+
+ finfo->valid = APR_FINFO_NAME | APR_FINFO_SIZE | APR_FINFO_MTIME;
+ finfo->fname = NULL;
+ finfo->size = (thedir->n.entry->nFileSizeHigh * MAXDWORD) +
+ thedir->n.entry->nFileSizeLow;
+ FileTimeToAprTime(&finfo->mtime, &thedir->n.entry->ftLastWriteTime);
+ if (thedir->n.entry->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+ finfo->filetype = APR_DIR;
+ finfo->valid |= APR_FINFO_TYPE;
}
+ else if (thedir->n.entry->dwFileAttributes &
FILE_ATTRIBUTE_REPARSE_POINT) {
+ finfo->filetype = APR_LNK;
+ finfo->valid |= APR_FINFO_TYPE | APR_FINFO_LINK;
+ }
+ else {
+ /* XXX: Not good logic. No devices here, but what might we find? */
+ finfo->filetype = APR_REG;
+ finfo->valid |= APR_FINFO_TYPE;
+ }
return APR_SUCCESS;
}
-APR_DECLARE(apr_status_t) apr_rewinddir(apr_dir_t *dir)
+APR_DECLARE(apr_status_t) apr_dir_rewind(apr_dir_t *dir)
{
dir_cleanup(dir);
if (!FindClose(dir->dirhand)) {
@@ -255,65 +281,11 @@
return APR_SUCCESS;
}
-APR_DECLARE(apr_status_t) apr_dir_entry_size(apr_ssize_t *size,
- apr_dir_t *thedir)
-{
- if (thedir == NULL || thedir->n.entry == NULL) {
- return APR_ENODIR;
- }
- (*size) = (thedir->n.entry->nFileSizeHigh * MAXDWORD) +
- thedir->n.entry->nFileSizeLow;
- return APR_SUCCESS;
-}
-APR_DECLARE(apr_status_t) apr_dir_entry_mtime(apr_time_t *time,
- apr_dir_t *thedir)
-{
- if (thedir == NULL || thedir->n.entry == NULL) {
- return APR_ENODIR;
- }
- FileTimeToAprTime(time, &thedir->n.entry->ftLastWriteTime);
- return APR_SUCCESS;
-}
-
-APR_DECLARE(apr_status_t) apr_dir_entry_ftype(apr_filetype_e *type,
- apr_dir_t *thedir)
-{
- switch(thedir->n.entry->dwFileAttributes) {
- case FILE_ATTRIBUTE_DIRECTORY: {
- (*type) = APR_DIR;
- return APR_SUCCESS;
- }
- case FILE_ATTRIBUTE_NORMAL: {
- (*type) = APR_REG;
- return APR_SUCCESS;
- }
- default: {
- (*type) = APR_REG; /* As valid as anything else.*/
- return APR_SUCCESS;
- }
- }
-}
-APR_DECLARE(apr_status_t) apr_get_dir_filename(const char **new,
- apr_dir_t *thedir)
-{
-#if APR_HAS_UNICODE_FS
- apr_oslevel_e os_level;
- if (!apr_get_oslevel(thedir->cntxt, &os_level) && os_level >= APR_WIN_NT)
- {
- 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
- (*new) = thedir->n.entry->cFileName;
- return APR_SUCCESS;
-}
+
+
APR_DECLARE(apr_status_t) apr_get_os_dir(apr_os_dir_t **thedir,
apr_dir_t *dir)
{
@@ -324,26 +296,9 @@
return APR_SUCCESS;
}
-/* XXX: This is sort of blinkin stupid on win32... consider,
- * our open doesn't open the dir, it sets up the apr_dir_t,
- * and on the first apr_readdir it actually does a FindFirstFile
- * if the handle is closed, or else a FindNextFile that is based
- * on cached info that we simply don't have our hands on when
- * we use this function. Maybe APR_ENOTIMPL would be better?
- */
APR_DECLARE(apr_status_t) apr_put_os_dir(apr_dir_t **dir,
apr_os_dir_t *thedir,
apr_pool_t *cont)
{
- if (cont == NULL) {
- return APR_ENOPOOL;
- }
- if ((*dir) == NULL) {
- (*dir) = (apr_dir_t *)apr_pcalloc(cont, sizeof(apr_dir_t));
- (*dir)->cntxt = cont;
- }
- else
- (*dir)->rootlen = 0; /* We don't know, don't care */
- (*dir)->dirhand = thedir;
- return APR_SUCCESS;
+ return APR_ENOTIMPL;
}
1.39 +0 -12 apr/file_io/win32/filestat.c
Index: filestat.c
===================================================================
RCS file: /home/cvs/apr/file_io/win32/filestat.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- filestat.c 2001/01/20 21:39:03 1.38
+++ filestat.c 2001/01/23 04:10:46 1.39
@@ -63,18 +63,6 @@
#include "atime.h"
#include "misc.h"
-/* Entries missing from the MSVC 5.0 Win32 SDK:
- */
-#ifndef FILE_ATTRIBUTE_REPARSE_POINT
-#define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
-#endif
-#ifndef FILE_FLAG_OPEN_NO_RECALL
-#define FILE_FLAG_OPEN_NO_RECALL 0x00100000
-#endif
-#ifndef FILE_FLAG_OPEN_REPARSE_POINT
-#define FILE_FLAG_OPEN_REPARSE_POINT 0x00200000
-#endif
-
APR_DECLARE(apr_status_t) apr_getfileinfo(apr_finfo_t *finfo, apr_int32_t
wanted,
apr_file_t *thefile)
1.5 +15 -45 apr/include/apr_file_info.h
Index: apr_file_info.h
===================================================================
RCS file: /home/cvs/apr/include/apr_file_info.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- apr_file_info.h 2001/01/20 22:18:55 1.4
+++ apr_file_info.h 2001/01/23 04:10:47 1.5
@@ -145,6 +145,7 @@
#define APR_FINFO_CSIZE 0x00000400
#define APR_FINFO_DEV 0x00001000
#define APR_FINFO_INODE 0x00002000
+#define APR_FINFO_NLINK 0x00004000
#define APR_FINFO_TYPE 0x00008000
#define APR_FINFO_USER 0x00010000
#define APR_FINFO_GROUP 0x00020000
@@ -152,13 +153,14 @@
#define APR_FINFO_GPROT 0x00200000
#define APR_FINFO_WPROT 0x00400000
#define APR_FINFO_ICASE 0x01000000 /* if dev is case insensitive */
-#define APR_FINFO_FCASE 0x02000000 /* filename in proper case */
+#define APR_FINFO_NAME 0x02000000 /* ->name in proper case */
#define APR_FINFO_MIN 0x00008170 /* minimal: type, dates and size */
#define APR_FINFO_IDENT 0x00003000 /* dev and inode */
#define APR_FINFO_OWNER 0x00030000 /* user and group */
#define APR_FINFO_PROT 0x00700000 /* all protections */
-#define APR_FINFO_NORM 0x0073b170 /* the expected unix results */
+#define APR_FINFO_NORM 0x0073b170 /* an atomic unix apr_stat() */
+#define APR_FINFO_DIRENT 0x01002000 /* an atomic unix apr_dir_read() */
/**
* The file information structure. This is analogous to the POSIX
@@ -184,6 +186,8 @@
apr_ino_t inode;
/** The id of the device the file is on. */
apr_dev_t device;
+ /** The number of hard links to the file. */
+ apr_int16_t nlink;
/** The size of the file */
apr_off_t size;
/** The space allocated for the file */
@@ -198,8 +202,8 @@
apr_time_t ctime;
/** The full pathname of the file */
const char *fname;
- /** The file's name alone, in filesystem case */
- char *fcase;
+ /** The file's name (no path) in filesystem case */
+ const char *name;
/** The file's handle, if accessed (can be submitted to apr_duphandle) */
struct apr_file_t *filehand;
};
@@ -247,60 +251,26 @@
/**
* close the specified directory.
* @param thedir the directory descriptor to close.
- * @deffunc apr_status_t apr_closedir(apr_dir_t *thedir)
+ * @deffunc apr_status_t apr_dir_close(apr_dir_t *thedir)
*/
-APR_DECLARE(apr_status_t) apr_closedir(apr_dir_t *thedir);
+APR_DECLARE(apr_status_t) apr_dir_close(apr_dir_t *thedir);
/**
* Read the next entry from the specified directory.
* @param thedir the directory descriptor to read from, and fill out.
* @tip All systems return . and .. as the first two files.
- * @deffunc apr_status_t apr_readdir(apr_dir_t *thedir)
+ * @deffunc apr_status_t apr_dir_read(apr_finfo_t *finfo, apr_int32_t
wanted, apr_dir_t *thedir)
*/
-APR_DECLARE(apr_status_t) apr_readdir(apr_dir_t *thedir);
+APR_DECLARE(apr_status_t) apr_dir_read(apr_finfo_t *finfo, apr_int32_t
wanted,
+ apr_dir_t *thedir);
/**
* Rewind the directory to the first entry.
* @param thedir the directory descriptor to rewind.
- * @deffunc apr_status_t apr_rewinddir(apr_dir_t *thedir)
+ * @deffunc apr_status_t apr_dir_rewind(apr_dir_t *thedir)
*/
-APR_DECLARE(apr_status_t) apr_rewinddir(apr_dir_t *thedir);
+APR_DECLARE(apr_status_t) apr_dir_rewind(apr_dir_t *thedir);
-/**
- * Get the file name of the current directory entry.
- * @param new_path the file name of the directory entry.
- * @param thedir the currently open directory.
- * @deffunc apr_status_t apr_get_dir_filename(const char **new_path,
apr_dir_t *thedir)
- */
-APR_DECLARE(apr_status_t) apr_get_dir_filename(const char **new_path,
- apr_dir_t *thedir);
-
-/**
- * Get the size of the current directory entry.
- * @param size the size of the directory entry.
- * @param thedir the currently open directory.
- * @deffunc apr_status_t apr_dir_entry_size(apr_size_t *size, apr_dir_t
*thedir)
- */
-APR_DECLARE(apr_status_t) apr_dir_entry_size(apr_size_t *size,
- apr_dir_t *thedir);
-
-/**
- * Get the last modified time of the current directory entry.
- * @param mtime the last modified time of the directory entry.
- * @param thedir the currently open directory.
- * @deffunc apr_status_t apr_dir_entry_mtime(apr_time_t *mtime, apr_dir_t
*thedir)
- */
-APR_DECLARE(apr_status_t) apr_dir_entry_mtime(apr_time_t *mtime,
- apr_dir_t *thedir);
-
-/**
- * Get the file type of the current directory entry.
- * @param type the file type of the directory entry.
- * @param thedir the currently open directory.
- * @deffunc apr_status_t apr_dir_entry_ftype(apr_filetype_e *type, apr_dir_t
*thedir)
- */
-APR_DECLARE(apr_status_t) apr_dir_entry_ftype(apr_filetype_e *type,
- apr_dir_t *thedir);
#ifdef __cplusplus
}
1.23 +1 -0 apr/include/arch/os2/fileio.h
Index: fileio.h
===================================================================
RCS file: /home/cvs/apr/include/arch/os2/fileio.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- fileio.h 2000/08/06 14:55:54 1.22
+++ fileio.h 2001/01/23 04:10:47 1.23
@@ -63,6 +63,7 @@
#include "apr_general.h"
#include "apr_lock.h"
#include "apr_file_io.h"
+#include "apr_file_info.h"
#include "apr_errno.h"
#define APR_FILE_BUFSIZE 4096
1.30 +1 -0 apr/include/arch/unix/fileio.h
Index: fileio.h
===================================================================
RCS file: /home/cvs/apr/include/arch/unix/fileio.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- fileio.h 2001/01/20 21:39:04 1.29
+++ fileio.h 2001/01/23 04:10:47 1.30
@@ -60,6 +60,7 @@
#include "apr_general.h"
#include "apr_tables.h"
#include "apr_file_io.h"
+#include "apr_file_info.h"
#include "apr_errno.h"
#include "apr_lib.h"
1.41 +12 -0 apr/include/arch/win32/fileio.h
Index: fileio.h
===================================================================
RCS file: /home/cvs/apr/include/arch/win32/fileio.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- fileio.h 2001/01/20 21:39:04 1.40
+++ fileio.h 2001/01/23 04:10:47 1.41
@@ -62,6 +62,7 @@
#include "apr_tables.h"
#include "apr_lock.h"
#include "apr_file_io.h"
+#include "apr_file_info.h"
#include "apr_errno.h"
#include "misc.h"
@@ -115,6 +116,17 @@
#define APR_READCONTROL 4096 /* Read the file's owner/perms */
#define APR_WRITECONTROL 2048 /* Modifythe file's owner/perms */
+/* Entries missing from the MSVC 5.0 Win32 SDK:
+ */
+#ifndef FILE_ATTRIBUTE_REPARSE_POINT
+#define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
+#endif
+#ifndef FILE_FLAG_OPEN_NO_RECALL
+#define FILE_FLAG_OPEN_NO_RECALL 0x00100000
+#endif
+#ifndef FILE_FLAG_OPEN_REPARSE_POINT
+#define FILE_FLAG_OPEN_REPARSE_POINT 0x00200000
+#endif
/* quick run-down of fields in windows' apr_file_t structure that may have
1.25 +13 -15 apr/test/testfile.c
Index: testfile.c
===================================================================
RCS file: /home/cvs/apr/test/testfile.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- testfile.c 2001/01/15 19:19:24 1.24
+++ testfile.c 2001/01/23 04:10:48 1.25
@@ -290,8 +290,7 @@
apr_dir_t *temp;
apr_file_t *file = NULL;
apr_size_t bytes;
- apr_filetype_e type;
- const char *fname;
+ apr_finfo_t dirent;
fprintf(stdout, "Testing Directory functions.\n");
@@ -322,7 +321,7 @@
}
fprintf(stdout, "\tReading Directory.......");
- if ((apr_readdir(temp)) != APR_SUCCESS) {
+ if ((apr_dir_read(&dirent, APR_FINFO_DIRENT, temp)) != APR_SUCCESS) {
fprintf(stderr, "Could not read directory\n");
return -1;
}
@@ -336,40 +335,39 @@
/* Because I want the file I created, I am skipping the "." and ".."
* files that are here.
*/
- if (apr_readdir(temp) != APR_SUCCESS) {
+ if (apr_dir_read(&dirent, APR_FINFO_DIRENT | APR_FINFO_TYPE
+ | APR_FINFO_SIZE | APR_FINFO_MTIME, temp)
+ != APR_SUCCESS) {
fprintf(stderr, "Error reading directory testdir");
return -1;
}
- apr_get_dir_filename(&fname, temp);
- } while (fname[0] == '.');
- if (strcmp(fname, "testfile")) {
- fprintf(stderr, "Got wrong file name %s\n", fname);
+ } while (dirent.name[0] == '.');
+ if (strcmp(dirent.name, "testfile")) {
+ fprintf(stderr, "Got wrong file name %s\n", dirent.name);
return -1;
}
fprintf(stdout, "OK\n");
fprintf(stdout, "\t\tFile type.......");
- apr_dir_entry_ftype(&type, temp);
- if (type != APR_REG) {
+ if (dirent.filetype != APR_REG) {
fprintf(stderr, "Got wrong file type\n");
return -1;
}
fprintf(stdout, "OK\n");
fprintf(stdout, "\t\tFile size.......");
- apr_dir_entry_size(&bytes, temp);
- if (bytes != strlen("Another test!!!")) {
- fprintf(stderr, "Got wrong file size %" APR_SIZE_T_FMT "\n", bytes);
+ if (dirent.size != bytes)) {
+ fprintf(stderr, "Got wrong file size %" APR_SIZE_T_FMT "\n",
dirent.size);
return -1;
}
fprintf(stdout, "OK\n");
fprintf(stdout, "\tRewinding directory.......");
- apr_rewinddir(temp);
+ apr_dir_rewind(temp);
fprintf(stdout, "OK\n");
fprintf(stdout, "\tClosing Directory.......");
- if (apr_closedir(temp) != APR_SUCCESS) {
+ if (apr_dir_close(temp) != APR_SUCCESS) {
fprintf(stderr, "Could not close directory\n");
return -1;
}