Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: strange stat behavior
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: strange stat behavior



i know that d_name only returns the name.... the weird part is just that it shouldn't work without giving lstat an absolute path, like you said... but it works on solaris 7; specifically, if the directory that's given as the argument is within the path of the cwd, the code works correctly [it shouldn't]. for example. if you put that program in a directory, say, 3 directories deep in your home directory, and invoke it with just ~, it works correctly, even though that directory is 3 levels higher.

on BSD systems, or at least on freebsd and darwin, the same code fails calling lstat after . & .. , like it should.

very weird, ya?

adam

On Saturday, February 15, 2003, at 12:51 AM, Lally Singh wrote:

lstat doesn't care about PATH.  the source below, modified
so that it compiles, runs fine from the command line.  My point
was that d_name is just the filename, not the full path to the
file.  So, lstat looks in the current working directory.  As
the code originally listed did _not_ change the current working
directory, it wouldn't look in the directory specified in
argv[1] unless it was also coincidentally the current working
directory.  Use chdir(argv[1]) to set the current working directory
to argv[1].
_______________________________________________
studentdev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/studentdev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: strange stat behavior (From: Lally Singh <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.