aboutsummaryrefslogtreecommitdiff
path: root/butl/filesystem.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2016-12-07 01:22:53 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2016-12-07 11:27:32 +0300
commit3e6110dec6f4cb004b8594b9b798a9db5b08fe7a (patch)
treee27cd6b75386752c7bf5cbe0bb35b55e17ff6c0e /butl/filesystem.cxx
parente7b033d7b38bc55f934521b5f35060b43a8b0526 (diff)
Add path::current(), path::parent()
Diffstat (limited to 'butl/filesystem.cxx')
-rw-r--r--butl/filesystem.cxx18
1 files changed, 12 insertions, 6 deletions
diff --git a/butl/filesystem.cxx b/butl/filesystem.cxx
index 424e361..0643938 100644
--- a/butl/filesystem.cxx
+++ b/butl/filesystem.cxx
@@ -531,14 +531,17 @@ namespace butl
errno = 0;
if (struct dirent* de = readdir (h_))
{
- const char* n (de->d_name);
+ // We can accept some overhead for '.' and '..' (relying on short
+ // string optimization) in favor of a more compact code.
+ //
+ path p (de->d_name);
// Skip '.' and '..'.
//
- if (n[0] == '.' && (n[1] == '\0' || (n[1] == '.' && n[2] == '\0')))
+ if (p.current () || p.parent ())
continue;
- e_.p_ = path (n);
+ e_.p_ = move (p);
e_.t_ = d_type<struct dirent> (de, nullptr);
e_.lt_ = entry_type::unknown;
}
@@ -665,14 +668,17 @@ namespace butl
if (r)
{
- const char* n (fi.name);
+ // We can accept some overhead for '.' and '..' (relying on short
+ // string optimization) in favor of a more compact code.
+ //
+ path p (fi.name);
// Skip '.' and '..'.
//
- if (n[0] == '.' && (n[1] == '\0' || (n[1] == '.' && n[2] == '\0')))
+ if (p.current () || p.parent ())
continue;
- e_.p_ = path (n);
+ e_.p_ = move (p);
// We do not support symlinks at the moment.
//