utility: added FilePath abstraction and rewrote data management to use it
The utility class FilePath wraps an instance of boost::filesystem::path. Using FilePath allows for easy comparision of file paths on different platforms using absolute or relative paths. Whereever file paths are compared, this wrapper should be used.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
#ifndef FILE_PATH_H
|
||||
#define FILE_PATH_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "boost/filesystem.hpp"
|
||||
|
||||
class FilePath
|
||||
{
|
||||
public:
|
||||
FilePath(const char* filePath);
|
||||
FilePath(const std::string& filePath);
|
||||
FilePath(const boost::filesystem::path& filePath);
|
||||
|
||||
bool exists() const;
|
||||
|
||||
std::string str() const;
|
||||
std::string absoluteStr() const;
|
||||
std::string fileName() const;
|
||||
|
||||
std::string extension() const;
|
||||
FilePath withoutExtension() const;
|
||||
bool hasExtension(const std::vector<std::string>& extensions) const;
|
||||
|
||||
bool operator==(const FilePath& other) const;
|
||||
bool operator!=(const FilePath& other) const;
|
||||
bool operator<(const FilePath& other) const;
|
||||
|
||||
private:
|
||||
boost::filesystem::path m_path;
|
||||
};
|
||||
|
||||
#endif // FILE_PATH_H
|
||||
Reference in New Issue
Block a user