Dostaję ścieżkę do bieżącego katalogu z systemem plików boost, a następnie sprawdzam, czy katalog istnieje.boost :: system plików istnieje() na ścieżce katalogu nie działa, ale is_directory() jest ok.
is_directory()
jest ok, ale exists()
kończy się niepowodzeniem na tej samej ścieżce, czy brakuje mi czegoś?
przykład kod (boost 1,35)
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
namespace fs = boost::filesystem;
// the path is full path /home/my/somedirectory
fs::path data_dir(fs::current_path());
fs::is_directory(data_dir) // true, directory exists
fs::exists(data_dir) // false
exists(status(data_dir)) // false
edycji:
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
namespace fs = boost::filesystem;
fs::path data_dir(fs::current_path());
// data_dir == "/home/myusername/proj/test"
if (fs::is_directory(data_dir)) // true - is directory
if (fs::is_directory(fs::status(data_dir))) // true - it is still a directory
zabawy obróbki:
if (fs::exists(fs::status(data_dir))) // true - directory exists
if (fs::exists(data_dir)) // true - directory exists
Ale:
if (!fs::exists(fs::status(data_dir))) // false - directory still exists
if (!fs::exists(data_dir)) // true - directory does not exists
Czy używasz systemu Windows? Jest to znane ograniczenie podstawowego interfejsu API systemu Windows. –
Działa u mnie w systemie Windows. – interjay