libdigidocpp
|
#include <File.h>
Static Public Member Functions | |
static std::string | env (const std::string &varname) |
static std::string | cwd () |
static bool | fileExists (const std::string &path) |
static bool | directoryExists (const std::string &path) |
static f_string | encodeName (const std::string &fileName) |
static std::string | decodeName (const f_string &localFileName) |
static bool | isRelative (const std::string &path) |
static tm * | modifiedTime (const std::string &path) |
static std::string | fileName (const std::string &path) |
static std::string | directory (const std::string &path) |
static std::string | path (const std::string &directory, const std::string &relativePath, bool unixStyle=false) |
static std::string | fullPathUrl (const std::string &fullDirectory, const std::string &relativeFilePath) |
static std::string | tempFileName () |
static std::string | tempDirectory () |
static void | createDirectory (const std::string &path) throw (IOException) |
static std::string | createTempDirectory () throw (IOException) |
static unsigned long | fileSize (const std::string &path) throw (IOException) |
static std::vector< std::string > | listFiles (const std::string &directory, bool relative=false, bool listEmptyDirectories=false, bool unixStyle=false) throw (IOException) |
static void | copyFile (const std::string &srcPath, const std::string &destPath, bool overwrite=true) throw (IOException) |
static void | moveFile (const std::string &srcPath, const std::string &destPath, bool overwrite=true) throw (IOException) |
static void | removeFile (const std::string &fname) |
static void | removeDirectory (const std::string &fname) |
static void | deleteTempFiles () throw (IOException) |
static void | removeDirectoryRecursively (const std::string &dname) throw (IOException) |
static bool | compareUri (const std::string &a, const std::string &b) |
static std::string | fromUri (const std::string &uri) |
static std::string | toUri (const std::string &path) |
static FILE * | fopen (const std::string &filename, const std::string &mode) |
Static Public Attributes | |
static std::stack< std::string > | tempFiles |
Static Private Member Functions | |
static std::vector< std::string > | getDirSubElements (const std::string &directory, bool relative, bool filesOnly, bool unixStyle) throw (IOException) |
static std::string | convertUTF8 (const std::string &str_in, bool to_UTF) |
|
static |
Definition at line 890 of file File.cpp.
References hexToUpper().
Referenced by digidoc::SignatureBES::checkReferencesToDocs().
|
staticprivate |
Helper method for converting from non-UTF-8 encoded strings to UTF-8. Supported LANG values for Linux: see /usr/share/i18n/SUPPORTED. Supported encodings for libiconv: see iconv –list .
Note! If non-ASCII characters are used we assume a proper LANG value!!!
str_in | The string to be converted. |
|
static |
Copies file from source srcPath
to destination destPath
.
srcPath | source full file path. |
destPath | destination full file path. |
overwrite | whether to overwrite existing file. |
IOException | exception is thrown if overwrite flag is set to false and destination file already exists. Or the file copy operation failed. |
Definition at line 576 of file File.cpp.
References THROW_IOEXCEPTION.
Referenced by digidoc::Document::saveAs().
|
static |
Creates directory recursively. Also access rights can be omitted. Defaults are 700 in unix.
path | full path of the directory created. |
mode | directory access rights, optional parameter, default value 0700 (owner: rwx, group: —, others: —) |
IOException | exception is thrown if the directory creation failed. |
Definition at line 404 of file File.cpp.
References DEBUG, f_string, and THROW_IOEXCEPTION.
Referenced by digidoc::ZipSerializePrivate::extractCurrentFile(), and digidoc::XmlConfPrivate::serializeUserConf().
|
static |
Creates temporary directory.
IOException | throws exception if the directory creation failed. |
Definition at line 454 of file File.cpp.
Referenced by digidoc::ZipSerialize::extract(), and digidoc::DDoc::loadFile().
|
static |
Definition at line 145 of file File.cpp.
Referenced by digidoc::XmlConf::getDefaultConfDir().
|
static |
Decodes path from std lib path
localFileName | path |
Definition at line 243 of file File.cpp.
Referenced by decodeParameter(), digidoc::BDoc::parseManifestAndLoadFiles(), and digidoc::XmlConfPrivate::XmlConfPrivate().
|
static |
Tries to delete all temporary files and directories whose names were handled out with tempFileName, tempDirectory and createTempDirectory. The deletion of directories is recursive.
Definition at line 834 of file File.cpp.
Referenced by digidoc::terminate().
|
static |
Parses file path and returns directory from file full path.
path | full path of the file. |
Definition at line 326 of file File.cpp.
References PATH_DELIMITER.
Referenced by digidoc::ZipSerializePrivate::extractCurrentFile(), digidoc::XmlConf::getDefaultConfDir(), and digidoc::XmlConf::getUserConfDir().
|
static |
Checks whether directory exists and is type of directory.
path | path to the directory, which existence is checked. |
Definition at line 273 of file File.cpp.
References f_stat, f_statbuf, and f_string.
Referenced by digidoc::DirectoryX509CertStore::loadCerts(), and digidoc::XmlConfPrivate::serializeUserConf().
|
static |
Encodes path to compatible std lib
fileName | path |
Definition at line 205 of file File.cpp.
Referenced by digidoc::BDoc::addSignature(), digidoc::DDoc::addSignature(), digidoc::Document::calcDigest(), digidoc::BDoc::createManifest(), digidoc::BDoc::createMimetype(), digidoc::Log::dbgPrintfMemImpl(), digidoc::ZipSerialize::extract(), digidoc::Log::out(), digidoc::BDoc::readMimetype(), digidoc::ZipSerialize::save(), digidoc::Signature::saveToXml(), digidoc::XmlConfPrivate::serializeUserConf(), and digidoc::CNGSigner::setPin().
|
static |
Definition at line 159 of file File.cpp.
References f_string.
Referenced by digidoc::XmlConfPrivate::XmlConfPrivate().
|
static |
Checks whether file exists and is type of file.
path | path to the file, which existence is checked. |
Definition at line 253 of file File.cpp.
References f_stat, f_statbuf, and f_string.
Referenced by digidoc::BDoc::addDocument(), digidoc::BDoc::parseManifestAndLoadFiles(), digidoc::XmlConf::setOCSP(), digidoc::XmlConfPrivate::setUserConf(), and digidoc::XmlConf::XmlConf().
|
static |
Parses file path and returns file name from file full path.
path | full path of the file. |
Definition at line 314 of file File.cpp.
Referenced by digidoc::BDoc::parseManifestAndLoadFiles().
|
static |
Checks that file is a file and it exists, if the file exists returns its size in bytes.
path | full path of the file. |
IOException | throws exception if the file does not exists. |
Definition at line 468 of file File.cpp.
References f_stat, f_statbuf, f_string, and THROW_IOEXCEPTION.
Referenced by digidoc::Document::getSize().
|
static |
Definition at line 750 of file File.cpp.
References f_fopen.
Referenced by digidoc::ZipSerializePrivate::extractCurrentFile(), and digidoc::ZipSerialize::save().
|
static |
|
static |
Constructs the full file path in the format "file:///fullpath" in URI encoding.
fullDirectory | full directory path to the relativeFilePath |
relativeFilePath | file name to be appended to the full path |
Definition at line 763 of file File.cpp.
References toUri().
Referenced by digidoc::XmlConf::getDsigXsdPath(), digidoc::XmlConf::getManifestXsdPath(), and digidoc::XmlConf::getXadesXsdPath().
|
staticprivate |
Lists files or sub directories in directory. If flag filesOnly
is set to true
returns ONLY files, otherwise returns ONLY directories.
directory | full path of the directory. |
relative | should the returned file list be relative to the directory . |
filesOnly | if set to true , returns only files, otherwise returns only directories. |
unixStyle | should the returned file path entries in the file list use the unix style path separators. |
IOException | throws exception if the directory listing failed. |
Definition at line 652 of file File.cpp.
References FALSE, INVALID_HANDLE_VALUE, and THROW_IOEXCEPTION.
|
static |
Returns true if the path is relative
Definition at line 489 of file File.cpp.
References f_string.
Referenced by digidoc::XmlConf::getCertStorePath().
|
static |
Returns list of files (and empty directories, if listEmptyDirectories
is set) found in the directory directory
.
directory | full path of the directory. |
relative | should the returned file list be relative to the directory . Default value is false , meaning returned file listing has full file paths. |
listEmptyDirectories | should the returned file list contain also empty directories. Default value is false , meaning no empty directories are returned. |
unixStyle | should the returned file path entries in the file list use the unix style path separators. Default value is false , meaning operating system specific path separators are used. |
IOException | throws exception if the directory listing failed. |
Definition at line 519 of file File.cpp.
References PATH_DELIMITER.
Referenced by digidoc::DirectoryX509CertStore::loadCerts(), and digidoc::BDoc::parseManifestAndLoadFiles().
|
static |
|
static |
Moves file from source srcPath
to destination destPath
.
srcPath | source full file path. |
destPath | destination full file path. |
overwrite | whether to overwrite existing file. |
IOException | exception is thrown if overwrite flag is set to false and destination file already exists. Or the file move operation failed. |
Definition at line 612 of file File.cpp.
References f_remove, f_rename, f_string, THROW_IOEXCEPTION, and WARN.
Referenced by digidoc::ZipSerialize::save().
|
static |
Creates full path from directory name and relative path.
directory | directory path. |
relativePath | relative path. |
unixStyle | when set to true returns path with unix path separators, otherwise returns with operating system specific path separators. Default value is false . |
Definition at line 343 of file File.cpp.
References PATH_DELIMITER.
Referenced by digidoc::DDocLibrary::DDocLibrary(), digidoc::ZipSerializePrivate::extractCurrentFile(), digidoc::XmlConf::getCertStorePath(), digidoc::DDoc::loadFile(), digidoc::BDoc::parseManifestAndLoadFiles(), digidoc::XmlConfPrivate::read(), digidoc::BDoc::readMimetype(), and digidoc::XmlConfPrivate::serializeUserConf().
|
static |
|
static |
|
static |
|
static |
Definition at line 392 of file File.cpp.
References PATH_DELIMITER.
|
static |
Definition at line 371 of file File.cpp.
References THROW_IOEXCEPTION.
Referenced by digidoc::BDoc::addSignature(), digidoc::DDoc::addSignature(), digidoc::Signature::calcDigestOnNode(), digidoc::BDoc::createManifest(), digidoc::BDoc::createMimetype(), digidoc::ZipSerialize::save(), and digidoc::Signature::saveToXml().
|
static |
Helper method for converting strings with non-ascii characters to the URI format (HH for each non-ascii character).
Not converting: (From RFC 2396 "URI Generic Syntax") reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | "," mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"
str_in | the string to be converted |
Definition at line 856 of file File.cpp.
References i.
Referenced by digidoc::SignatureBES::checkReferencesToDocs(), fullPathUrl(), and digidoc::SignatureBES::prepareSignedInfo().
|
static |