A modded EditSaber for making beat saber maps.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
2.4 KiB

  1. // Fill out your copyright notice in the Description page of Project Settings.
  2. #include "BPFileIO.h"
  3. bool UBPFileIO::VerifyOrCreateDirectory(const FString & TestDir)
  4. {
  5. IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
  6. // Directory Exists?
  7. if (!PlatformFile.DirectoryExists(*TestDir))
  8. {
  9. PlatformFile.CreateDirectory(*TestDir);
  10. if (!PlatformFile.DirectoryExists(*TestDir))
  11. {
  12. return false;
  13. }
  14. }
  15. return true;
  16. }
  17. bool UBPFileIO::VerifyDirectory(const FString & TestDir)
  18. {
  19. IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
  20. // Directory Exists?
  21. if (!PlatformFile.DirectoryExists(*TestDir))
  22. {
  23. return false;
  24. }
  25. return true;
  26. }
  27. TArray<FString> UBPFileIO::FindAllDirectories(const FString & TestDir)
  28. {
  29. TArray<FString> result;
  30. IFileManager& FileManager = IFileManager::Get();
  31. FString FinalPath = TestDir + "/*";
  32. FileManager.FindFiles(result, *FinalPath, false, true);
  33. return result;
  34. }
  35. TArray<FString> UBPFileIO::FindAllFiles(const FString & TestDir)
  36. {
  37. TArray<FString> result;
  38. IFileManager& FileManager = IFileManager::Get();
  39. FString FinalPath = TestDir + "/*";
  40. FileManager.FindFiles(result, *FinalPath, true, false);
  41. return result;
  42. }
  43. bool UBPFileIO::VerifyFile(const FString & TestFile)
  44. {
  45. if (FPlatformFileManager::Get().GetPlatformFile().FileExists(*TestFile))
  46. {
  47. return true;
  48. }
  49. return false;
  50. }
  51. bool UBPFileIO::RenameOrMoveFile(const FString & InputFile, const FString & OutputFile)
  52. {
  53. if (!FPlatformFileManager::Get().GetPlatformFile().FileExists(*InputFile))
  54. {
  55. return false;
  56. }
  57. if (!FPlatformFileManager::Get().GetPlatformFile().MoveFile(*OutputFile, *InputFile))
  58. {
  59. return false;
  60. }
  61. return true;
  62. }
  63. bool UBPFileIO::CopyFile(const FString & File, const FString& OutputDirectory, const FString& newName)
  64. {
  65. IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
  66. if (PlatformFile.FileExists(*File))
  67. {
  68. if (PlatformFile.DirectoryExists(*OutputDirectory))
  69. {
  70. PlatformFile.CopyFile(*FString(OutputDirectory + "/" + newName), *File);
  71. return true;
  72. }
  73. }
  74. return false;
  75. }
  76. bool UBPFileIO::DeleteFile(const FString & File)
  77. {
  78. if (!FPlatformFileManager::Get().GetPlatformFile().DeleteFile(*File))
  79. {
  80. return false;
  81. }
  82. return true;
  83. }
  84. bool UBPFileIO::DeleteDirectory(const FString & Directory)
  85. {
  86. if (!FPlatformFileManager::Get().GetPlatformFile().DeleteDirectory(*Directory))
  87. {
  88. return false;
  89. }
  90. return true;
  91. }