2026-01-16 22:45:06 -05:00
|
|
|
#ifndef AXIO_FILEUTIL_H
|
|
|
|
|
#define AXIO_FILEUTIL_H
|
2018-12-08 23:44:41 -07:00
|
|
|
|
|
|
|
|
#include "TString.h"
|
2025-12-17 13:44:30 -05:00
|
|
|
#include <vector>
|
2018-12-08 23:44:41 -07:00
|
|
|
|
|
|
|
|
namespace FileUtil
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bool Exists(const TString& rkFilePath);
|
|
|
|
|
bool IsRoot(const TString& rkPath);
|
|
|
|
|
bool IsFile(const TString& rkFilePath);
|
|
|
|
|
bool IsDirectory(const TString& rkDirPath);
|
2019-05-26 20:32:24 -10:00
|
|
|
bool IsDirectoryWritable(const TString& rkDirPath);
|
2018-12-08 23:44:41 -07:00
|
|
|
bool IsAbsolute(const TString& rkDirPath);
|
|
|
|
|
bool IsRelative(const TString& rkDirPath);
|
|
|
|
|
bool IsEmpty(const TString& rkDirPath);
|
|
|
|
|
bool MakeDirectory(const TString& rkNewDir);
|
|
|
|
|
bool CopyFile(const TString& rkOrigPath, const TString& rkNewPath);
|
|
|
|
|
bool CopyDirectory(const TString& rkOrigPath, const TString& rkNewPath);
|
|
|
|
|
bool MoveFile(const TString& rkOldPath, const TString& rkNewPath);
|
|
|
|
|
bool MoveDirectory(const TString& rkOldPath, const TString& rkNewPath);
|
|
|
|
|
bool DeleteFile(const TString& rkFilePath);
|
|
|
|
|
bool DeleteDirectory(const TString& rkDirPath, bool FailIfNotEmpty); // This is an extremely destructive function, be careful using it!
|
|
|
|
|
bool ClearDirectory(const TString& rkDirPath); // This is an extremely destructive function, be careful using it!
|
2019-02-03 02:19:03 -07:00
|
|
|
void MarkHidden(const TString& rkFilePath, bool Hidden);
|
2019-02-02 17:30:36 -07:00
|
|
|
void UpdateLastModifiedTime(const TString& rkFilePath);
|
2026-01-11 11:00:26 -05:00
|
|
|
uint64_t FileSize(const TString& rkFilePath);
|
|
|
|
|
uint64_t LastModifiedTime(const TString& rkFilePath);
|
2018-12-08 23:44:41 -07:00
|
|
|
TString WorkingDirectory();
|
|
|
|
|
TString MakeAbsolute(TString Path);
|
|
|
|
|
TString MakeRelative(const TString& rkPath, const TString& rkRelativeTo = WorkingDirectory());
|
|
|
|
|
TString SimplifyRelativePath(const TString& rkPath);
|
2026-01-11 11:00:26 -05:00
|
|
|
uint32_t MaxFileNameLength();
|
2018-12-08 23:44:41 -07:00
|
|
|
TString SanitizeName(TString Name, bool Directory, bool RootDir = false);
|
|
|
|
|
TString SanitizePath(TString Path, bool Directory);
|
|
|
|
|
bool IsValidFileNameCharacter(char Chr);
|
|
|
|
|
bool IsValidName(const TString& rkName, bool Directory, bool RootDir = false);
|
|
|
|
|
bool IsValidPath(const TString& rkPath, bool Directory);
|
|
|
|
|
void GetDirectoryContents(TString DirPath, TStringList& rOut, bool Recursive = true, bool IncludeFiles = true, bool IncludeDirs = true);
|
|
|
|
|
TString FindFileExtension(const TString& rkDir, const TString& rkName);
|
|
|
|
|
bool LoadFileToString(const TString& rkFilePath, TString& rOut);
|
2026-01-11 11:00:26 -05:00
|
|
|
bool LoadFileToBuffer(const TString& rkFilePath, std::vector<uint8_t>& Out);
|
2019-04-06 15:49:05 -07:00
|
|
|
bool SaveStringToFile(const TString& rkFilePath, const TString& kString);
|
2026-01-11 11:00:26 -05:00
|
|
|
bool SaveBufferToFile(const TString& rkFilePath, const std::vector<uint8_t>& kBuffer);
|
2018-12-08 23:44:41 -07:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-16 22:45:06 -05:00
|
|
|
#endif // AXIO_FILEUTIL_H
|
2018-12-08 23:44:41 -07:00
|
|
|
|