diff options
author | Alex Zolotarev <deathbaba@gmail.com> | 2010-12-06 21:53:17 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:06:41 +0300 |
commit | 0a221350d1036690a6d25310a8e4c7dd98ecff94 (patch) | |
tree | f05780ab04de285a120ba6dd23c2fb76243c235a /platform/platform.hpp | |
parent | 814e5093acdf950100732aa04e435874ac3c76d5 (diff) |
Platform refactoring for QT
Introduced correct paths support for release production builds
Diffstat (limited to 'platform/platform.hpp')
-rw-r--r-- | platform/platform.hpp | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/platform/platform.hpp b/platform/platform.hpp index 8ed3e1994f..3f6da6100d 100644 --- a/platform/platform.hpp +++ b/platform/platform.hpp @@ -1,23 +1,41 @@ #pragma once +#include "../base/exception.hpp" + #include "../std/string.hpp" #include "../std/vector.hpp" #include "../std/utility.hpp" #include "../base/start_mem_debug.hpp" +DECLARE_EXCEPTION(FileAbsentException, RootException); + class Platform { public: virtual ~Platform() {} /// Time in seconds passed from application start - virtual double TimeInSec() = 0; + virtual double TimeInSec() const = 0; - /// Full path to read/write project data directory with slash at the end - virtual string WorkingDir() = 0; - /// Full path to read only program resources dir with slash at the end - virtual string ResourcesDir() = 0; + /// @return always the same writable dir for current user with slash at the end + virtual string WritableDir() const = 0; + /// @return full path to file in user's writable directory + string WritablePathForFile(string const & file) const + { + return WritableDir() + file; + } + + /// Throws FileAbsentException + /// @param[in] file just file name which we want to read + /// @param[out] fullPath fully resolved path including file name + /// @return false if file is absent + virtual string ReadPathForFile(char const * file) const = 0; + /// Throws FileAbsentException + string ReadPathForFile(string const & file) const + { + return ReadPathForFile(file.c_str()); + } /// @name File operations //@{ @@ -26,20 +44,20 @@ public: /// @param directory directory path with slash at the end /// @param mask files extension to find, like ".map" etc /// @return number of files found in outFiles - virtual int GetFilesInDir(string const & directory, string const & mask, FilesList & outFiles) = 0; + virtual int GetFilesInDir(string const & directory, string const & mask, FilesList & outFiles) const = 0; /// @return false if file is not exist - virtual bool GetFileSize(string const & file, uint64_t & size) = 0; + virtual bool GetFileSize(string const & file, uint64_t & size) const = 0; /// Renamed to avoid conflict with Windows macroses - virtual bool RenameFileX(string const & original, string const & newName) = 0; + virtual bool RenameFileX(string const & original, string const & newName) const = 0; /// Simple check - bool IsFileExists(string const & file) + bool IsFileExists(string const & file) const { uint64_t dummy; return GetFileSize(file, dummy); } //@} - virtual int CpuCores() = 0; + virtual int CpuCores() const = 0; virtual double VisualScale() const = 0; |