CppCommon  1.0.4.1
C++ Common Library
path.inl
Go to the documentation of this file.
1 
11 
12 namespace CppCommon {
13 
14 inline bool Path::IsOther() const
15 {
16  FileType t = type();
17  return ((t != FileType::NONE) && (t != FileType::REGULAR) && (t != FileType::DIRECTORY) && (t != FileType::SYMLINK));
18 }
19 
20 inline Path& Path::Assign(const Path& path)
21 {
22  _path = path._path;
23  return *this;
24 }
25 
26 inline Path& Path::Concat(const Path& path)
27 {
28  _path.append(path._path);
29  return *this;
30 }
31 
32 inline void Path::swap(Path& path) noexcept
33 {
34  using std::swap;
35  swap(_path, path._path);
36 }
37 
38 inline void swap(Path& path1, Path& path2) noexcept
39 {
40  path1.swap(path2);
41 }
42 
43 } // namespace CppCommon
44 
45 #if defined(FMT_VERSION)
46 template <>
47 struct fmt::formatter<CppCommon::Path> : formatter<std::string_view>
48 {
49  template <typename FormatContext>
50  auto format(const CppCommon::Path& value, FormatContext& ctx) const
51  {
52  return formatter<string_view>::format(value.string(), ctx);
53  }
54 };
55 #endif
Filesystem path.
Definition: path.h:90
Path & Assign(const Path &path)
Assign the given path to the current one.
Definition: path.inl:20
Path & Concat(const Path &path)
Concatenate the given path to the current one.
Definition: path.inl:26
bool IsOther() const
Is the path points to special file (block, character, FIFO, socket)?
Definition: path.inl:14
void swap(Path &path) noexcept
Swap two instances.
Definition: path.inl:32
FileType type() const
Get the path file type.
Definition: path.cpp:423
const std::string & string() const noexcept
Get the path value as UTF-8 string.
Definition: path.h:151
std::string _path
Path string.
Definition: path.h:376
#define ENUM_FLAGS(type)
Register a new enum-based flags macro.
Definition: flags.h:48
C++ Common project definitions.
Definition: token_bucket.h:15
std::string format(fmt::format_string< T... > pattern, T &&... args)
Format string.
Definition: format.inl:12
FileType
File types.
Definition: path.h:23
@ SYMLINK
Symbolic link.
@ DIRECTORY
Directory.
@ REGULAR
Regular file.
@ NONE
None (file not found)
void swap(FileCache &cache1, FileCache &cache2) noexcept
Definition: filecache.inl:23
void swap(Path &path1, Path &path2) noexcept
Definition: path.inl:38
FilePermissions
File permissions (Unix specific)
Definition: path.h:51
FileAttributes
File attributes (Windows specific)
Definition: path.h:37