Refactor platform apis comments and cleanup a bit
This commit is contained in:
@@ -229,7 +229,7 @@ bool AndroidPlatformTools::OnPostProcess(CookingData& data)
|
||||
}
|
||||
|
||||
// Copy fresh Gradle project template
|
||||
if (FileSystem::CopyDirectory(data.OriginalOutputPath, platformDataPath / TEXT("Project"), true))
|
||||
if (FileSystem::CopyDirectory(data.OriginalOutputPath, platformDataPath / TEXT("Project")))
|
||||
{
|
||||
LOG(Error, "Failed to deploy Gradle project to {0} from {1}", data.OriginalOutputPath, platformDataPath);
|
||||
return true;
|
||||
|
||||
@@ -123,7 +123,7 @@ bool UWPPlatformTools::OnDeployBinaries(CookingData& data)
|
||||
const auto srcAssetsPath = uwpDataPath / TEXT("Assets");
|
||||
if (!FileSystem::DirectoryExists(dstAssetsPath))
|
||||
{
|
||||
if (FileSystem::CopyDirectory(dstAssetsPath, srcAssetsPath, true))
|
||||
if (FileSystem::CopyDirectory(dstAssetsPath, srcAssetsPath))
|
||||
{
|
||||
data.Error(TEXT("Failed to copy Assets directory."));
|
||||
return true;
|
||||
|
||||
@@ -203,7 +203,7 @@ bool iOSPlatformTools::OnPostProcess(CookingData& data)
|
||||
return true;
|
||||
|
||||
// Copy fresh XCode project template
|
||||
if (FileSystem::CopyDirectory(data.OriginalOutputPath, platformDataPath / TEXT("Project"), true))
|
||||
if (FileSystem::CopyDirectory(data.OriginalOutputPath, platformDataPath / TEXT("Project")))
|
||||
{
|
||||
LOG(Error, "Failed to deploy XCode project to {0} from {1}", data.OriginalOutputPath, platformDataPath);
|
||||
return true;
|
||||
|
||||
@@ -156,12 +156,12 @@ bool DeployDataStep::Perform(CookingData& data)
|
||||
FileSystem::CopyFile(dstDotnet / TEXT("THIRD-PARTY-NOTICES.TXT"), srcDotnet / TEXT("THIRD-PARTY-NOTICES.TXT"));
|
||||
if (usAOT)
|
||||
{
|
||||
failed |= EditorUtilities::CopyDirectoryIfNewer(dstDotnet, srcDotnet / TEXT("shared/Microsoft.NETCore.App") / version, true);
|
||||
failed |= EditorUtilities::CopyDirectoryIfNewer(dstDotnet, srcDotnet / TEXT("shared/Microsoft.NETCore.App") / version);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if 1
|
||||
failed |= EditorUtilities::CopyDirectoryIfNewer(dstDotnet / TEXT("host/fxr") / version, srcDotnet / TEXT("host/fxr") / version, true);
|
||||
failed |= EditorUtilities::CopyDirectoryIfNewer(dstDotnet / TEXT("host/fxr") / version, srcDotnet / TEXT("host/fxr") / version);
|
||||
#else
|
||||
// TODO: hostfxr for target platform should be copied from nuget package location: microsoft.netcore.app.runtime.<RID>/<VERSION>/runtimes/<RID>/native/hostfxr.dll
|
||||
String dstHostfxr = dstDotnet / TEXT("host/fxr") / version;
|
||||
@@ -330,7 +330,7 @@ bool DeployDataStep::Perform(CookingData& data)
|
||||
data.Error(TEXT("Missing Mono runtime data files."));
|
||||
return true;
|
||||
}
|
||||
if (FileSystem::CopyDirectory(dstMono, srcMono, true))
|
||||
if (FileSystem::CopyDirectory(dstMono, srcMono))
|
||||
{
|
||||
data.Error(TEXT("Failed to copy Mono runtime data files."));
|
||||
return true;
|
||||
@@ -416,7 +416,7 @@ bool DeployDataStep::Perform(CookingData& data)
|
||||
for (auto& e : buildSettings.AdditionalAssetFolders)
|
||||
{
|
||||
String path = FileSystem::ConvertRelativePathToAbsolute(Globals::ProjectFolder, e);
|
||||
if (FileSystem::DirectoryGetFiles(files, path, TEXT("*"), DirectorySearchOption::AllDirectories))
|
||||
if (FileSystem::DirectoryGetFiles(files, path))
|
||||
{
|
||||
data.Error(TEXT("Failed to find additional assets to deploy."));
|
||||
return true;
|
||||
|
||||
@@ -141,7 +141,7 @@ bool Editor::CheckProjectUpgrade()
|
||||
FileSystem::DeleteDirectory(tempSourceSetup);
|
||||
FileSystem::CreateDirectory(tempSourceSetup);
|
||||
Array<String> files;
|
||||
FileSystem::DirectoryGetFiles(files, sourceFolder, TEXT("*"), DirectorySearchOption::AllDirectories);
|
||||
FileSystem::DirectoryGetFiles(files, sourceFolder);
|
||||
bool useEditorModule = false;
|
||||
for (auto& file : files)
|
||||
{
|
||||
@@ -159,7 +159,7 @@ bool Editor::CheckProjectUpgrade()
|
||||
FileSystem::CopyFile(tempSourceFile, file);
|
||||
}
|
||||
FileSystem::DeleteDirectory(sourceFolder);
|
||||
FileSystem::CopyDirectory(sourceFolder, tempSourceSetup, true);
|
||||
FileSystem::CopyDirectory(sourceFolder, tempSourceSetup);
|
||||
FileSystem::DeleteDirectory(tempSourceSetup);
|
||||
|
||||
// Generate module files
|
||||
@@ -364,7 +364,7 @@ bool Editor::BackupProject()
|
||||
LOG(Info, "Backup project to \"{0}\"", dstPath);
|
||||
|
||||
// Copy everything
|
||||
return FileSystem::CopyDirectory(dstPath, Globals::ProjectFolder, true);
|
||||
return FileSystem::CopyDirectory(dstPath, Globals::ProjectFolder);
|
||||
}
|
||||
|
||||
int32 Editor::LoadProduct()
|
||||
|
||||
@@ -79,5 +79,5 @@ public:
|
||||
static bool ReplaceInFile(const StringView& file, const Dictionary<String, String, HeapAllocation>& replaceMap);
|
||||
|
||||
static bool CopyFileIfNewer(const StringView& dst, const StringView& src);
|
||||
static bool CopyDirectoryIfNewer(const StringView& dst, const StringView& src, bool withSubDirectories);
|
||||
static bool CopyDirectoryIfNewer(const StringView& dst, const StringView& src, bool withSubDirectories = true);
|
||||
};
|
||||
|
||||
@@ -1067,7 +1067,7 @@ bool findAsset(const Guid& id, const String& directory, Array<String>& tmpCache,
|
||||
{
|
||||
// Get all asset files
|
||||
tmpCache.Clear();
|
||||
if (FileSystem::DirectoryGetFiles(tmpCache, directory, TEXT("*"), DirectorySearchOption::AllDirectories))
|
||||
if (FileSystem::DirectoryGetFiles(tmpCache, directory))
|
||||
{
|
||||
if (FileSystem::DirectoryExists(directory))
|
||||
LOG(Error, "Cannot query files in folder '{0}'.", directory);
|
||||
|
||||
@@ -167,18 +167,18 @@ bool AndroidFileSystem::DirectoryGetFiles(Array<String>& results, const String&
|
||||
return getFilesFromDirectoryAll(results, pathANSI.Get(), searchPatternANSI.Get());
|
||||
}
|
||||
|
||||
bool AndroidFileSystem::GetChildDirectories(Array<String>& results, const String& directory)
|
||||
bool AndroidFileSystem::GetChildDirectories(Array<String>& results, const String& path)
|
||||
{
|
||||
size_t pathLength;
|
||||
struct stat statPath, statEntry;
|
||||
struct dirent* entry;
|
||||
const StringAsANSI<> pathANSI(*directory, directory.Length());
|
||||
const char* path = pathANSI.Get();
|
||||
const StringAsANSI<> pathANSI(*path, path.Length());
|
||||
const char* pathStr = pathANSI.Get();
|
||||
|
||||
// Stat for the path
|
||||
stat(path, &statPath);
|
||||
stat(pathStr, &statPath);
|
||||
|
||||
// If path does not exists or is not dir - exit with status -1
|
||||
// If path does not exist or is not dir - exit with status -1
|
||||
if (S_ISDIR(statPath.st_mode) == 0)
|
||||
{
|
||||
// Is not directory
|
||||
@@ -186,7 +186,7 @@ bool AndroidFileSystem::GetChildDirectories(Array<String>& results, const String
|
||||
}
|
||||
|
||||
// If not possible to read the directory for this user
|
||||
DIR* dir = opendir(path);
|
||||
DIR* dir = opendir(pathStr);
|
||||
if (dir == nullptr)
|
||||
{
|
||||
// Cannot open directory
|
||||
@@ -194,7 +194,7 @@ bool AndroidFileSystem::GetChildDirectories(Array<String>& results, const String
|
||||
}
|
||||
|
||||
// The length of the path
|
||||
pathLength = strlen(path);
|
||||
pathLength = strlen(pathStr);
|
||||
|
||||
// Iteration through entries in the directory
|
||||
while ((entry = readdir(dir)) != nullptr)
|
||||
@@ -204,20 +204,20 @@ bool AndroidFileSystem::GetChildDirectories(Array<String>& results, const String
|
||||
continue;
|
||||
|
||||
// Determinate a full path of an entry
|
||||
char full_path[256];
|
||||
ASSERT(pathLength + strlen(entry->d_name) < ARRAY_COUNT(full_path));
|
||||
strcpy(full_path, path);
|
||||
strcat(full_path, "/");
|
||||
strcat(full_path, entry->d_name);
|
||||
char fullPath[256];
|
||||
ASSERT(pathLength + strlen(entry->d_name) < ARRAY_COUNT(fullPath));
|
||||
strcpy(fullPath, pathStr);
|
||||
strcat(fullPath, "/");
|
||||
strcat(fullPath, entry->d_name);
|
||||
|
||||
// Stat for the entry
|
||||
stat(full_path, &statEntry);
|
||||
stat(fullPath, &statEntry);
|
||||
|
||||
// Check for directory
|
||||
if (S_ISDIR(statEntry.st_mode) != 0)
|
||||
{
|
||||
// Add directory
|
||||
results.Add(String(full_path));
|
||||
results.Add(String(fullPath));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,12 +12,11 @@
|
||||
class FLAXENGINE_API AndroidFileSystem : public FileSystemBase
|
||||
{
|
||||
public:
|
||||
|
||||
static bool CreateDirectory(const StringView& path);
|
||||
static bool DeleteDirectory(const String& path, bool deleteContents = true);
|
||||
static bool DirectoryExists(const StringView& path);
|
||||
static bool DirectoryGetFiles(Array<String, HeapAllocation>& results, const String& path, const Char* searchPattern, DirectorySearchOption option = DirectorySearchOption::AllDirectories);
|
||||
static bool GetChildDirectories(Array<String, HeapAllocation>& results, const String& directory);
|
||||
static bool DirectoryGetFiles(Array<String, HeapAllocation>& results, const String& path, const Char* searchPattern = TEXT("*"), DirectorySearchOption option = DirectorySearchOption::AllDirectories);
|
||||
static bool GetChildDirectories(Array<String, HeapAllocation>& results, const String& path);
|
||||
static bool FileExists(const StringView& path);
|
||||
static bool DeleteFile(const StringView& path);
|
||||
static uint64 GetFileSize(const StringView& path);
|
||||
@@ -25,25 +24,10 @@ public:
|
||||
static bool SetReadOnly(const StringView& path, bool isReadOnly);
|
||||
static bool MoveFile(const StringView& dst, const StringView& src, bool overwrite = false);
|
||||
static bool CopyFile(const StringView& dst, const StringView& src);
|
||||
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// Gets last time when file has been modified (in UTC).
|
||||
/// </summary>
|
||||
/// <param name="path">The file path to check.</param>
|
||||
/// <returns>The last write time or DateTime::MinValue() if cannot get data.</returns>
|
||||
static DateTime GetFileLastEditTime(const StringView& path);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the special folder path.
|
||||
/// </summary>
|
||||
/// <param name="type">The folder type.</param>
|
||||
/// <param name="result">The result full path.</param>
|
||||
static void GetSpecialFolderPath(const SpecialFolder type, String& result);
|
||||
|
||||
private:
|
||||
|
||||
static bool getFilesFromDirectoryTop(Array<String, HeapAllocation>& results, const char* path, const char* searchPattern);
|
||||
static bool getFilesFromDirectoryAll(Array<String, HeapAllocation>& results, const char* path, const char* searchPattern);
|
||||
};
|
||||
|
||||
@@ -145,19 +145,19 @@ bool AppleFileSystem::DirectoryGetFiles(Array<String>& results, const String& pa
|
||||
return getFilesFromDirectoryAll(results, pathANSI.Get(), searchPatternANSI.Get());
|
||||
}
|
||||
|
||||
bool AppleFileSystem::GetChildDirectories(Array<String>& results, const String& directory)
|
||||
bool AppleFileSystem::GetChildDirectories(Array<String>& results, const String& path)
|
||||
{
|
||||
size_t pathLength;
|
||||
DIR* dir;
|
||||
struct stat statPath, statEntry;
|
||||
struct dirent* entry;
|
||||
const StringAsANSI<> pathANSI(*directory, directory.Length());
|
||||
const char* path = pathANSI.Get();
|
||||
const StringAsANSI<> pathANSI(*path, path.Length());
|
||||
const char* pathStr = pathANSI.Get();
|
||||
|
||||
// Stat for the path
|
||||
stat(path, &statPath);
|
||||
stat(pathStr, &statPath);
|
||||
|
||||
// If path does not exists or is not dir - exit with status -1
|
||||
// If path does not exist or is not dir - exit with status -1
|
||||
if (S_ISDIR(statPath.st_mode) == 0)
|
||||
{
|
||||
// Is not directory
|
||||
@@ -165,14 +165,14 @@ bool AppleFileSystem::GetChildDirectories(Array<String>& results, const String&
|
||||
}
|
||||
|
||||
// If not possible to read the directory for this user
|
||||
if ((dir = opendir(path)) == NULL)
|
||||
if ((dir = opendir(pathStr)) == NULL)
|
||||
{
|
||||
// Cannot open directory
|
||||
return true;
|
||||
}
|
||||
|
||||
// The length of the path
|
||||
pathLength = strlen(path);
|
||||
pathLength = strlen(pathStr);
|
||||
|
||||
// Iteration through entries in the directory
|
||||
while ((entry = readdir(dir)) != NULL)
|
||||
@@ -182,20 +182,20 @@ bool AppleFileSystem::GetChildDirectories(Array<String>& results, const String&
|
||||
continue;
|
||||
|
||||
// Determinate a full path of an entry
|
||||
char full_path[256];
|
||||
ASSERT(pathLength + strlen(entry->d_name) < ARRAY_COUNT(full_path));
|
||||
strcpy(full_path, path);
|
||||
strcat(full_path, "/");
|
||||
strcat(full_path, entry->d_name);
|
||||
char fullPath[256];
|
||||
ASSERT(pathLength + strlen(entry->d_name) < ARRAY_COUNT(fullPath));
|
||||
strcpy(fullPath, path);
|
||||
strcat(fullPath, "/");
|
||||
strcat(fullPath, entry->d_name);
|
||||
|
||||
// Stat for the entry
|
||||
stat(full_path, &statEntry);
|
||||
stat(fullPath, &statEntry);
|
||||
|
||||
// Check for directory
|
||||
if (S_ISDIR(statEntry.st_mode) != 0)
|
||||
{
|
||||
// Add directory
|
||||
results.Add(String(full_path));
|
||||
results.Add(String(fullPath));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,13 +12,12 @@
|
||||
class FLAXENGINE_API AppleFileSystem : public FileSystemBase
|
||||
{
|
||||
public:
|
||||
|
||||
// [FileSystemBase]
|
||||
static bool CreateDirectory(const StringView& path);
|
||||
static bool DeleteDirectory(const String& path, bool deleteContents = true);
|
||||
static bool DirectoryExists(const StringView& path);
|
||||
static bool DirectoryGetFiles(Array<String, HeapAllocation>& results, const String& path, const Char* searchPattern, DirectorySearchOption option = DirectorySearchOption::AllDirectories);
|
||||
static bool GetChildDirectories(Array<String, HeapAllocation>& results, const String& directory);
|
||||
static bool DirectoryGetFiles(Array<String, HeapAllocation>& results, const String& path, const Char* searchPattern = TEXT("*"), DirectorySearchOption option = DirectorySearchOption::AllDirectories);
|
||||
static bool GetChildDirectories(Array<String, HeapAllocation>& results, const String& path);
|
||||
static bool FileExists(const StringView& path);
|
||||
static bool DeleteFile(const StringView& path);
|
||||
static uint64 GetFileSize(const StringView& path);
|
||||
@@ -26,25 +25,10 @@ public:
|
||||
static bool SetReadOnly(const StringView& path, bool isReadOnly);
|
||||
static bool MoveFile(const StringView& dst, const StringView& src, bool overwrite = false);
|
||||
static bool CopyFile(const StringView& dst, const StringView& src);
|
||||
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// Gets last time when file has been modified (in UTC).
|
||||
/// </summary>
|
||||
/// <param name="path">The file path to check.</param>
|
||||
/// <returns>The last write time or DateTime::MinValue() if cannot get data.</returns>
|
||||
static DateTime GetFileLastEditTime(const StringView& path);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the special folder path.
|
||||
/// </summary>
|
||||
/// <param name="type">The folder type.</param>
|
||||
/// <param name="result">The result full path.</param>
|
||||
static void GetSpecialFolderPath(const SpecialFolder type, String& result);
|
||||
|
||||
private:
|
||||
|
||||
static bool getFilesFromDirectoryTop(Array<String, HeapAllocation>& results, const char* path, const char* searchPattern);
|
||||
static bool getFilesFromDirectoryAll(Array<String, HeapAllocation>& results, const char* path, const char* searchPattern);
|
||||
};
|
||||
|
||||
@@ -195,7 +195,7 @@ String FileSystemBase::ConvertAbsolutePathToRelative(const String& basePath, con
|
||||
return output;
|
||||
}
|
||||
|
||||
bool FileSystemBase::CopyFile(const String& dst, const String& src)
|
||||
bool FileSystemBase::CopyFile(const StringView& dst, const StringView& src)
|
||||
{
|
||||
// Open and create files
|
||||
const auto srcFile = File::Open(src, FileMode::OpenExisting, FileAccess::Read);
|
||||
@@ -247,7 +247,7 @@ uint64 FileSystemBase::GetDirectorySize(const StringView& path)
|
||||
{
|
||||
uint64 result = 0;
|
||||
Array<String> files;
|
||||
FileSystem::DirectoryGetFiles(files, path, TEXT("*"), DirectorySearchOption::AllDirectories);
|
||||
FileSystem::DirectoryGetFiles(files, path);
|
||||
for (const String& file : files)
|
||||
result += FileSystem::GetFileSize(file);
|
||||
return result;
|
||||
|
||||
@@ -43,8 +43,133 @@ API_INJECT_CODE(cpp, "#include \"Engine/Platform/FileSystem.h\"");
|
||||
API_CLASS(Static, Name="FileSystem", Tag="NativeInvokeUseName")
|
||||
class FLAXENGINE_API FileSystemBase
|
||||
{
|
||||
DECLARE_SCRIPTING_TYPE_MINIMAL(FileSystemBase);
|
||||
DECLARE_SCRIPTING_TYPE_MINIMAL(FileSystemBase);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new directory.
|
||||
/// </summary>
|
||||
/// <param name="path">Directory path</param>
|
||||
/// <returns>True if failed to create directory, otherwise false.</returns>
|
||||
static bool CreateDirectory(const StringView& path) = delete;
|
||||
|
||||
/// <summary>
|
||||
/// Deletes an existing directory.
|
||||
/// </summary>
|
||||
/// <param name="path">Directory path</param>
|
||||
/// <param name="deleteContents">True if delete all subdirectories and files, otherwise false.</param>
|
||||
/// <returns>True if failed to delete directory, otherwise false.</returns>
|
||||
static bool DeleteDirectory(const String& path, bool deleteContents = true) = delete;
|
||||
|
||||
/// <summary>
|
||||
/// Checks if directory exists.
|
||||
/// </summary>
|
||||
/// <param name="path">Directory path.</param>
|
||||
/// <returns>True if directory exists, otherwise false.</returns>
|
||||
static bool DirectoryExists(const StringView& path) = delete;
|
||||
|
||||
/// <summary>
|
||||
/// Finds the paths of files that match the specified search pattern in the specified directory, using a value to determine whether to search subdirectories.
|
||||
/// </summary>
|
||||
/// <param name="results">Output list with all found file paths. Items are appended without clearing the list first.</param>
|
||||
/// <param name="path">Path of the directory to search in it.</param>
|
||||
/// <param name="searchPattern">Custom search pattern to use during that operation Use asterisk character (*) for name-based filtering (eg. `*.txt` to find all files with `.txt` extension)..</param>
|
||||
/// <param name="option">Additional search options that define rules.</param>
|
||||
/// <returns>True if an error occurred, otherwise false.</returns>
|
||||
static bool DirectoryGetFiles(Array<String, HeapAllocation>& results, const String& path, const Char* searchPattern = TEXT("*"), DirectorySearchOption option = DirectorySearchOption::AllDirectories) = delete;
|
||||
|
||||
/// <summary>
|
||||
/// Finds the paths of directories that are inside the specified directory.
|
||||
/// </summary>
|
||||
/// <param name="results">Output list with all found directory paths. Items are appended without clearing the list first.</param>
|
||||
/// <param name="path">Path of the directory to search in it.</param>
|
||||
/// <returns>True if an error occurred, otherwise false.</returns>
|
||||
static bool GetChildDirectories(Array<String, HeapAllocation>& results, const String& path) = delete;
|
||||
|
||||
/// <summary>
|
||||
/// Copies the directory.
|
||||
/// </summary>
|
||||
/// <param name="dst">Destination path.</param>
|
||||
/// <param name="src">Source directory path.</param>
|
||||
/// <param name="withSubDirectories">True if copy subdirectories of the source folder, otherwise only top-level files will be cloned.</param>
|
||||
/// <returns>True if failed, otherwise false.</returns>
|
||||
static bool CopyDirectory(const String& dst, const String& src, bool withSubDirectories = true);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the size of the directory (in bytes) defined by size of all files contained by it.
|
||||
/// </summary>
|
||||
/// <param name="path">Directory path.</param>
|
||||
/// <returns>Amount of bytes in directory, or 0 if failed.</returns>
|
||||
static uint64 GetDirectorySize(const StringView& path);
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
/// Checks if a given file exists.
|
||||
/// </summary>
|
||||
/// <param name="path">File path to check.</param>
|
||||
/// <returns>True if file exists, otherwise false.</returns>
|
||||
static bool FileExists(const StringView& path) = delete;
|
||||
|
||||
/// <summary>
|
||||
/// Deletes an existing file.
|
||||
/// </summary>
|
||||
/// <param name="path">File path</param>
|
||||
/// <returns>True if operation failed, otherwise false.</returns>
|
||||
static bool DeleteFile(const StringView& path) = delete;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the size of the file (in bytes).
|
||||
/// </summary>
|
||||
/// <param name="path">File path</param>
|
||||
/// <returns>Amount of bytes in file, or 0 if failed.</returns>
|
||||
static uint64 GetFileSize(const StringView& path) = delete;
|
||||
|
||||
/// <summary>
|
||||
/// Checks if file is read-only.
|
||||
/// </summary>
|
||||
/// <param name="path">File path.</param>
|
||||
/// <returns>True if file is read-only, otherwise false. Returns false if failed or path is invalid.</returns>
|
||||
static bool IsReadOnly(const StringView& path) = delete;
|
||||
|
||||
/// <summary>
|
||||
/// Sets file read-only flag.
|
||||
/// </summary>
|
||||
/// <param name="path">File path.</param>
|
||||
/// <param name="isReadOnly">Read-only flag value to set.</param>
|
||||
/// <returns>True if operation failed, otherwise false.</returns>
|
||||
static bool SetReadOnly(const StringView& path, bool isReadOnly) = delete;
|
||||
|
||||
/// <summary>
|
||||
/// Moves the file.
|
||||
/// </summary>
|
||||
/// <param name="dst">Destination path.</param>
|
||||
/// <param name="src">Source file path.</param>
|
||||
/// <param name="overwrite">True if allow overriding destination file if it already exists, otherwise action will fail.</param>
|
||||
/// <returns>True if failed, otherwise false.</returns>
|
||||
static bool MoveFile(const StringView& dst, const StringView& src, bool overwrite = false) = delete;
|
||||
|
||||
/// <summary>
|
||||
/// Copies the file.
|
||||
/// </summary>
|
||||
/// <param name="dst">Destination path.</param>
|
||||
/// <param name="src">Source file path.</param>
|
||||
/// <returns>True if failed, otherwise false.</returns>
|
||||
static bool CopyFile(const StringView& dst, const StringView& src);
|
||||
|
||||
/// <summary>
|
||||
/// Gets last time when file has been modified (in UTC).
|
||||
/// </summary>
|
||||
/// <param name="path">The file path to check.</param>
|
||||
/// <returns>The last write time or DateTime::MinValue() if cannot get data.</returns>
|
||||
static DateTime GetFileLastEditTime(const StringView& path) = delete;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the special folder path.
|
||||
/// </summary>
|
||||
/// <param name="type">The folder type.</param>
|
||||
/// <param name="result">The result full path.</param>
|
||||
static void GetSpecialFolderPath(const SpecialFolder type, String& result) = delete;
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
/// Displays a standard dialog box that prompts the user to open a file(s).
|
||||
/// </summary>
|
||||
@@ -97,28 +222,26 @@ DECLARE_SCRIPTING_TYPE_MINIMAL(FileSystemBase);
|
||||
API_FUNCTION() static bool ShowFileExplorer(const StringView& path);
|
||||
|
||||
public:
|
||||
|
||||
static void SaveBitmapToFile(byte* data, uint32 width, uint32 height, uint32 bitsPerPixel, const uint32 padding, const String& path);
|
||||
|
||||
public:
|
||||
|
||||
static bool AreFilePathsEqual(const StringView& path1, const StringView& path2);
|
||||
|
||||
/// <summary>
|
||||
/// Normalize input path for valid path name for current platform file system
|
||||
/// Normalizes input path for valid path name for current platform file system.
|
||||
/// </summary>
|
||||
/// <param name="path">Path to normalize</param>
|
||||
static void NormalizePath(String& path);
|
||||
|
||||
/// <summary>
|
||||
/// Check if path type is relative
|
||||
/// Checks if path type is relative.
|
||||
/// </summary>
|
||||
/// <param name="path">Input path to check</param>
|
||||
/// <returns>True if input path is relative one, otherwise false</returns>
|
||||
static bool IsRelative(const StringView& path);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves file extension (without a dot)
|
||||
/// Retrieves file extension (without a dot).
|
||||
/// </summary>
|
||||
/// <param name="path">Input path to process</param>
|
||||
/// <returns>File extension</returns>
|
||||
@@ -131,22 +254,15 @@ public:
|
||||
static void GetTempFilePath(String& tmpPath);
|
||||
|
||||
public:
|
||||
|
||||
static bool CopyFile(const String& dst, const String& src);
|
||||
static bool CopyDirectory(const String& dst, const String& src, bool withSubDirectories);
|
||||
static uint64 GetDirectorySize(const StringView& path);
|
||||
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// Converts path relative to the engine startup folder into absolute path
|
||||
/// Converts path relative to the engine startup folder into absolute path.
|
||||
/// </summary>
|
||||
/// <param name="path">Path relative to the engine directory</param>
|
||||
/// <returns>Absolute path</returns>
|
||||
static String ConvertRelativePathToAbsolute(const String& path);
|
||||
|
||||
/// <summary>
|
||||
/// Converts path relative to basePath into absolute path
|
||||
/// Converts path relative to basePath into absolute path.
|
||||
/// </summary>
|
||||
/// <param name="basePath">Base path</param>
|
||||
/// <param name="path">Path relative to basePath</param>
|
||||
@@ -154,14 +270,14 @@ public:
|
||||
static String ConvertRelativePathToAbsolute(const String& basePath, const String& path);
|
||||
|
||||
/// <summary>
|
||||
/// Converts absolute path into relative path to engine startup folder
|
||||
/// Converts absolute path into relative path to engine startup folder.
|
||||
/// </summary>
|
||||
/// <param name="path">Absolute path</param>
|
||||
/// <returns>Relative path</returns>
|
||||
static String ConvertAbsolutePathToRelative(const String& path);
|
||||
|
||||
/// <summary>
|
||||
/// Converts absolute path into relative path to basePath
|
||||
/// Converts absolute path into relative path to basePath.
|
||||
/// </summary>
|
||||
/// <param name="basePath">Base path</param>
|
||||
/// <param name="path">Absolute path</param>
|
||||
@@ -169,6 +285,5 @@ public:
|
||||
static String ConvertAbsolutePathToRelative(const String& basePath, const String& path);
|
||||
|
||||
private:
|
||||
|
||||
static bool DirectoryCopyHelper(const String& dst, const String& src, bool withSubDirectories);
|
||||
};
|
||||
|
||||
@@ -291,17 +291,17 @@ bool LinuxFileSystem::DirectoryGetFiles(Array<String>& results, const String& pa
|
||||
return getFilesFromDirectoryAll(results, pathANSI.Get(), searchPatternANSI.Get());
|
||||
}
|
||||
|
||||
bool LinuxFileSystem::GetChildDirectories(Array<String>& results, const String& directory)
|
||||
bool LinuxFileSystem::GetChildDirectories(Array<String>& results, const String& path)
|
||||
{
|
||||
size_t pathLength;
|
||||
DIR* dir;
|
||||
struct stat statPath, statEntry;
|
||||
struct dirent* entry;
|
||||
const StringAsUTF8<> pathANSI(*directory, directory.Length());
|
||||
const char* path = pathANSI.Get();
|
||||
const StringAsUTF8<> pathANSI(*path, path.Length());
|
||||
const char* pathStr = pathANSI.Get();
|
||||
|
||||
// Stat for the path
|
||||
stat(path, &statPath);
|
||||
stat(pathStr, &statPath);
|
||||
|
||||
// If path does not exists or is not dir - exit with status -1
|
||||
if (S_ISDIR(statPath.st_mode) == 0)
|
||||
@@ -311,14 +311,14 @@ bool LinuxFileSystem::GetChildDirectories(Array<String>& results, const String&
|
||||
}
|
||||
|
||||
// If not possible to read the directory for this user
|
||||
if ((dir = opendir(path)) == NULL)
|
||||
if ((dir = opendir(pathStr)) == NULL)
|
||||
{
|
||||
// Cannot open directory
|
||||
return true;
|
||||
}
|
||||
|
||||
// The length of the path
|
||||
pathLength = strlen(path);
|
||||
pathLength = strlen(pathStr);
|
||||
|
||||
// Iteration through entries in the directory
|
||||
while ((entry = readdir(dir)) != NULL)
|
||||
@@ -328,20 +328,20 @@ bool LinuxFileSystem::GetChildDirectories(Array<String>& results, const String&
|
||||
continue;
|
||||
|
||||
// Determinate a full path of an entry
|
||||
char full_path[256];
|
||||
ASSERT(pathLength + strlen(entry->d_name) < ARRAY_COUNT(full_path));
|
||||
strcpy(full_path, path);
|
||||
strcat(full_path, "/");
|
||||
strcat(full_path, entry->d_name);
|
||||
char fullPath[256];
|
||||
ASSERT(pathLength + strlen(entry->d_name) < ARRAY_COUNT(fullPath));
|
||||
strcpy(fullPath, path);
|
||||
strcat(fullPath, "/");
|
||||
strcat(fullPath, entry->d_name);
|
||||
|
||||
// Stat for the entry
|
||||
stat(full_path, &statEntry);
|
||||
stat(fullPath, &statEntry);
|
||||
|
||||
// Check for directory
|
||||
if (S_ISDIR(statEntry.st_mode) != 0)
|
||||
{
|
||||
// Add directory
|
||||
results.Add(String(full_path));
|
||||
results.Add(String(fullPath));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
class FLAXENGINE_API LinuxFileSystem : public FileSystemBase
|
||||
{
|
||||
public:
|
||||
|
||||
// [FileSystemBase]
|
||||
static bool ShowOpenFileDialog(Window* parentWindow, const StringView& initialDirectory, const StringView& filter, bool multiSelect, const StringView& title, Array<String, HeapAllocation>& filenames);
|
||||
static bool ShowBrowseFolderDialog(Window* parentWindow, const StringView& initialDirectory, const StringView& title, String& path);
|
||||
@@ -20,8 +19,8 @@ public:
|
||||
static bool CreateDirectory(const StringView& path);
|
||||
static bool DeleteDirectory(const String& path, bool deleteContents = true);
|
||||
static bool DirectoryExists(const StringView& path);
|
||||
static bool DirectoryGetFiles(Array<String, HeapAllocation>& results, const String& path, const Char* searchPattern, DirectorySearchOption option = DirectorySearchOption::AllDirectories);
|
||||
static bool GetChildDirectories(Array<String, HeapAllocation>& results, const String& directory);
|
||||
static bool DirectoryGetFiles(Array<String, HeapAllocation>& results, const String& path, const Char* searchPattern = TEXT("*"), DirectorySearchOption option = DirectorySearchOption::AllDirectories);
|
||||
static bool GetChildDirectories(Array<String, HeapAllocation>& results, const String& path);
|
||||
static bool FileExists(const StringView& path);
|
||||
static bool DeleteFile(const StringView& path);
|
||||
static bool MoveFileToRecycleBin(const StringView& path);
|
||||
@@ -30,25 +29,10 @@ public:
|
||||
static bool SetReadOnly(const StringView& path, bool isReadOnly);
|
||||
static bool MoveFile(const StringView& dst, const StringView& src, bool overwrite = false);
|
||||
static bool CopyFile(const StringView& dst, const StringView& src);
|
||||
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// Gets last time when file has been modified (in UTC).
|
||||
/// </summary>
|
||||
/// <param name="path">The file path to check.</param>
|
||||
/// <returns>The last write time or DateTime::MinValue() if cannot get data.</returns>
|
||||
static DateTime GetFileLastEditTime(const StringView& path);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the special folder path.
|
||||
/// </summary>
|
||||
/// <param name="type">The folder type.</param>
|
||||
/// <param name="result">The result full path.</param>
|
||||
static void GetSpecialFolderPath(const SpecialFolder type, String& result);
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
static bool UrnEncodePath(const char *path, char *result, int maxLength);
|
||||
static bool getFilesFromDirectoryTop(Array<String, HeapAllocation>& results, const char* path, const char* searchPattern);
|
||||
static bool getFilesFromDirectoryAll(Array<String, HeapAllocation>& results, const char* path, const char* searchPattern);
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
class FLAXENGINE_API MacFileSystem : public AppleFileSystem
|
||||
{
|
||||
public:
|
||||
|
||||
// [AppleFileSystem]
|
||||
static bool ShowOpenFileDialog(Window* parentWindow, const StringView& initialDirectory, const StringView& filter, bool multiSelect, const StringView& title, Array<String, HeapAllocation>& filenames);
|
||||
static bool ShowSaveFileDialog(Window* parentWindow, const StringView& initialDirectory, const StringView& filter, bool multiSelect, const StringView& title, Array<String, HeapAllocation>& filenames);
|
||||
|
||||
@@ -12,12 +12,7 @@
|
||||
class FLAXENGINE_API UWPFileSystem : public Win32FileSystem
|
||||
{
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// Gets the special folder path.
|
||||
/// </summary>
|
||||
/// <param name="type">The folder type.</param>
|
||||
/// <param name="result">The result full path.</param>
|
||||
// [FileSystemBase]
|
||||
static void GetSpecialFolderPath(const SpecialFolder type, String& result);
|
||||
};
|
||||
|
||||
|
||||
@@ -129,11 +129,11 @@ bool Win32FileSystem::DirectoryGetFiles(Array<String>& results, const String& pa
|
||||
return getFilesFromDirectoryAll(results, path, searchPattern);
|
||||
}
|
||||
|
||||
bool Win32FileSystem::GetChildDirectories(Array<String>& results, const String& directory)
|
||||
bool Win32FileSystem::GetChildDirectories(Array<String>& results, const String& path)
|
||||
{
|
||||
// Try to find first file
|
||||
WIN32_FIND_DATA info;
|
||||
String pattern = directory / TEXT('*');
|
||||
String pattern = path / TEXT('*');
|
||||
const HANDLE handle = FindFirstFileW(*pattern, &info);
|
||||
if (INVALID_HANDLE_VALUE == handle)
|
||||
{
|
||||
@@ -151,7 +151,7 @@ bool Win32FileSystem::GetChildDirectories(Array<String>& results, const String&
|
||||
if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
// Add directory
|
||||
results.Add(directory / info.cFileName);
|
||||
results.Add(path / info.cFileName);
|
||||
}
|
||||
} while (FindNextFileW(handle, &info) != 0);
|
||||
FindClose(handle);
|
||||
|
||||
@@ -11,81 +11,23 @@
|
||||
/// </summary>
|
||||
class FLAXENGINE_API Win32FileSystem : public FileSystemBase
|
||||
{
|
||||
// TODO: fix docs
|
||||
|
||||
public:
|
||||
|
||||
// Creates a new directory
|
||||
// @param path Directory path
|
||||
// @returns True if cannot create directory, otherwise false
|
||||
// [FileSystemBase]
|
||||
static bool CreateDirectory(const StringView& path);
|
||||
|
||||
// Deletes an existing directory
|
||||
// @param path Directory path
|
||||
// @param deleteSubdirectories True if delete all subdirectories and files, otherwise false
|
||||
// @returns True if cannot delete directory, otherwise false
|
||||
static bool DeleteDirectory(const String& path, bool deleteContents = true);
|
||||
|
||||
// Check if directory exists
|
||||
// @param path Directory path to check
|
||||
// @returns True if directory exists, otherwise false
|
||||
static bool DirectoryExists(const StringView& path);
|
||||
|
||||
// Finds the names of files (including their paths) that match the specified search pattern in the specified directory, using a value to determine whether to search subdirectories
|
||||
// @param results When this method completes, this list contains list of all filenames that match the specified search pattern
|
||||
// @param path Path of the directory to search in it
|
||||
// @param searchPattern Custom search pattern to use during that operation
|
||||
// @param option Additional search options
|
||||
// @returns True if an error occurred, otherwise false
|
||||
static bool DirectoryGetFiles(Array<String, HeapAllocation>& results, const String& path, const Char* searchPattern, DirectorySearchOption option = DirectorySearchOption::AllDirectories);
|
||||
|
||||
// Finds the names of directories (including their paths) that are inside the specified directory
|
||||
// @param results When this method completes, this list contains list of all filenames that match the specified search pattern
|
||||
// @param directory Path of the directory to search in it
|
||||
// @returns True if an error occurred, otherwise false
|
||||
static bool GetChildDirectories(Array<String, HeapAllocation>& results, const String& directory);
|
||||
|
||||
public:
|
||||
|
||||
// Check if file exists
|
||||
// @param path File path to check
|
||||
// @returns True if file exists, otherwise false
|
||||
static bool DirectoryGetFiles(Array<String, HeapAllocation>& results, const String& path, const Char* searchPattern = TEXT("*"), DirectorySearchOption option = DirectorySearchOption::AllDirectories);
|
||||
static bool GetChildDirectories(Array<String, HeapAllocation>& results, const String& path);
|
||||
static bool FileExists(const StringView& path);
|
||||
|
||||
// Deletes an existing file
|
||||
// @param path File path
|
||||
// @returns True if cannot delete file, otherwise false
|
||||
static bool DeleteFile(const StringView& path);
|
||||
|
||||
// Tries to get size of the file
|
||||
// @param path File path to check
|
||||
// @returns Amount of bytes in file
|
||||
static uint64 GetFileSize(const StringView& path);
|
||||
|
||||
// Check if file is read-only
|
||||
// @param path File path to check
|
||||
// @returns True if file is read-only
|
||||
static bool IsReadOnly(const StringView& path);
|
||||
|
||||
// Sets file read-only flag
|
||||
// @param path File path
|
||||
// @returns True if cannot update file
|
||||
static bool SetReadOnly(const StringView& path, bool isReadOnly);
|
||||
|
||||
// Move file
|
||||
// @param dst Destination path
|
||||
// @param src Source path
|
||||
// @returns True if cannot move file
|
||||
static bool MoveFile(const StringView& dst, const StringView& src, bool overwrite = false);
|
||||
|
||||
// Clone file
|
||||
// @param dst Destination path
|
||||
// @param src Source path
|
||||
// @returns True if cannot copy file
|
||||
static bool CopyFile(const StringView& dst, const StringView& src);
|
||||
static DateTime GetFileLastEditTime(const StringView& path);
|
||||
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// Converts the UNIX style line endings into DOS style (from \n into \r\n).
|
||||
/// </summary>
|
||||
@@ -93,17 +35,7 @@ public:
|
||||
/// <param name="output">The output result.</param>
|
||||
static void ConvertLineEndingsToDos(const StringView& text, Array<Char, HeapAllocation>& output);
|
||||
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// Gets last time when file has been modified (in UTC).
|
||||
/// </summary>
|
||||
/// <param name="path">The file path to check.</param>
|
||||
/// <returns>The last write time or DateTime::MinValue() if cannot get data.</returns>
|
||||
static DateTime GetFileLastEditTime(const StringView& path);
|
||||
|
||||
private:
|
||||
|
||||
static bool getFilesFromDirectoryTop(Array<String, HeapAllocation>& results, const String& directory, const Char* searchPattern);
|
||||
static bool getFilesFromDirectoryAll(Array<String, HeapAllocation>& results, const String& directory, const Char* searchPattern);
|
||||
};
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
class FLAXENGINE_API WindowsFileSystem : public Win32FileSystem
|
||||
{
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// Moves a file to the recycle bin with possible undo instead of removing it permanently.
|
||||
/// </summary>
|
||||
@@ -20,26 +19,15 @@ public:
|
||||
/// <returns>True if cannot perform that operation, otherwise false.</returns>
|
||||
static bool MoveFileToRecycleBin(const StringView& path);
|
||||
|
||||
public:
|
||||
|
||||
static bool AreFilePathsEqual(const StringView& path1, const StringView& path2);
|
||||
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// Gets the special folder path.
|
||||
/// </summary>
|
||||
/// <param name="type">The folder type.</param>
|
||||
/// <param name="result">The result full path.</param>
|
||||
static void GetSpecialFolderPath(const SpecialFolder type, String& result);
|
||||
|
||||
public:
|
||||
|
||||
// [Win32FileSystem]
|
||||
static bool ShowOpenFileDialog(Window* parentWindow, const StringView& initialDirectory, const StringView& filter, bool multiSelect, const StringView& title, Array<String, HeapAllocation>& filenames);
|
||||
static bool ShowSaveFileDialog(Window* parentWindow, const StringView& initialDirectory, const StringView& filter, bool multiSelect, const StringView& title, Array<String, HeapAllocation>& filenames);
|
||||
static bool ShowBrowseFolderDialog(Window* parentWindow, const StringView& initialDirectory, const StringView& title, String& path);
|
||||
static bool ShowFileExplorer(const StringView& path);
|
||||
static void GetSpecialFolderPath(const SpecialFolder type, String& result);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -380,7 +380,7 @@ bool ModelTool::GenerateModelSDF(Model* inputModel, ModelData* modelData, float
|
||||
sdf.ResolutionScale = resolutionScale;
|
||||
sdf.LOD = lodIndex;
|
||||
const int32 maxMips = 3;
|
||||
const int32 mipCount = Math::Min(MipLevelsCount(resolution.X, resolution.Y, resolution.Z, true), maxMips);
|
||||
const int32 mipCount = Math::Min(MipLevelsCount(resolution.X, resolution.Y, resolution.Z), maxMips);
|
||||
PixelFormat format = PixelFormat::R16_UNorm;
|
||||
int32 formatStride = 2;
|
||||
float formatMaxValue = MAX_uint16;
|
||||
|
||||
Reference in New Issue
Block a user