You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rb...@hyperreal.org on 2000/01/03 20:47:45 UTC
cvs commit: apache-2.0/src/lib/apr/include apr_file_io.h
rbb 00/01/03 11:47:44
Modified: src/lib/apr/file_io/unix filestat.c
src/lib/apr/include apr_file_io.h
Log:
Add a new function. We shouldn't need to have an open file in order to
get stat information about the file. This takes care of that problem.
Revision Changes Path
1.3 +35 -0 apache-2.0/src/lib/apr/file_io/unix/filestat.c
Index: filestat.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/unix/filestat.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- filestat.c 1999/10/05 01:15:19 1.2
+++ filestat.c 2000/01/03 19:47:43 1.3
@@ -84,3 +84,38 @@
}
}
+/* ***APRDOC********************************************************
+ * ap_status_t ap_stat(ap_file_t **, char *, ap_context_t *)
+ * get the specified file's stats. The file is specified by filename,
+ * instead of using a pre-opened file.
+ * arg 1) Where to store the information about the file.
+ * arg 2) The name of the file to stat.
+ * arg 3) the context to use to allocate the new file.
+ */
+ap_status_t ap_stat(struct file_t **thefile, char *fname, ap_context_t *cont)
+{
+ struct stat info;
+ int rv = stat(fname, &info);
+
+ if (rv == 0) {
+ (*thefile) = ap_pcalloc(cont, sizeof(struct file_t));
+ if ((*thefile) == NULL) {
+ return APR_ENOMEM;
+ }
+ (*thefile)->fname = ap_pstrdup(cont, fname);
+ (*thefile)->filehand = NULL;
+ (*thefile)->filedes = -1;
+ (*thefile)->protection = info.st_mode;
+ (*thefile)->user = info.st_uid;
+ (*thefile)->group = info.st_gid;
+ (*thefile)->size = info.st_size;
+ (*thefile)->atime = info.st_atime;
+ (*thefile)->mtime = info.st_mtime;
+ (*thefile)->ctime = info.st_ctime;
+ (*thefile)->stated = 1;
+ return APR_SUCCESS;
+ }
+ else {
+ return APR_ENOSTAT;
+ }
+}
1.24 +1 -0 apache-2.0/src/lib/apr/include/apr_file_io.h
Index: apr_file_io.h
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_file_io.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- apr_file_io.h 1999/12/30 19:50:28 1.23
+++ apr_file_io.h 2000/01/03 19:47:44 1.24
@@ -132,6 +132,7 @@
ap_status_t ap_make_iov(ap_iovec_t **, struct iovec *, ap_context_t *);
ap_status_t ap_dupfile(ap_file_t **, ap_file_t *);
ap_status_t ap_getfileinfo(ap_file_t *);
+ap_status_t ap_stat(ap_file_t **thefile, char *fname, ap_context_t *cont);
ap_status_t ap_seek(ap_file_t *, ap_seek_where_t, ap_off_t *);
ap_status_t ap_opendir(ap_dir_t **, const char *, ap_context_t *);