NGen
|
Simple utility class for testing things about one or more files. More...
#include <FileChecker.h>
Static Public Member Functions | |
static bool | file_can_be_written (std::string path) |
Get whether a write to a file at the given path is permitted. | |
static bool | file_is_empty (const std::string &path) |
Checks whether a file is empty. | |
static bool | file_is_readable (std::string path) |
Check whether the path provided points to an existing, readable file. | |
static bool | file_is_readable (const std::string &path, const std::string &description) |
Check whether the path provided points to an existing, readable file, printing a message when it does not. | |
static std::string | find_first_accessible (std::string mode, std::vector< std::string > paths) |
Find the first file path in a provided collection that points to an existing file accessible as specified, proceeding through the collection in indexed order. | |
static std::string | find_first_readable (std::vector< std::string > paths) |
Find the first file path in a provided collection that points to an existing, readable file, proceeding through the collection in indexed order. | |
Simple utility class for testing things about one or more files.
|
inlinestatic |
Get whether a write to a file at the given path is permitted.
Get whether the given file can be written to. To be true, the file must either already exist and have permissions that allow it to be written to, or the file must not exist and the parent directory permissions must allow for a new file to be created and written to.
path | The relative or absolute filesystem path of interest, as a string. |
References file_is_empty(), and file_is_readable().
|
inlinestatic |
Checks whether a file is empty.
Function assumes the given file exists and will return false
if it cannot open the file.
path | The relative or absolute filesystem path of interest, as a string. |
Referenced by file_can_be_written().
|
inlinestatic |
Check whether the path provided points to an existing, readable file, printing a message when it does not.
The only difference between this and the overloaded function of the same name with a single parameter is this function may also print a message. When a file is found to not be readable, a message indicating this is sent to stdout, with its format being: <description> path <path> not readable
For example, if description
is 'Configuration file' and path
is '/home/user/file.txt', then the text 'Configuration file path /home/user/file.txt not readable' is sent to stdout.
path | The relative or absolute filesystem path of interest, as a string. |
description | A name or description of file to make a printed message more informative. |
References file_is_readable().
|
inlinestatic |
Check whether the path provided points to an existing, readable file.
path | The relative or absolute filesystem path of interest, as a string. |
Referenced by models::bmi::Bmi_Adapter::Bmi_Adapter(), models::bmi::AbstractCLibBmiAdapter::dynamic_library_load(), file_can_be_written(), file_is_readable(), and models::bmi::Bmi_Adapter::Initialize().
|
inlinestatic |
Find the first file path in a provided collection that points to an existing file accessible as specified, proceeding through the collection in indexed order.
mode | The accessibility mode that the file must be accessible with, as used with fopen . |
paths | A vector of potential file paths, as strings. |
Referenced by find_first_readable().
|
inlinestatic |
Find the first file path in a provided collection that points to an existing, readable file, proceeding through the collection in indexed order.
paths | A vector of potential file paths, as strings. |
References find_first_accessible().
Referenced by MultiLayerParserTest::find_file().