3#include "FileContents.h"
6#if !defined( EMSCRIPTEN )
8 namespace fs = std::filesystem;
13#if defined( EMSCRIPTEN )
14 using RecursiveDirIterator = std::vector<std::string>;
15 using DirectoryEntry = std::string;
17 using FileTimeType = int64_t;
19 using RecursiveDirIterator = fs::recursive_directory_iterator;
20 using DirectoryEntry = fs::directory_entry;
22 using FileTimeType = fs::file_time_type;
26 COGSFOUNDATION_API
void readFileAsync(
const std::string& fileName,
const FileContents::Callback& callback, uint64_t offset = 0, uint64_t size = 0,
FileContentsHints hints = FileContentsHints::None);
28 COGSFOUNDATION_API FileContents::Ptr readFileSync(
const std::string& fileName, uint64_t offset = 0, uint64_t size = 0,
FileContentsHints hints = FileContentsHints::None);
29 COGSFOUNDATION_API
bool readTextFile(std::string& content,
const std::string & fileName);
31 COGSFOUNDATION_API
void autoExpandEnvironmentVariables(std::string& text);
32 COGSFOUNDATION_API std::string expandEnvironmentVariables(
const std::string& input);
33 COGSFOUNDATION_API std::string expandEnvironmentVariable(
const std::string& name);
35 COGSFOUNDATION_API
char pathSeparator();
36 COGSFOUNDATION_API
bool exists(std::string_view path);
37 COGSFOUNDATION_API
bool isFile(std::string_view path);
38 COGSFOUNDATION_API
bool isDirectory(std::string_view path);
39 COGSFOUNDATION_API std::string absolute(std::string_view path);
40 COGSFOUNDATION_API std::string canonical(std::string_view path);
42 COGSFOUNDATION_API
bool remove(std::string_view path);
45 COGSFOUNDATION_API std::string combine(std::string_view path, std::string_view extensionPath);
47 COGSFOUNDATION_API std::string expandPath(std::string_view fileName);
48 COGSFOUNDATION_API std::string parentPath(std::string_view str);
49 COGSFOUNDATION_API std::string relativePath(std::string_view str);
50 COGSFOUNDATION_API std::string relativePath(std::string_view str, std::string_view base);
52 COGSFOUNDATION_API std::string getPathToExe();
53 COGSFOUNDATION_API std::string getPathRelativeToDll(
const std::string& fileName,
void* handle);
54 COGSFOUNDATION_API std::string getTempPath();
55 COGSFOUNDATION_API std::string getAppDataPath();
56 COGSFOUNDATION_API std::string getOrgLocalDataPath();
58 COGSFOUNDATION_API
bool isAbsolute(std::string_view str);
59 COGSFOUNDATION_API
bool isRelative(std::string_view str);
61 COGSFOUNDATION_API std::string fileName(std::string_view str);
62 COGSFOUNDATION_API std::string extension(std::string_view str);
63 COGSFOUNDATION_API std::string stem(std::string_view str);
64 COGSFOUNDATION_API
void replaceAll(std::string& str, std::string_view from, std::string_view to);
65 COGSFOUNDATION_API FileTimeType getFileTime(std::string_view path);
66 COGSFOUNDATION_API uint64_t getFileSize(std::string_view path);
68 COGSFOUNDATION_API
bool writeBinaryFile(
const std::string& fileName,
const void* content,
size_t contentSize);
70 COGSFOUNDATION_API
bool createDirectories(std::string_view fileName);
71 COGSFOUNDATION_API RecursiveDirIterator directoryIterator(std::string_view directory);
72 COGSFOUNDATION_API std::string getPath(
const DirectoryEntry& entry);
74#if !defined( EMSCRIPTEN )
75 COGSFOUNDATION_API
bool copyFile(std::string_view src, std::string_view dest);
77 COGSFOUNDATION_API
void backupFile(
const std::string& path,
int max);
79 COGSFOUNDATION_API FileHandle::Ptr openFile(std::string_view path, FileHandle::OpenMode openMode, FileHandle::AccessMode accessMode);
80 COGSFOUNDATION_API
void closeFile(
const FileHandle::Ptr& handle);
81 COGSFOUNDATION_API
size_t fileSize(
const FileHandle::Ptr& handle);
82 COGSFOUNDATION_API
void* mapFile(
const FileHandle::Ptr& handle, FileHandle::ProtectionMode protectionMode,
size_t offset,
size_t size);
83 COGSFOUNDATION_API
void unmapFile(
const FileHandle::Ptr& handle);
Contains all Cogs related functionality.