class Core::Portable::FileUtils
Overview
File utility functions. More…
#include <corefile.h> class FileUtils { public: // methods static void getTempDir(FileName& dirname); static void getDataDir(FileName& dirname, bool shared = false); static void getAppDir(FileName& dirname, bool shared = false); static void getAppSupportDir(FileName& dirname, bool shared = false); static void getHomeDir(FileName& dirname); static void getWorkingDir(FileName& dirname); static bool makeDirectory(CStringPtr dirname); static bool fileExists(CStringPtr filename); static bool dirExists(CStringPtr dirname); static int64 fileLastModified(CStringPtr filename); static bool deleteFile(CStringPtr filename); static bool removeDirectory(CStringPtr dirname); static bool removeDirectoryTree(CStringPtr dirname); static bool renameFile(CStringPtr oldname, CStringPtr newname); static bool truncate(CStringPtr filename, Core::int64 length); static IO::MemoryStream* loadFile(CStringPtr filename); static bool saveFile(CStringPtr filename, const IO::MemoryStream& data); static bool touchFile(CStringPtr filename); static bool copyFile(CStringPtr source, CStringPtr destination); static bool copyDirectoryTree(CStringPtr source, CStringPtr destination); };
Detailed Documentation
File utility functions.
Methods
static void getTempDir(FileName& dirname)
Get path to temporary directory.
static void getDataDir(FileName& dirname, bool shared = false)
Get path to application data directory (per user or shared).
static void getAppDir(FileName& dirname, bool shared = false)
Get path to applications directory (per user or shared).
static void getAppSupportDir(FileName& dirname, bool shared = false)
Get path to application support directory (per user or shared).
static void getHomeDir(FileName& dirname)
Get path to user home directory.
static void getWorkingDir(FileName& dirname)
Get current working directory.
static bool makeDirectory(CStringPtr dirname)
Create new directory.
static bool fileExists(CStringPtr filename)
Check if given file exists.
static bool dirExists(CStringPtr dirname)
Check if given directory exists.
static int64 fileLastModified(CStringPtr filename)
Get timestamp of last file modification.
static bool deleteFile(CStringPtr filename)
Delete given file.
static bool removeDirectory(CStringPtr dirname)
Remove directory.
static bool removeDirectoryTree(CStringPtr dirname)
Remove directory tree and all contained files/directories.
Potentially very dangerous! Be careful…
static bool renameFile(CStringPtr oldname, CStringPtr newname)
Rename file.
static bool truncate(CStringPtr filename, Core::int64 length)
Truncate file to given length.
static IO::MemoryStream* loadFile(CStringPtr filename)
Load file contents into new memory stream instance owned by the caller.
static bool saveFile(CStringPtr filename, const IO::MemoryStream& data)
Save file contents from memory to disk in a single write operation.
static bool touchFile(CStringPtr filename)
Change access and modification time to current.
static bool copyFile(CStringPtr source, CStringPtr destination)
Copy file.
static bool copyDirectoryTree(CStringPtr source, CStringPtr destination)
Copy directory recursively.
Files that exist in both source tree and destination get overridden, files only existant in destination remain untouched.