|
IVW_CORE_API FILE * | fopen (const std::string &filename, const char *mode) |
|
IVW_CORE_API std::fstream | fstream (const std::string &filename, std::ios_base::openmode mode=std::ios_base::in|std::ios_base::out) |
|
IVW_CORE_API std::ifstream | ifstream (const std::string &filename, std::ios_base::openmode mode=std::ios_base::in) |
|
IVW_CORE_API std::ofstream | ofstream (const std::string &filename, std::ios_base::openmode mode=std::ios_base::out) |
|
IVW_CORE_API bool | skipByteOrderMark (std::istream &stream) |
|
IVW_CORE_API std::string | getWorkingDirectory () |
|
IVW_CORE_API std::string | getExecutablePath () |
|
IVW_CORE_API std::string | getInviwoUserSettingsPath () |
|
IVW_CORE_API bool | fileExists (const std::string &filePath) |
| Check if a file exists. More...
|
|
IVW_CORE_API bool | directoryExists (const std::string &path) |
|
IVW_CORE_API std::time_t | fileModificationTime (const std::string &filePath) |
| Get last time file was modified. Error can occur if the file does not exist for example. More...
|
|
IVW_CORE_API bool | copyFile (const std::string &src, const std::string &dst) |
| Copy an existing file to a new file. Overwrites existing file. More...
|
|
IVW_CORE_API std::vector< std::string > | getDirectoryContents (const std::string &path, ListMode mode=ListMode::Files) |
|
IVW_CORE_API std::vector< std::string > | getDirectoryContentsRecursively (const std::string &path, ListMode mode=ListMode::Files) |
|
IVW_CORE_API bool | wildcardStringMatch (const std::string &pattern, const std::string &str) |
|
IVW_CORE_API bool | wildcardStringMatchDigits (const std::string &pattern, const std::string &str, int &index, bool matchLess=false, bool matchMore=true) |
|
IVW_CORE_API std::string | getParentFolderWithChildren (const std::string &path, const std::vector< std::string > &childFolders) |
|
IVW_CORE_API std::string | findBasePath () |
|
IVW_CORE_API std::string | getPath (PathType pathType, const std::string &suffix="", const bool createFolder=false) |
|
IVW_CORE_API void | createDirectoryRecursively (std::string path) |
|
IVW_CORE_API std::string | addBasePath (const std::string &url) |
| Adds the InviwoApplication base path before the url. More...
|
|
IVW_CORE_API std::string | getFileDirectory (const std::string &url) |
|
IVW_CORE_API std::string | getFileNameWithExtension (const std::string &url) |
|
IVW_CORE_API std::string | getFileNameWithoutExtension (const std::string &url) |
|
IVW_CORE_API std::string | getFileExtension (const std::string &url) |
|
IVW_CORE_API std::string | replaceFileExtension (const std::string &url, const std::string &newFileExtension) |
|
IVW_CORE_API std::string | getRelativePath (const std::string &basePath, const std::string &absolutePath) |
| Make a path relative to basePath. Requirement: basePath and absulutePath has to be absolute paths. basePath should point at directory. More...
|
|
IVW_CORE_API std::string | getCanonicalPath (const std::string &url) |
|
IVW_CORE_API bool | isAbsolutePath (const std::string &path) |
|
IVW_CORE_API bool | sameDrive (const std::string &refPath, const std::string &queryPath) |
| Checks whether the second path is on the same drive as the first path. More...
|
|
IVW_CORE_API std::string | cleanupPath (const std::string &path) |
| clean up path by replacing backslashes with forward slash and removing surrounding quotes More...
|
|
FILE * inviwo::filesystem::fopen |
( |
const std::string & |
filename, |
|
|
const char * |
mode |
|
) |
| |
Creates and returns a FILE pointer for the given file name (utf-8 encoded). The call auto f = filesystem::fopen(filename, mode);
is functionally equivalent to the statement fopen(filename, mode);
or _wfopen();
, respectively. No checks whether the file exists or was successfully opened are performed. That is the caller has to check it. For more details check the documentation of fopen.
Since all strings within Inviwo are utf-8 encoded, this function should be used to create a file handle when reading from/writing to files.
On Windows, the file name is first converted from a utf-8 string to std::wstring and then the file handle is created using the std::wstring as fopen(const char*) does not support utf-8.
- Parameters
-
filename | utf-8 encoded string |
mode | mode to open the file (input or output) |
- Returns
- file handle for the given file, i.e.
fopen(filename, mode);
- See also
- fopen, _wfopen
std::fstream inviwo::filesystem::fstream |
( |
const std::string & |
filename, |
|
|
std::ios_base::openmode |
mode = std::ios_base::in | std::ios_base::out |
|
) |
| |
Creates and returns a std::fstream for the given file name (utf-8 encoded). The call auto f = filesystem::fstream(filename, mode);
is functionally equivalent to the statement std::fstream f(filename, mode);
. No checks whether the file exists or was successfully opened are performed. That is the caller has to check it. For more details check the documentation of std::fstream.
Since all strings within Inviwo are utf-8 encoded, this function should be used to create a stream when reading from/writing to files using streams.
On Windows, the file name is first converted from a utf-8 string to std::wstring and then the stream is created using the std::wstring as std::fstream(std::string) does not support utf-8.
- Parameters
-
filename | utf-8 encoded string |
mode | mode to open the file (input or output) |
- Returns
- stream for the given file, i.e.
std::fstream(filename, mode);
- See also
- std::fstream
std::ifstream inviwo::filesystem::ifstream |
( |
const std::string & |
filename, |
|
|
std::ios_base::openmode |
mode = std::ios_base::in |
|
) |
| |
Creates and returns a std::ifstream for the given file name (utf-8 encoded). The call auto in = filesystem::ifstream(filename, mode);
is functionally equivalent to the statement std::ifstream in(filename, mode);
. No checks whether the file exists or was successfully opened are performed. That is the caller has to check it. For more details check the documentation of std::ifstream.
Since all strings within Inviwo are utf-8 encoded, this function should be used to create a stream when reading from files using streams.
On Windows, the file name is first converted from a utf-8 string to std::wstring and then the stream is created using the std::wstring as std::ifstream(std::string) does not support utf-8.
- Parameters
-
filename | utf-8 encoded string |
mode | mode to open the file (input or output) |
- Returns
- stream for the given file, i.e.
std::ifstream(filename, mode);
- See also
- std::ifstream
std::ofstream inviwo::filesystem::ofstream |
( |
const std::string & |
filename, |
|
|
std::ios_base::openmode |
mode = std::ios_base::out |
|
) |
| |
Creates and returns a std::ofstream for the given file name (utf-8 encoded). The call auto out = filesystem::ofstream(filename, mode);
is functionally equivalent to the statement std::ofstream out(filename, mode);
. No checks whether the file exists or was successfully opened are performed. That is the caller has to check it. For more details check the documentation of std::ofstream.
Since all strings within Inviwo are utf-8 encoded, this function should be used to create a stream when writing to files using streams.
On Windows, the file name is first converted from a utf-8 string to std::wstring and then the stream is created using the std::wstring as std::ofstream(std::string) does not support utf-8.
- Parameters
-
filename | utf-8 encoded string |
mode | mode to open the file (input or output) |
- Returns
- stream for the given file, i.e.
std::ofstream(filename, mode);
- See also
- std::ofstream
bool inviwo::filesystem::wildcardStringMatchDigits |
( |
const std::string & |
pattern, |
|
|
const std::string & |
str, |
|
|
int & |
index, |
|
|
bool |
matchLess = false , |
|
|
bool |
matchMore = true |
|
) |
| |
Checks whether a given string matches a pattern including digits. The pattern might contain a single sequence of '#' for indicating a number besides '*' matching any string including the empty string and '?' matching a single character.
The digit sequence indicated by '#' is extracted and returned. Depending on the flags, the number have to exactly match sequence or might be shorter (matchLess) or longer (matchMore). For example, the sequence '###' matches only a three-digit number. Enabling 'matchLess' also matches one-digit and two-digit numbers whereas 'matchMore' allows for numbers with more digits.
Examples:
- '###*.jpg' will match all jpeg files starting with a 3-digit sequence. Setting 'matchMore = true' matches the same files, but might extract longer numbers.
- 'myfile#.png' matches all files containing exactly one digit with 'matchMore = false'.
- Parameters
-
pattern | The pattern used for matching, might contain a single sequence of '#' besides '*', and '?' |
str | String which needs to be checked |
index | if the match is successful, this index contains the extracted digit sequence indicated by '#' |
matchLess | allows to match digit sequences shorter than defined by the number of '#' (default false) |
matchMore | allows to match longer digit sequences (default true) |
- Returns
- True if the given string matches the pattern, false otherwise.