bpp-core3
3.0.0
|
Some utilitary functions to deal with files. More...
#include <Bpp/Io/FileTools.h>
Public Member Functions | |
FileTools () | |
virtual | ~FileTools () |
Static Public Member Functions | |
static bool | fileExists (const std::string &filename) |
Tells if a file exist. More... | |
static bool | directoryExists (const std::string &path) |
Tells if a directory exist. More... | |
static std::string | getFileName (const std::string &path, char dirSep=DIR_SEP) |
Get the name of of a file, without extension. More... | |
static std::streampos | getFileSize (const std::string &filename) |
Get the size of a file. More... | |
static std::string | getParent (const std::string &path, char dirSep=DIR_SEP) |
Get the path of the parent directry of the given file/dir. More... | |
static std::string | getExtension (const std::string &path) |
Get the extension of a file. More... | |
static std::vector< std::string > | putStreamIntoVectorOfStrings (std::istream &input) |
Reads a stream and write each line in a vector. More... | |
static std::string | getNextLine (std::istream &in) |
Get the next non-blanck line of a stream. More... | |
Static Public Attributes | |
static char | DIR_SEP = '/' |
Some utilitary functions to deal with files.
File paths default to unix, i.e. the directory seprator if '/'. This character is stored in the variable 'DIR_SEP', and hence may be changed by
for windows programs.
Methods dealing with pathes have an optional dirSep argument, which default to DIR_SEP.
Definition at line 31 of file FileTools.h.
|
inline |
Definition at line 37 of file FileTools.h.
|
inlinevirtual |
Definition at line 38 of file FileTools.h.
References directoryExists(), fileExists(), getExtension(), getFileName(), getFileSize(), getNextLine(), getParent(), and putStreamIntoVectorOfStrings().
|
static |
Tells if a directory exist.
NB: this is an alias for fileExists.
path | The path toward the file. |
Definition at line 29 of file FileTools.cpp.
Referenced by ~FileTools().
|
static |
Tells if a file exist.
filename | The path toward the file. |
Definition at line 19 of file FileTools.cpp.
Referenced by bpp::ApplicationTools::getAFilePath(), and ~FileTools().
|
static |
Get the extension of a file.
Example: FileTools::getExtension("/path/file.ext") returns "ext". This method is not recursive, hence FileTools::getExtension("/home/me/archive.tar.gz") returns "gz".
path | A file path. |
Definition at line 86 of file FileTools.cpp.
Referenced by ~FileTools().
|
static |
Get the name of of a file, without extension.
Example: FileTools::getFileName("/path/file.ext") returns "file". This method is not recursive, hence FileTools::getfileName("/home/me/archive.tar.gz") returns "archive".
An empty string is returned if 'path' is not a valid path toward a file.
path | A file path. |
dirSep | The directory separator. |
Definition at line 39 of file FileTools.cpp.
Referenced by ~FileTools().
|
static |
Get the size of a file.
filename | The path toward the file. |
Definition at line 59 of file FileTools.cpp.
Referenced by ~FileTools().
|
static |
Get the next non-blanck line of a stream.
in | Input stream. |
Definition at line 108 of file FileTools.cpp.
References bpp::TextTools::isEmpty().
Referenced by bpp::DataTable::read(), bpp::Table< T >::read(), and ~FileTools().
|
static |
Get the path of the parent directry of the given file/dir.
path | A file/directory path. |
dirSep | The directory separator. |
Definition at line 71 of file FileTools.cpp.
Referenced by ~FileTools().
|
static |
Reads a stream and write each line in a vector.
input | Input stream. |
Definition at line 94 of file FileTools.cpp.
Referenced by ~FileTools().
|
static |
Definition at line 34 of file FileTools.h.