fs/Traits: add constant CURRENT_DIRECTORY

This commit is contained in:
Max Kellermann 2015-02-25 19:13:58 +01:00
parent 81c49fba03
commit e3908c8de6
3 changed files with 7 additions and 2 deletions

View File

@ -47,7 +47,8 @@ CheckDirectoryReadable(Path path_fs)
} }
#ifndef WIN32 #ifndef WIN32
const auto x = AllocatedPath::Build(path_fs, "."); const auto x = AllocatedPath::Build(path_fs,
PathTraitsFS::CURRENT_DIRECTORY);
if (!StatFile(x, st) && errno == EACCES) if (!StatFile(x, st) && errno == EACCES)
FormatError(config_domain, FormatError(config_domain,
"No permission to traverse (\"execute\") directory: %s", "No permission to traverse (\"execute\") directory: %s",

View File

@ -74,7 +74,7 @@ GetParentPathImpl(typename Traits::const_pointer p)
typename Traits::const_pointer sep = Traits::FindLastSeparator(p); typename Traits::const_pointer sep = Traits::FindLastSeparator(p);
if (sep == nullptr) if (sep == nullptr)
return typename Traits::string("."); return typename Traits::string(Traits::CURRENT_DIRECTORY);
if (sep == p) if (sep == p)
return typename Traits::string(p, p + 1); return typename Traits::string(p, p + 1);
#ifdef WIN32 #ifdef WIN32

View File

@ -47,6 +47,8 @@ struct PathTraitsFS {
static constexpr value_type SEPARATOR = '/'; static constexpr value_type SEPARATOR = '/';
#endif #endif
static constexpr const_pointer CURRENT_DIRECTORY = ".";
static constexpr bool IsSeparator(value_type ch) { static constexpr bool IsSeparator(value_type ch) {
return return
#ifdef WIN32 #ifdef WIN32
@ -149,6 +151,8 @@ struct PathTraitsUTF8 {
static constexpr value_type SEPARATOR = '/'; static constexpr value_type SEPARATOR = '/';
static constexpr const_pointer CURRENT_DIRECTORY = ".";
static constexpr bool IsSeparator(value_type ch) { static constexpr bool IsSeparator(value_type ch) {
return ch == SEPARATOR; return ch == SEPARATOR;
} }