You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by bj...@apache.org on 2001/01/25 12:34:58 UTC

cvs commit: apr/file_io/os2 dir.c filestat.c

bjh         01/01/25 03:34:58

  Modified:    file_io/os2 dir.c filestat.c
  Log:
  Get OS/2 dir & stat code working with current API.
  
  Revision  Changes    Path
  1.23      +17 -34    apr/file_io/os2/dir.c
  
  Index: dir.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/os2/dir.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- dir.c	2001/01/23 04:10:46	1.22
  +++ dir.c	2001/01/25 11:34:53	1.23
  @@ -123,50 +123,33 @@
           rv = DosFindNext(thedir->handle, &thedir->entry, sizeof(thedir->entry), &entries);
       }
   
  -    /* No valid bit flag to test here - do we want one? */
       finfo->cntxt = thedir->cntxt;
       finfo->fname = NULL;
  +    finfo->valid = 0;
   
  -    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)
  -         */
  +    if (rv == 0 && entries == 1) {
           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, 
  +        finfo->csize = thedir->entry.cbFileAlloc;
  +
  +        /* Only directories & regular files show up in directory listings */
  +        finfo->filetype = (thedir->entry.attrFile & FILE_DIRECTORY) ? APR_DIR : APR_REG;
  +
  +        apr_os2_time_to_apr_time(&finfo->mtime, thedir->entry.fdateLastWrite,
                                    thedir->entry.ftimeLastWrite);
  +        apr_os2_time_to_apr_time(&finfo->atime, thedir->entry.fdateLastAccess,
  +                                 thedir->entry.ftimeLastAccess);
  +        apr_os2_time_to_apr_time(&finfo->ctime, thedir->entry.fdateCreation,
  +                                 thedir->entry.ftimeCreation);
  +
           finfo->name = thedir->entry.achName;
  -        if (thedir->entry.attrFile & FILE_DIRECTORY) {
  -            finfo->filetype = APR_DIR;
  -            finfo->valid |= APR_FINFO_TYPE;
  -        }
  -        
  +        finfo->valid = APR_FINFO_NAME | APR_FINFO_MTIME | APR_FINFO_ATIME |
  +            APR_FINFO_CTIME | APR_FINFO_TYPE | APR_FINFO_SIZE |
  +            APR_FINFO_CSIZE;
  +
           return APR_SUCCESS;
       }
   
  
  
  
  1.18      +5 -5      apr/file_io/os2/filestat.c
  
  Index: filestat.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/os2/filestat.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- filestat.c	2001/01/21 15:11:40	1.17
  +++ filestat.c	2001/01/25 11:34:55	1.18
  @@ -75,12 +75,15 @@
       finfo->inode = 0;
       finfo->device = 0;
       finfo->size = fstatus->cbFile;
  +    finfo->csize = fstatus->cbFileAlloc;
       apr_os2_time_to_apr_time(&finfo->atime, fstatus->fdateLastAccess, 
                                fstatus->ftimeLastAccess );
       apr_os2_time_to_apr_time(&finfo->mtime, fstatus->fdateLastWrite,  
                                fstatus->ftimeLastWrite );
       apr_os2_time_to_apr_time(&finfo->ctime, fstatus->fdateCreation,   
                                fstatus->ftimeCreation );
  +    finfo->valid |= APR_FINFO_TYPE | APR_FINFO_PROT | APR_FINFO_SIZE |
  +        APR_FINFO_CSIZE | APR_FINFO_MTIME | APR_FINFO_CTIME | APR_FINFO_ATIME;
   }
   
   
  @@ -160,15 +163,12 @@
       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->valid = APR_FINFO_TYPE | APR_FINFO_PROT;
  +        finfo->protection = 0666;
           finfo->filetype = APR_CHR;
           return APR_SUCCESS;
       }