From f6c424165264eec06af2504800ebfdd5d701efae Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Fri, 10 Jan 2020 21:54:34 +0100 Subject: Use Win32 Unicode APIs and expect all strings to be UTF-8 (fixes #1765) For backward compatibility, if PROJ_LIB content is found to be not UTF-8 or pointing to a non existing directory, then an attempt at interpretating it in the ANSI page encoding is done. proj_context_set_search_paths() now assumes strings to be in UTF-8, and functions returning paths will also return values in UTF-8. --- src/filemanager.hpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/filemanager.hpp') diff --git a/src/filemanager.hpp b/src/filemanager.hpp index 9793267c..bc12a303 100644 --- a/src/filemanager.hpp +++ b/src/filemanager.hpp @@ -39,13 +39,26 @@ NS_PROJ_START class File; +enum class FileAccess { + READ_ONLY, // "rb" + READ_UPDATE, // "r+b" + CREATE, // "w+b" +}; + class FileManager { private: FileManager() = delete; public: // "Low-level" interface. - static std::unique_ptr open(PJ_CONTEXT *ctx, const char *filename); + static std::unique_ptr open(PJ_CONTEXT *ctx, const char *filename, + FileAccess access); + static bool exists(PJ_CONTEXT *ctx, const char *filename); + static bool mkdir(PJ_CONTEXT *ctx, const char *filename); + static bool unlink(PJ_CONTEXT *ctx, const char *filename); + static bool rename(PJ_CONTEXT *ctx, const char *oldPath, + const char *newPath); + static std::string getProjLibEnvVar(PJ_CONTEXT *ctx); // "High-level" interface, honoring PROJ_LIB and the like. static std::unique_ptr open_resource_file(PJ_CONTEXT *ctx, @@ -66,6 +79,7 @@ class File { public: virtual ~File(); virtual size_t read(void *buffer, size_t sizeBytes) = 0; + virtual size_t write(const void *buffer, size_t sizeBytes) = 0; virtual bool seek(unsigned long long offset, int whence = SEEK_SET) = 0; virtual unsigned long long tell() = 0; virtual void reassign_context(PJ_CONTEXT *ctx) = 0; @@ -78,4 +92,4 @@ NS_PROJ_END //! @endcond Doxygen_Suppress -#endif // FILEMANAGER_HPP_INCLUDED \ No newline at end of file +#endif // FILEMANAGER_HPP_INCLUDED -- cgit v1.2.3