30 #ifndef __TERRALIB_CORE_FILESYSTEM_FILESYSTEM_H__
31 #define __TERRALIB_CORE_FILESYSTEM_FILESYSTEM_H__
34 #include "../Config.h"
42 #include <boost/thread/mutex.hpp>
89 const std::string& format =
"%%%%-%%%%-%%%%-%%%%");
116 static std::string
fileName(
const std::string& path);
125 static std::string
stem(
const std::string& path);
177 static bool exists(
const std::string& path);
204 static void copyFile(
const std::string& from,
const std::string& to);
216 static bool remove(
const std::string& path);
224 static void rename(
const std::string& old_p,
const std::string& new_p);
245 static uintmax_t
fileSize(
const std::string& path);
286 static void writeToFile(
const std::string& filePath,
const std::string& content);
304 std::string& fullFileName );
330 static bool isBlank(
const std::string& filePath);
A class for handling system files and paths using UTF-8 strings.
static std::string executableDirectory()
static bool createDirectory(const std::string &path)
Creates a directory from a given path in UTF-8.
static std::vector< std::string > listDirectory(const std::string &path)
Lists a directory from a given path in UTF-8.
static std::string stem(const std::string &path)
Retrives the filename of a given file path in UTF-8, excluding extension.
static void copyFile(const std::string &from, const std::string &to)
Copies a file.
static bool isDirectory(const std::string &path)
Checks if a given path in UTF-8 is a directory.
static std::string getFileContent(const std::string &filePath)
Get file content.
static std::string absolutePath(const std::string &path)
Retrives the absolute path for the given path in UTF-8.
static std::string readFromFile(const std::string &filePath)
Read file and returns the contents of the file.
static bool allocateTmpDiskFile(unsigned long int size, FILE **fileptr, std::string &fullFileName)
Create and allocate a new temporary disk file.
static bool isInvalid(const std::string &content)
Checks whether the contents contains full non-printable character content.
FileSystem(FileSystem const &)
static boost::mutex mutexFileSystem
Used to perform the tasks: write to file or read from file.
static bool exists(const std::string &path)
Checks if a given path in UTF-8 exists.
static std::string createTempFileDirectoryPathString()
static std::string currentPath()
Retrives the current working directory path in UTF-8.
static std::string adjustPathToNativeForm(const std::string &filePath)
Adjusts the given path to native form.
static std::string uniquePath(const std::string &format="%%%%-%%%%-%%%%-%%%%")
Retrives an unique path generated by a given format.
static std::string createTempFilePathString(const std::string &filePath)
static std::string adjustPathToGenericForm(const std::string &filePath)
Adjusts the given path to generic form.
static std::string fileName(const std::string &path)
Retrives the filename of a given file path in UTF-8, including extension.
static bool isEmpty(const std::string &path)
Checks if a given path in UTF-8 is an empty directory.
static bool remove(const std::string &path)
Removes a file or directory from a given path in UTF-8.
static void writeToFile(const std::string &filePath, const std::string &content)
will create a copy of the file before saving.
FileSystem & operator=(FileSystem const &)
static uintmax_t fileSize(const std::string &path)
Returns the file size of a FILE in UTF-8.
static bool createDirectories(const std::string &path)
Creates a directory for any element of path that does not exist.
static std::string extension(const std::string &path)
Retrives the extension of a given file path in UTF-8.
static std::string systemCompletePath(const std::string &path)
Composes an absolute path for the given path in UTF-8.
static std::string parentPath(const std::string &path)
Retrives the parent path of a given file path in UTF-8. For /home/files/fileName.shp,...
static std::string getNativeSeparator()
Returns the native separator based on the Operational System.
static void rename(const std::string &old_p, const std::string &new_p)
Renames a file or directory from a given path in UTF-8.
static std::string tempDirectoryPath()
Retrives the temp directory in UTF-8.
static bool isRegularFile(const std::string &path)
Checks if a given path in UTF-8 is a regular file.
static bool isBlank(const std::string &filePath)
Checks whether the file contains full non-printable character content.