CppCommon 1.0.5.0
C++ Common Library
Loading...
Searching...
No Matches
path.inl
Go to the documentation of this file.
1
11
12namespace CppCommon {
13
14inline 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
20inline Path& Path::Assign(const Path& path)
21{
22 _path = path._path;
23 return *this;
24}
25
26inline Path& Path::Concat(const Path& path)
27{
28 _path.append(path._path);
29 return *this;
30}
31
32inline void Path::swap(Path& path) noexcept
33{
34 using std::swap;
35 swap(_path, path._path);
36}
37
38inline void swap(Path& path1, Path& path2) noexcept
39{
40 path1.swap(path2);
41}
42
43} // namespace CppCommon
44
45#if defined(FMT_VERSION)
46template <>
47struct 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
friend void swap(Path &path1, Path &path2) noexcept
Definition path.inl:38
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
FileType type() const
Get the path file type.
Definition path.cpp:423
std::string _path
Path string.
Definition path.h:376
const std::string & string() const noexcept
Get the path value as UTF-8 string.
Definition path.h:151
#define ENUM_FLAGS(type)
Register a new enum-based flags macro.
Definition flags.h:48
C++ Common project definitions.
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
FilePermissions
File permissions (Unix specific)
Definition path.h:51
FileAttributes
File attributes (Windows specific)
Definition path.h:37