开发者

What is the C++ equivalent of PHP's is_dir()?

开发者 https://www.devze.com 2023-01-12 17:59 出处:网络
What is the C++ equivalent of PHP\'s is_dir() ? http://www.php.net/manual/en/function.is-dir.php bool is_dir ( string $filename )

What is the C++ equivalent of PHP's is_dir() ?

http://www.php.net/manual/en/function.is-dir.php

bool is_dir ( string $filename )

Tells whether the given filename is a directory.

Wor开发者_运维技巧king on a Linux platform only, what library would you use?

And what if cross-platform support mattered, what method would you use?


There is nothing in the C++ standard to deal with filesystems across platforms. For cross platform filesystem access, use the Boost Filesystem library.


The POSIX function lstat (and its less secure friend stat) returns a struct that you can query for that information. A convenience macro is provided: S_ISDIR() man 2 lstat for usage information.

Boost also provides the filesystem library, which provides an easy-to-use set of functions, including the free function is_directory().

0

精彩评论

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