#include <file.hpp>
Definition at line 18 of file file.hpp.
◆ FilePath() [1/3]
| jlm::util::FilePath::FilePath |
( |
const std::string & |
path | ) |
|
|
inlineexplicit |
◆ FilePath() [2/3]
| jlm::util::FilePath::FilePath |
( |
const FilePath & |
other | ) |
|
|
inline |
◆ FilePath() [3/3]
| jlm::util::FilePath::FilePath |
( |
FilePath && |
other | ) |
|
|
inlinenoexcept |
◆ base()
| std::string jlm::util::FilePath::base |
( |
| ) |
const |
|
inlinenoexcept |
Returns the base name of the file without the path.
Example: jlm::file f("/tmp/archive.tar.gz"); auto base = f.base(); // base = "archive"
Definition at line 61 of file file.hpp.
◆ complete_suffix()
| std::string jlm::util::FilePath::complete_suffix |
( |
| ) |
const |
|
inlinenoexcept |
Returns the complete suffix (extension) of the file.
Example: jlm::file f("/tmp/archive.tar.gz"); auto ext = f.complete_suffix(); // ext = "tar.gz"
Definition at line 98 of file file.hpp.
◆ CreateDirectory()
| void jlm::util::FilePath::CreateDirectory |
( |
| ) |
const |
|
inline |
Creates the directory represented by this file path object. The parent directory must already exist. The directory can also exist already, in which case this is a no-op.
- Exceptions
-
| jlm::util::error | if an error occurs |
Definition at line 258 of file file.hpp.
◆ createUniqueFileName()
| static FilePath jlm::util::FilePath::createUniqueFileName |
( |
const FilePath & |
directory, |
|
|
const std::string & |
fileNamePrefix, |
|
|
const std::string & |
fileNameSuffix |
|
) |
| |
|
inlinestatic |
Generates a unique file in a given directory with a prefix and suffix.
- Parameters
-
| directory | The directory in which the file is created. |
| fileNamePrefix | The file name prefix. |
| fileNameSuffix | The file name suffix. |
- Returns
- A unique file
Definition at line 301 of file file.hpp.
◆ Dirname()
| FilePath jlm::util::FilePath::Dirname |
( |
| ) |
const |
|
inlinenoexcept |
Returns the path to the file or directory's parent directory. Emulates the behavior of the GNU coreutil "dirname".
If the current path does not contain a parent directory, either "/" or "." is returned, depending on whether this is an absolute or relative path.
This function does not respect ".." and instead treats it like any other folder.
Examples: "/tmp/archive.tar.gz" => "/tmp" "/tmp/jlm/" => "/tmp" "/a" => "/" "a/.." => "a" "dir/file.txt" => "dir" "test.txt" => "." Special cases: "/" => "/" "." => "." "" => "."
Definition at line 148 of file file.hpp.
◆ Exists()
| bool jlm::util::FilePath::Exists |
( |
| ) |
const |
|
inlinenoexcept |
Determines whether the file path exists.
- Returns
- True if the file path exists, otherwise false.
Definition at line 222 of file file.hpp.
◆ IsDirectory()
| bool jlm::util::FilePath::IsDirectory |
( |
| ) |
const |
|
inlinenoexcept |
Determines whether file path is a directory.
- Returns
- True if the file path is a directory, otherwise false.
Definition at line 233 of file file.hpp.
◆ isFile()
| bool jlm::util::FilePath::isFile |
( |
| ) |
const |
|
inlinenoexcept |
Determines whether file path is a file.
- Returns
- True if the file path is a file, otherwise false.
Definition at line 244 of file file.hpp.
◆ Join() [1/2]
◆ Join() [2/2]
| FilePath jlm::util::FilePath::Join |
( |
const std::string & |
other | ) |
const |
|
inline |
Creates a new file path this / other.
If other is an absolute path, the this-part is completely ignored. What constitutes an absolute path is platform specific.
Any "." or ".." in paths are kept as is. Except if the this-part is equal to ".", in which case other is returned directly.
Examples: "/tmp/" join "a.txt" => "/tmp/a.txt" "a/b" join "c/d" => "a/b/c/d" "a/b" join "/tmp/x" => "/tmp/x" "." join "e.txt" => "e.txt" "" join "e.txt" => "e.txt" "a/." join "../e.txt" => "a/./../e.txt"
- Parameters
-
| other | the second part of the path |
- Returns
- the joined file path
Definition at line 193 of file file.hpp.
◆ name()
| std::string jlm::util::FilePath::name |
( |
| ) |
const |
|
inlinenoexcept |
Returns the name of the file, excluding the path.
Example: jlm::file f("/tmp/archive.tar.gz"); auto name = f.name(); // name = "archive.tar.gz"
- Returns
- The name of the file
Definition at line 81 of file file.hpp.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ operator==() [1/2]
| bool jlm::util::FilePath::operator== |
( |
const FilePath & |
other | ) |
const |
|
inlinenoexcept |
◆ operator==() [2/2]
| bool jlm::util::FilePath::operator== |
( |
const std::string & |
f | ) |
const |
|
inlinenoexcept |
◆ suffix()
| std::string jlm::util::FilePath::suffix |
( |
| ) |
const |
|
inlinenoexcept |
Returns the suffix (extension) of the file.
Example: jlm::file f("/tmp/archive.tar.gz"); auto ext = f.suffix(); // ext = "gz"
Definition at line 116 of file file.hpp.
◆ TempDirectoryPath()
| static FilePath jlm::util::FilePath::TempDirectoryPath |
( |
| ) |
|
|
inlinestatic |
- Returns
- a directory suitable for temporary files
Definition at line 317 of file file.hpp.
◆ to_str()
| const std::string& jlm::util::FilePath::to_str |
( |
| ) |
const |
|
inlinenoexcept |
◆ WithSuffix()
| FilePath jlm::util::FilePath::WithSuffix |
( |
const std::string & |
suffix | ) |
const |
|
inline |
Creates a new file path by adding the given suffix
- Returns
- the new file path
Definition at line 211 of file file.hpp.
◆ path_
| std::string jlm::util::FilePath::path_ |
|
private |
The documentation for this class was generated from the following file: