Reputation: 11
I'd like to know if it's possible (no matter why) to pass more than just a filename for existing file to stat() function, so it would not fail and return 0?
I mean like this:
struct stat mystat; char file[100];
...
if(stat(file, &mystat)==0){
//success
}
Is it possible to specify file as "existing-file_some_special_chars_maybe_some-text" and to stat() not fail on that?
Upvotes: 1
Views: 132
Reputation: 1168
How about just creating a list of file names and feeding them to stat()
one by one?
Upvotes: 0
Reputation: 360572
stat()
works on filenames, so if you're passing in something that isn't a filename, you shouldn't be surprised that it fails. You can use fstat()
to get information on whatever file a file handle is pointing to, but otherwise you're stuck with just filenames.
Upvotes: 1