Mail Archives: djgpp-workers/1996/03/20/04:43:38
On Tue, 19 Mar 1996, Mat Hostetter wrote:
> >>>>> "Eli" == Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> writes:
>
> Eli> Then I'd suggest to test ff_blk.ff_name against the filename
> Eli> part of `path' that you pass to `findfirst', and if they
> Eli> don't match, treat that `else if' clause as if it failed. In
> Eli> your case, you should see if "BADFILE" matches "_BEAUT_DO.S",
> Eli> which fails. I think this isn't too much of a kludge,
> Eli> because I'd expect from a *really* successfull call to return
> Eli> a name that it was asked about, not something else.
>
> Can you send me a patch you want me to try?
Attached. Please note that I didn't have too much time to test it, so
take it with a grain of salt. If anybody out there has access to Win95,
OS/2, network drives of any kind and other wierdnesses, please apply this
patch and tell me how does it work. The best way to test it is to
compile stat.c from the library sources with -DTEST and use the program
that this will generate.
*** stat.c~1 Wed Jan 24 08:30:22 1996
--- stat.c Wed Mar 20 00:53:14 1996
*************** stat_assist(const char *path, struct sta
*** 584,601 ****
}
}
- #ifdef S_IFLABEL
- /* Check for volume label on local drives. Net drives may not support
- this properly. */
- else if (!_is_remote_drive(drv_no) && !__findfirst(path, &ff_blk, FA_LABEL))
- {
- statbuf->st_mode = READ_ACCESS | S_IFLABEL;
- statbuf->st_ino = 1;
- statbuf->st_size = 0;
- dos_ftime = ( (unsigned)ff_blk.ff_fdate << 16 ) + ff_blk.ff_ftime;
- }
- #endif
-
/* Detect root directories. These are special because, unlike
subdirectories, FindFirst fails for them. If you think the
simple test of the string returned by _truename() to have
--- 584,589 ----
*************** stat_assist(const char *path, struct sta
*** 623,629 ****
if (!(p = _truename(root_dir, root_path)) || strcmp(p, canon_path))
{
/* The root is different, or the drive is inaccessible.
! This must be a non-existing file/directory. */
errno = ENOENT; /* FindFirst sets it to ENMFILE */
return -1;
}
--- 611,652 ----
if (!(p = _truename(root_dir, root_path)) || strcmp(p, canon_path))
{
/* The root is different, or the drive is inaccessible.
! This might be a non-existing file/directory or a volume
! label. */
! #ifdef S_IFLABEL
! /* Check for volume labels. We did not mix FA_LABEL with
! other attributes in the call to `__findfirst' above,
! because some environments will return bogus info in
! that case. For instance, Win95 and WinNT seem to
! ignore `path' and return the volume label even if it
! doesn't fit the name in `path'. This fools us to
! think that a non-existent file exists and is a volume
! label. Hence the test for the returned name. */
! if (!__findfirst(path, &ff_blk, FA_LABEL))
! {
! int i = strlen (ff_blk.ff_name) - 1;
! int j = strlen (path) - 1;
!
! if (j > i)
! {
! for ( ; i >= 0 && j >= 0; i--, j--)
! if (toupper(ff_blk.ff_name[i]) != toupper(path[j]))
! break;
! }
!
! if (i < 0
! && (path[j] == '/' || path[j] == '\\' || path[j] == ':'))
! {
! /* Indeed a label. */
! statbuf->st_mode = READ_ACCESS | S_IFLABEL;
! statbuf->st_ino = 1;
! statbuf->st_size = 0;
! dos_ftime =
! ( (unsigned)ff_blk.ff_fdate << 16 ) + ff_blk.ff_ftime;
! goto almost_done;
! }
! }
! #endif
errno = ENOENT; /* FindFirst sets it to ENMFILE */
return -1;
}
*************** stat_assist(const char *path, struct sta
*** 662,667 ****
--- 685,691 ----
}
+ almost_done:
/* Device code. */
statbuf->st_dev = drv_no;
#ifdef HAVE_ST_RDEV
- Raw text -