|
TECA
The Toolkit for Extreme Climate Analysis
|
Codes dealing with low level file system API's. More...
Classes | |
| struct | line_buffer |
Functions | |
| int | read_stream (const char *file_name, const char *header, teca_binary_stream &stream, bool verbose=true) |
| int | write_stream (const char *file_name, int flags, const char *header, const teca_binary_stream &stream, bool verbose=true) |
| void | replace_timestep (std::string &file_name, unsigned long time_step, int width=6) |
| replace t% with the given value More... | |
| int | replace_time (std::string &file_name, double t, const std::string &calendar, const std::string &units, const std::string &format) |
| replace t% with the time t in calendar with units in the strftime format More... | |
| void | replace_extension (std::string &file_name, const std::string &ext) |
| replace e% with the given string More... | |
| void | replace_identifier (std::string &file_name, const std::string &id) |
| replace s% with the given string More... | |
| void | to_lower (std::string &in) |
| return string converted to lower case More... | |
| int | file_exists (const char *path) |
| return 0 if the file does not exist More... | |
| int | file_writable (const char *path) |
| return 0 if the file/directory is not writeable More... | |
| std::string | path (const std::string &filename) |
| std::string | base_filename (const std::string &filename) |
| std::string | filename (const std::string &filename) |
| std::string | extension (const std::string &filename) |
| Returns the extension from the given filename. More... | |
| size_t | load_lines (const char *filename, std::vector< std::string > &lines) |
| read the lines of the ascii file into a vector More... | |
| size_t | load_text (const std::string &filename, std::string &text) |
| read the file into a string More... | |
| int | write_text (std::string &filename, std::string &text) |
| write the string to the named file More... | |
| int | search_and_replace (const std::string &search_for, const std::string &replace_with, std::string &in_text) |
| Search and replace with in a string of text. More... | |
| int | locate_files (const std::string &path, const std::string &re, std::vector< std::string > &file_list) |
| Locate files in path that match a regular expression. More... | |
| template<typename T > | |
| size_t | load_bin (const char *filename, size_t dlen, T *buffer) |
| Load a binary file into memory. More... | |
| template<typename T > | |
| int | name_value (std::vector< std::string > &lines, std::string name, T &value) |
| extract a name-value pair from the given set of lines. More... | |
| template<typename T > | |
| size_t | parse_value (std::string &in, size_t at, std::string key, T &value) |
Codes dealing with low level file system API's.
| std::string teca_file_util::base_filename | ( | const std::string & | filename | ) |
Returns the file name not including the extension (ie what ever is after the last ".". If there is no "." then the filename is returned unmodified.
| std::string teca_file_util::extension | ( | const std::string & | filename | ) |
Returns the extension from the given filename.
| int teca_file_util::file_exists | ( | const char * | path | ) |
return 0 if the file does not exist
| int teca_file_util::file_writable | ( | const char * | path | ) |
return 0 if the file/directory is not writeable
| std::string teca_file_util::filename | ( | const std::string & | filename | ) |
Returns the file name from the given path. If PATH_SEP isn't found then the filename is returned unmodified.
| size_t teca_file_util::load_bin | ( | const char * | filename, |
| size_t | dlen, | ||
| T * | buffer | ||
| ) |
Load a binary file into memory.
| size_t teca_file_util::load_lines | ( | const char * | filename, |
| std::vector< std::string > & | lines | ||
| ) |
read the lines of the ascii file into a vector
| size_t teca_file_util::load_text | ( | const std::string & | filename, |
| std::string & | text | ||
| ) |
read the file into a string
| int teca_file_util::locate_files | ( | const std::string & | path, |
| const std::string & | re, | ||
| std::vector< std::string > & | file_list | ||
| ) |
Locate files in path that match a regular expression.
| int teca_file_util::name_value | ( | std::vector< std::string > & | lines, |
| std::string | name, | ||
| T & | value | ||
| ) |
extract a name-value pair from the given set of lines.
| size_t teca_file_util::parse_value | ( | std::string & | in, |
| size_t | at, | ||
| std::string | key, | ||
| T & | value | ||
| ) |
Parse a string for a "key", starting at offset "at" then advance past the key and attempt to convert what follows in to a value of type "T". If the key isn't found, then npos is returned otherwise the position imediately following the key is returned.
| std::string teca_file_util::path | ( | const std::string & | filename | ) |
Returns the path not including the file name and not including the final PATH_SEP. If PATH_SEP isn't found then ".PATH_SEP" is returned.
| int teca_file_util::read_stream | ( | const char * | file_name, |
| const char * | header, | ||
| teca_binary_stream & | stream, | ||
| bool | verbose = true |
||
| ) |
read the file into a stream. if header is not null the call will fail if the given string is not found. return zero upon success. The verbose flag indicates whether or not an error is reported if opening the file fails. All other errors are always reported.
| void teca_file_util::replace_extension | ( | std::string & | file_name, |
| const std::string & | ext | ||
| ) |
replace e% with the given string
| void teca_file_util::replace_identifier | ( | std::string & | file_name, |
| const std::string & | id | ||
| ) |
replace s% with the given string
| int teca_file_util::replace_time | ( | std::string & | file_name, |
| double | t, | ||
| const std::string & | calendar, | ||
| const std::string & | units, | ||
| const std::string & | format | ||
| ) |
replace t% with the time t in calendar with units in the strftime format
| void teca_file_util::replace_timestep | ( | std::string & | file_name, |
| unsigned long | time_step, | ||
| int | width = 6 |
||
| ) |
replace t% with the given value
| int teca_file_util::search_and_replace | ( | const std::string & | search_for, |
| const std::string & | replace_with, | ||
| std::string & | in_text | ||
| ) |
Search and replace with in a string of text.
| void teca_file_util::to_lower | ( | std::string & | in | ) |
return string converted to lower case
| int teca_file_util::write_stream | ( | const char * | file_name, |
| int | flags, | ||
| const char * | header, | ||
| const teca_binary_stream & | stream, | ||
| bool | verbose = true |
||
| ) |
write the stream to the file. the passed in flags control file access, a reasonable value is S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH. if header is not null the given string is prepended to the file. return zero upon success. The verbose flag indicates whether or not an error is reported if creating the file fails. All other errors are reported.
| int teca_file_util::write_text | ( | std::string & | filename, |
| std::string & | text | ||
| ) |
write the string to the named file