.. index:: pair: class; EE::System::FileSystem .. _doxid-class_e_e_1_1_system_1_1_file_system: class EE::System::FileSystem ============================ .. toctree:: :hidden: Overview ~~~~~~~~ .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include class FileSystem { public: // methods static std::string :ref:`getOSSlash`(); static bool :ref:`fileExists`(const std::string& Filepath); static bool :ref:`fileGet`(const std::string& path, std::vector<:ref:`Uint8`>& data); static bool :ref:`fileGet`(const std::string& path, :ref:`ScopedBuffer`& data); static bool :ref:`fileGet`(const std::string& path, std::string& data); static bool :ref:`fileCopy`(const std::string& src, const std::string& dst); static std::string :ref:`fileExtension`(const std::string& filepath, const bool& lowerExt = true); static std::string :ref:`fileNameFromPath`(const std::string& filepath); static std::string :ref:`fileRemoveFileName`(const std::string& filepath); static std::string :ref:`fileRemoveExtension`(const std::string& filepath); static void :ref:`filePathRemoveProcessPath`(std::string& path); static void :ref:`filePathRemoveBasePath`(const std::string& basePath, std::string& path); static bool :ref:`fileWrite`(const std::string& filepath, const :ref:`Uint8`* data, const :ref:`Uint32`& dataSize); static bool :ref:`fileWrite`(const std::string& filepath, const std::vector<:ref:`Uint8`>& data); static bool :ref:`fileWrite`(const std::string& filepath, const std::string& data); static bool :ref:`fileRemove`(const std::string& filepath); static bool :ref:`fileHide`(const std::string& filepath); static :ref:`Uint32` :ref:`fileGetModificationDate`(const std::string& filepath); static bool :ref:`fileCanWrite`(const std::string& filepath); static bool :ref:`fileIsHidden`(const std::string& filepath); static void :ref:`dirAddSlashAtEnd`(std::string& path); static void :ref:`dirRemoveSlashAtEnd`(std::string& dir); static std::string :ref:`removeLastFolderFromPath`(std::string path); static std::vector :ref:`filesGetInPath`(const std::string& path, const bool& sortByName = false, const bool& foldersFirst = false, const bool& ignoreHidden = false); static std::vector<:ref:`String`> :ref:`filesGetInPath`(const :ref:`String`& path, const bool& sortByName = false, const bool& foldersFirst = false, const bool& ignoreHidden = false); static std::vector<:ref:`FileInfo`> :ref:`filesInfoGetInPath`(std::string path, bool linkInfo = false, const bool& sortByName = false, const bool& foldersFirst = false, const bool& ignoreHidden = false); static :ref:`Uint64` :ref:`fileSize`(const std::string& Filepath); static bool :ref:`isDirectory`(const std::string& path); static bool :ref:`isDirectory`(const :ref:`String`& path); static bool :ref:`makeDir`(const std::string& path, bool recursive = false, const :ref:`Uint16`& mode = 0770); static std::string :ref:`getRealPath`(const std::string& path); static std::string :ref:`sizeToString`(const :ref:`Int64`& Size); static bool :ref:`changeWorkingDirectory`(const std::string& path); static std::string :ref:`getCurrentWorkingDirectory`(); static void :ref:`filePathRemoveCurrentWorkingDirectory`(std::string& path); static :ref:`Int64` :ref:`getDiskFreeSpace`(const std::string& path); static std::string :ref:`fileGetNumberedFileNameFromPath`(std::string directoryPath, const std::string& fileName, const std::string& separator = ".", const std::string& fileExtension = ""); static bool :ref:`isRelativePath`(const std::string& path); static FILE* :ref:`fopenUtf8`(const char* path, const char* mode); static FILE* :ref:`fopenUtf8`(const std::string& path, const std::string& mode); }; .. _details-class_e_e_1_1_system_1_1_file_system: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Methods ------- .. index:: pair: function; getOSSlash .. _doxid-class_e_e_1_1_system_1_1_file_system_1acc678ca2510b0cacb303c306fc5b6d08: .. ref-code-block:: cpp :class: doxyrest-title-code-block static std::string getOSSlash() .. rubric:: Returns: The default slash path code of the current OS .. index:: pair: function; fileExists .. _doxid-class_e_e_1_1_system_1_1_file_system_1a406670fc6dade9e771a5eedae55205b4: .. ref-code-block:: cpp :class: doxyrest-title-code-block static bool fileExists(const std::string& Filepath) .. rubric:: Returns: True if the file exists ( false if is a directory, to know if directory exists use isDirectory ) .. index:: pair: function; fileGet .. _doxid-class_e_e_1_1_system_1_1_file_system_1a5bfefc7b7d77943e87950c6dcbac2ba1: .. ref-code-block:: cpp :class: doxyrest-title-code-block static bool fileGet(const std::string& path, std::vector<:ref:`Uint8`>& data) Copy a file to memory .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - path - The file path * - data - The vector to allocate the file in memory .. rubric:: Returns: True if returned the file to the vector. .. index:: pair: function; fileGet .. _doxid-class_e_e_1_1_system_1_1_file_system_1aa70beafebf516e1500c50955f0b126b1: .. ref-code-block:: cpp :class: doxyrest-title-code-block static bool fileGet(const std::string& path, :ref:`ScopedBuffer`& data) Copy a file to memory .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - path - The file path * - data - A ScopedBuffer to allocate the data to memory .. rubric:: Returns: True if returned the file to the ScopedBuffer .. index:: pair: function; fileGet .. _doxid-class_e_e_1_1_system_1_1_file_system_1a115ebac569500983c940741a86afd24e: .. ref-code-block:: cpp :class: doxyrest-title-code-block static bool fileGet(const std::string& path, std::string& data) Copy a file to memory .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - path - The file path * - data - The string to allocate the file in memory .. rubric:: Returns: True if returned the file to the vector. .. index:: pair: function; fileCopy .. _doxid-class_e_e_1_1_system_1_1_file_system_1afed8e1f5e20577e58c98f83e360f79ec: .. ref-code-block:: cpp :class: doxyrest-title-code-block static bool fileCopy(const std::string& src, const std::string& dst) Copy a file to location. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - src - Source File Path * - dst - Destination File Path .. rubric:: Returns: If success. .. index:: pair: function; fileExtension .. _doxid-class_e_e_1_1_system_1_1_file_system_1afda61c4cdc0c1f7242de3f99c4aa5dc2: .. ref-code-block:: cpp :class: doxyrest-title-code-block static std::string fileExtension(const std::string& filepath, const bool& lowerExt = true) .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - filepath - The file path or name * - lowerExt - Lowercase the extension obtained? ( true by default ) .. rubric:: Returns: The file extension .. index:: pair: function; fileNameFromPath .. _doxid-class_e_e_1_1_system_1_1_file_system_1ab0dfe35a108bdaef0ca797965e2e140a: .. ref-code-block:: cpp :class: doxyrest-title-code-block static std::string fileNameFromPath(const std::string& filepath) .. rubric:: Returns: The file name of a file path .. index:: pair: function; fileRemoveFileName .. _doxid-class_e_e_1_1_system_1_1_file_system_1ab58841b2680dfefbb9f6dc330f9aab57: .. ref-code-block:: cpp :class: doxyrest-title-code-block static std::string fileRemoveFileName(const std::string& filepath) .. rubric:: Returns: Removes the file name from a path, and return the path. .. index:: pair: function; fileRemoveExtension .. _doxid-class_e_e_1_1_system_1_1_file_system_1abd68d24499f58ef1ad3a3269aaa2be3a: .. ref-code-block:: cpp :class: doxyrest-title-code-block static std::string fileRemoveExtension(const std::string& filepath) .. rubric:: Returns: Removes the extension of a filepath .. index:: pair: function; filePathRemoveProcessPath .. _doxid-class_e_e_1_1_system_1_1_file_system_1aa33066552696b6f0e940671ae923accc: .. ref-code-block:: cpp :class: doxyrest-title-code-block static void filePathRemoveProcessPath(std::string& path) Removes the process path to a file path .. index:: pair: function; filePathRemoveBasePath .. _doxid-class_e_e_1_1_system_1_1_file_system_1a208334959df8547fed954306b8bf9cd7: .. ref-code-block:: cpp :class: doxyrest-title-code-block static void filePathRemoveBasePath(const std::string& basePath, std::string& path) Removes a base path from a file path .. index:: pair: function; fileWrite .. _doxid-class_e_e_1_1_system_1_1_file_system_1a8630c3140915edaafcf43505a3b3307a: .. ref-code-block:: cpp :class: doxyrest-title-code-block static bool fileWrite(const std::string& filepath, const :ref:`Uint8`* data, const :ref:`Uint32`& dataSize) Write a file in binary mode and close it. .. index:: pair: function; fileWrite .. _doxid-class_e_e_1_1_system_1_1_file_system_1a762d4a138019049cb98ac2873db22a03: .. ref-code-block:: cpp :class: doxyrest-title-code-block static bool fileWrite(const std::string& filepath, const std::vector<:ref:`Uint8`>& data) Write a file in binary mode and close it. .. index:: pair: function; fileWrite .. _doxid-class_e_e_1_1_system_1_1_file_system_1a6cf06ad5b34e777aa6781bb5400cd393: .. ref-code-block:: cpp :class: doxyrest-title-code-block static bool fileWrite(const std::string& filepath, const std::string& data) Write a file in binary mode and close it. .. index:: pair: function; fileRemove .. _doxid-class_e_e_1_1_system_1_1_file_system_1af88fea961c020bb5ce1e071ebed7d3d2: .. ref-code-block:: cpp :class: doxyrest-title-code-block static bool fileRemove(const std::string& filepath) Deletes a file from the file system. .. index:: pair: function; fileHide .. _doxid-class_e_e_1_1_system_1_1_file_system_1ac47acb065d3acbfbff048746e3a2b420: .. ref-code-block:: cpp :class: doxyrest-title-code-block static bool fileHide(const std::string& filepath) Hides the file in the file system .. index:: pair: function; fileGetModificationDate .. _doxid-class_e_e_1_1_system_1_1_file_system_1a9f5330853eca787593323457002044f6: .. ref-code-block:: cpp :class: doxyrest-title-code-block static :ref:`Uint32` fileGetModificationDate(const std::string& filepath) .. rubric:: Returns: The modification date of the file .. index:: pair: function; fileCanWrite .. _doxid-class_e_e_1_1_system_1_1_file_system_1ac0c44a44f12140bc56c63143109bfd3b: .. ref-code-block:: cpp :class: doxyrest-title-code-block static bool fileCanWrite(const std::string& filepath) .. rubric:: Returns: If a file path is writeable .. index:: pair: function; fileIsHidden .. _doxid-class_e_e_1_1_system_1_1_file_system_1a22ace7d40bad9f3bc56ec5c72ec0c2dd: .. ref-code-block:: cpp :class: doxyrest-title-code-block static bool fileIsHidden(const std::string& filepath) .. rubric:: Returns: If the file is hidden (hidden attribute in Windows, files starting with '.' in other systems .. index:: pair: function; dirAddSlashAtEnd .. _doxid-class_e_e_1_1_system_1_1_file_system_1a0dd1ee2946580dcce77fee6c75f51fa0: .. ref-code-block:: cpp :class: doxyrest-title-code-block static void dirAddSlashAtEnd(std::string& path) If the directory path not end with a slash, it will add it. .. index:: pair: function; dirRemoveSlashAtEnd .. _doxid-class_e_e_1_1_system_1_1_file_system_1a244c4e91935ad91c85b4d41957d84b2b: .. ref-code-block:: cpp :class: doxyrest-title-code-block static void dirRemoveSlashAtEnd(std::string& dir) If the directory path ends with a slash, it will remove it. .. index:: pair: function; removeLastFolderFromPath .. _doxid-class_e_e_1_1_system_1_1_file_system_1a1e0221d5993b096a0b815a94c9cad75a: .. ref-code-block:: cpp :class: doxyrest-title-code-block static std::string removeLastFolderFromPath(std::string path) Move up from directory tree .. index:: pair: function; filesGetInPath .. _doxid-class_e_e_1_1_system_1_1_file_system_1aaf14ba653c03192f65f4b358e6007087: .. ref-code-block:: cpp :class: doxyrest-title-code-block static std::vector filesGetInPath(const std::string& path, const bool& sortByName = false, const bool& foldersFirst = false, const bool& ignoreHidden = false) .. rubric:: Returns: The files and sub directories contained by a directory .. index:: pair: function; filesGetInPath .. _doxid-class_e_e_1_1_system_1_1_file_system_1aba127dfd4d903b86b300a8add2163d81: .. ref-code-block:: cpp :class: doxyrest-title-code-block static std::vector<:ref:`String`> filesGetInPath(const :ref:`String`& path, const bool& sortByName = false, const bool& foldersFirst = false, const bool& ignoreHidden = false) .. rubric:: Returns: The files and sub directories contained by a directory .. index:: pair: function; filesInfoGetInPath .. _doxid-class_e_e_1_1_system_1_1_file_system_1af1ec1ac17444077b784dc40a324cd12a: .. ref-code-block:: cpp :class: doxyrest-title-code-block static std::vector<:ref:`FileInfo`> filesInfoGetInPath(std::string path, bool linkInfo = false, const bool& sortByName = false, const bool& foldersFirst = false, const bool& ignoreHidden = false) .. rubric:: Returns: The file info of the files and sub directories contained in the directory path. .. index:: pair: function; fileSize .. _doxid-class_e_e_1_1_system_1_1_file_system_1a05347306a53d0a2a13b7659b58c55bb8: .. ref-code-block:: cpp :class: doxyrest-title-code-block static :ref:`Uint64` fileSize(const std::string& Filepath) .. rubric:: Returns: The size of a file .. index:: pair: function; isDirectory .. _doxid-class_e_e_1_1_system_1_1_file_system_1afc797140a9f2e1cfec72db99f147b804: .. ref-code-block:: cpp :class: doxyrest-title-code-block static bool isDirectory(const std::string& path) .. rubric:: Returns: If directory exists, and is a directory .. index:: pair: function; isDirectory .. _doxid-class_e_e_1_1_system_1_1_file_system_1af6a236ad33f9fed47d648334c51091c5: .. ref-code-block:: cpp :class: doxyrest-title-code-block static bool isDirectory(const :ref:`String`& path) .. rubric:: Returns: If directory exists, and is a directory .. index:: pair: function; makeDir .. _doxid-class_e_e_1_1_system_1_1_file_system_1a9e4bc3cfcfeaf0b499d0d8b171cd14ba: .. ref-code-block:: cpp :class: doxyrest-title-code-block static bool makeDir(const std::string& path, bool recursive = false, const :ref:`Uint16`& mode = 0770) Creates a new directory .. index:: pair: function; getRealPath .. _doxid-class_e_e_1_1_system_1_1_file_system_1aa9e5da44b50cb6c2df0e6296a3cff4a7: .. ref-code-block:: cpp :class: doxyrest-title-code-block static std::string getRealPath(const std::string& path) .. rubric:: Returns: The absolute path of a relative path .. index:: pair: function; sizeToString .. _doxid-class_e_e_1_1_system_1_1_file_system_1adec25c3946635cd8c7ca3643947bf55b: .. ref-code-block:: cpp :class: doxyrest-title-code-block static std::string sizeToString(const :ref:`Int64`& Size) Convert a size represented in bytes, to a string converted in byes/kb/mb/tb. For example 10485760 -> "10.0 MB" .. index:: pair: function; changeWorkingDirectory .. _doxid-class_e_e_1_1_system_1_1_file_system_1a172318e4f58d15ce3026c3f0095fa5cb: .. ref-code-block:: cpp :class: doxyrest-title-code-block static bool changeWorkingDirectory(const std::string& path) Change the process current working directory .. index:: pair: function; getCurrentWorkingDirectory .. _doxid-class_e_e_1_1_system_1_1_file_system_1a28c6ee3c0246c770e238b661516224f0: .. ref-code-block:: cpp :class: doxyrest-title-code-block static std::string getCurrentWorkingDirectory() Gets the current working directory .. index:: pair: function; filePathRemoveCurrentWorkingDirectory .. _doxid-class_e_e_1_1_system_1_1_file_system_1aa8ed4dc792f100c8fca22c12b43301cb: .. ref-code-block:: cpp :class: doxyrest-title-code-block static void filePathRemoveCurrentWorkingDirectory(std::string& path) Removes the current working directory from a path .. index:: pair: function; getDiskFreeSpace .. _doxid-class_e_e_1_1_system_1_1_file_system_1a3ff26ede52fe5f5cd4b5054af5e72656: .. ref-code-block:: cpp :class: doxyrest-title-code-block static :ref:`Int64` getDiskFreeSpace(const std::string& path) .. rubric:: Returns: Returns free disk space for a given path in bytes .. index:: pair: function; fileGetNumberedFileNameFromPath .. _doxid-class_e_e_1_1_system_1_1_file_system_1ae174a9e0a27c58576edee5e1dad1a608: .. ref-code-block:: cpp :class: doxyrest-title-code-block static std::string fileGetNumberedFileNameFromPath(std::string directoryPath, const std::string& fileName, const std::string& separator = ".", const std::string& fileExtension = "") Creates a file name available for the directory path. For file name "file-name-" will search the first available name in the file system starting from file-name-1, file-name-2, and so on. .. rubric:: Returns: The file name found, otherwise empty string if error. .. index:: pair: function; isRelativePath .. _doxid-class_e_e_1_1_system_1_1_file_system_1af30b82ed099b996ca52dd779e1af55ae: .. ref-code-block:: cpp :class: doxyrest-title-code-block static bool isRelativePath(const std::string& path) .. rubric:: Returns: True if the path provided is relative. .. index:: pair: function; fopenUtf8 .. _doxid-class_e_e_1_1_system_1_1_file_system_1a08c18ef5bbbdd4cf9feabd82f9925be0: .. ref-code-block:: cpp :class: doxyrest-title-code-block static FILE* fopenUtf8(const char* path, const char* mode) Opens a file path with a path and mode encoded in UTF-8 .. index:: pair: function; fopenUtf8 .. _doxid-class_e_e_1_1_system_1_1_file_system_1ab2c4a6a8bb8dfb838f64b4676dc833ef: .. ref-code-block:: cpp :class: doxyrest-title-code-block static FILE* fopenUtf8(const std::string& path, const std::string& mode) Opens a file path with a path and mode encoded in UTF-8