on windows nl-filesys.c's isFile has a bug

Machine-specific discussion
Unix, Linux, OS X, OS/2, Windows, ..?
Locked
zhanglong
Posts: 9
Joined: Thu Jun 27, 2013 3:58 pm

on windows nl-filesys.c's isFile has a bug

Post by zhanglong »

stat return -1 for string like "d:". But in isFile isDirectory "d:/" is changed to "d:" before transfer to stat, we should check before temporary replace last \ or / to NUL.

maybe change

if (slash == '\\' || slash == '/')
*(fileName + len - 1) = 0;

to

if ((slash == '\\' || slash == '/') && (! (len >= 2 && *(fileName + len - 2) == ':')))
*(fileName + len -1) = 0;

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: on windows nl-filesys.c's isFile has a bug

Post by Lutz »

Thanks Zhanglong, this has been changed for the next version for both isFile() and isDir().

Locked