augustin
augustin

Reputation: 14729

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

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.

Working on a Linux platform only, what library would you use?

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

Upvotes: 2

Views: 1928

Answers (2)

greyfade
greyfade

Reputation: 25647

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().

Upvotes: 4

Grant Limberg
Grant Limberg

Reputation: 21363

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

Upvotes: 7

Related Questions