Bug in unix apr_stat involving the name field.

2004-09-20 Thread Scott Greig

The following works on win32 but not on linux.  Looks like the name field of
apr_file_t is never set on unix so the value is garbage.  


apr_file_t finfo;
apr_status_t s = apr_stat(finfo, filename,
  APR_FINFO_NAME |
  APR_FINFO_SIZE,
  pool);

if (s == APR_SUCCESS)
{
   std::cout  Path+Name:   finfo.fname  std::endl;
   std::cout  Name:   finfo.name  std::endl;
   std::cout  Size:   finfo.size  std::endl;
}


I'm using apr-1.0.0

Thanks,
Scott Greig
Altair Engineering, Inc.


Re: Bug in unix apr_stat involving the name field.

2004-09-20 Thread William A. Rowe, Jr.
At 11:53 AM 9/20/2004, you wrote:

The following works on win32 but not on linux.  Looks like the name field of
apr_file_t is never set on unix so the value is garbage.  

are you testing the .valid bit APR_FINFO_FNAME value?

There are scenarios on every platform when specific fields
cannot be set, it's important to check the .valid bits.

If apr_stat(, APR_FINFO_NAME, poll) returns APR_SUCCESS, that
would be a bug, the correct return code is APR_INCOMPLETE.

It would be -totally- wrong to just stuff the name passed for
Unix, because some Unix file systems, e.g. mounted from Samba, 
HFS (Mac OS), and others can return another file from a 
non-canonical name.

Bill




RE: Bug in unix apr_stat involving the name field.

2004-09-20 Thread Scott Greig
I had fixed my problem by memset-ing my apr_finfo_t to 0 before calling
apr_stat, then checking for a non-null name before using it.

I was not testing for the valid bit, I'll change to this method.

So apr_stat is working correctly. 

Thanks for the information.
- Scott


-Original Message-
From: William A. Rowe, Jr. [mailto:[EMAIL PROTECTED] 
Sent: Monday, September 20, 2004 1:39 PM
To: Scott Greig
Cc: dev@apr.apache.org
Subject: Re: Bug in unix apr_stat involving the name field.

At 11:53 AM 9/20/2004, you wrote:

The following works on win32 but not on linux.  Looks like the name field
of
apr_finfo_t is never set on unix so the value is garbage.  

are you testing the .valid bit APR_FINFO_FNAME value?

There are scenarios on every platform when specific fields
cannot be set, it's important to check the .valid bits.

If apr_stat(, APR_FINFO_NAME, poll) returns APR_SUCCESS, that
would be a bug, the correct return code is APR_INCOMPLETE.

It would be -totally- wrong to just stuff the name passed for
Unix, because some Unix file systems, e.g. mounted from Samba, 
HFS (Mac OS), and others can return another file from a 
non-canonical name.

Bill