开发者

Pass more than filename argument to stat()?

开发者 https://www.devze.com 2023-03-26 11:46 出处:网络
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'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];
.开发者_如何学Python..
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?


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.


How about just creating a list of file names and feeding them to stat() one by one?

0

精彩评论

暂无评论...
验证码 换一张
取 消