You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by rb...@apache.org on 2001/01/22 01:59:26 UTC

cvs commit: apr/file_io/unix filestat.c

rbb         01/01/21 16:59:26

  Modified:    file_io/unix filestat.c
  Log:
  Just combine some common code on Unix.  This should make things a bit
  easier to maintain.
  
  Revision  Changes    Path
  1.37      +31 -46    apr/file_io/unix/filestat.c
  
  Index: filestat.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/unix/filestat.c,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -d -b -w -u -r1.36 -r1.37
  --- filestat.c	2001/01/21 16:27:07	1.36
  +++ filestat.c	2001/01/22 00:59:26	1.37
  @@ -81,14 +81,11 @@
       return type;
   }
   
  -apr_status_t apr_getfileinfo(apr_finfo_t *finfo, apr_int32_t wanted,
  -                             apr_file_t *thefile)
  +static apr_status_t fill_out_finfo(apr_finfo_t *finfo, struct stat info,
  +                                   apr_int32_t wanted)
   {
  -    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->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;
  @@ -103,7 +100,6 @@
           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->fname = thefile->fname;
           if (wanted & APR_FINFO_CSIZE) {
               finfo->csize = info.st_blocks * 512;
               finfo->valid |= APR_FINFO_CSIZE;
  @@ -113,6 +109,17 @@
           }
           return APR_SUCCESS;
       }
  +
  +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->fname = thefile->fname;
  +        return fill_out_finfo(finfo, info, wanted);
  +    }
       else {
           return errno;
       }
  @@ -140,30 +147,8 @@
   
       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;
  -        finfo->group = info.st_gid;
  -        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;  */
  -
  -        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->fname = 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;
  +        return fill_out_finfo(finfo, info, wanted);
       }
       else {
   #if !defined(ENOENT) || !defined(ENOTDIR)