Re: opendir() failes with trailing \

Cameron Gregory <[email protected]>
Newsgroups gmane.comp.video.gimp.windows.devel
Message-ID <[email protected]>
G'Day,
	For me, I just removed the trailing slash, but 
like you show, network files are hosed.   I'm also led to
believe that in some cases if you have files in the directory
or not can make a difference to some of the calls.
	It could be stat(), depends how opendir() is implemented.
I'm not even really sure which opendir() I'm using.  I assume
the mingw one.

Cameron



David L Norris wrote:
> 
> On Mon, 2002-09-02 at 03:05, Cameron Gregory wrote:
> > So, then opendir files on "plugins" and all the other dirs...
> > My only guess is the current version uses a different opendir()??
> > tor: any insight there?
> 
> stat() on Win32 doesn't work like one might expect; I'd dare say it's
> broken.  Could this be the cause?  Incidentally, I'd love to know how to
> work around stat() problems on Win32.
> 
> Here's what the native Win32 stat() function does (WinXP, VC70):
> 
> E:\projects>stat C:\
> directory 1
> file 0
> 
> E:\projects>stat C:\windows
> directory 1
> file 0
> 
> E:\projects>stat C:\windows\
> directory 0
> file 0
> 
> E:\projects>stat N:\
> directory 1
> file 0
> 
> E:\projects>stat N:\www
> directory 1
> file 0
> 
> E:\projects>stat N:\www\
> directory 0
> file 0
> 
> E:\projects>stat \\daneel\public
> directory 0
> file 0
> 
> E:\projects>stat \\daneel\public\
> directory 1
> file 0
> 
> Test Code:
> 
> #include <stdio.h>
> #include <sys/stat.h>
> 
> int     isdirectory(char *path)
> {
>     struct stat stbuf;
> 
>     if (stat(path, &stbuf))
>         return 0;
>     return ((stbuf.st_mode & S_IFMT) == S_IFDIR) ? 1 : 0;
> }
> 
> int     isfile(char *path)
> {
>     struct stat stbuf;
> 
>     if (stat(path, &stbuf))
>         return 0;
>     return ((stbuf.st_mode & S_IFMT) == S_IFREG) ? 1 : 0;
> }
> 
> int main(int argc, char **argv)
> {
>     printf("directory %d\n", isdirectory( argv[1] ));
>     printf("file %d\n", isfile( argv[1] ));
> }
> 
> --
>  David Norris
>   Dave's Web - http://www.webaugur.com/dave/
>   Augury Net - http://augur.homeip.net/
>   ICQ - 412039
> 
> 
> To Post a message, send it to:   [email protected]
> To Unsubscribe, send a blank message to: [email protected]
> 
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

-- 
Please include previous messages in reply so I can follow the thread.

---------------------------------------------------------------------
Cameron Gregory
http://www.flamingtext.com/
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.