CUFileComponent.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2018-current Getnamo. All Rights Reserved
  2. #pragma once
  3. #include "Components/ActorComponent.h"
  4. #include "CUFileComponent.generated.h"
  5. /**
  6. * Convenience component to save/load data from files
  7. */
  8. UCLASS(ClassGroup = "Utility", meta = (BlueprintSpawnableComponent))
  9. class COREUTILITY_API UCUFileComponent : public UActorComponent
  10. {
  11. GENERATED_UCLASS_BODY()
  12. public:
  13. /** Get the current project contents directory path*/
  14. UFUNCTION(BlueprintPure, Category = FileUtility)
  15. FString ProjectContentsDirectory();
  16. /** Get the current project directory path*/
  17. UFUNCTION(BlueprintPure, Category = FileUtility)
  18. FString ProjectDirectory();
  19. /** Get the current project saved directory path*/
  20. UFUNCTION(BlueprintPure, Category = FileUtility)
  21. FString ProjectSavedDirectory();
  22. /** External storage in android context, otherwise uses project saved directory*/
  23. UFUNCTION(BlueprintPure, Category = FileUtility)
  24. FString ExternalSaveDirectory();
  25. UFUNCTION(BlueprintPure, Category = FileUtility)
  26. void SplitFullPath(const FString& InFullPath, FString& OutDirectory, FString& OutFileName);
  27. UFUNCTION(BlueprintPure, Category = FileUtility)
  28. void ProjectRelativePath(const FString& InFullPath, FString& OutProjectRelativePath);
  29. /** Save array of bytes to file at specified directory */
  30. UFUNCTION(BlueprintCallable, Category = FileUtility)
  31. bool SaveBytesToFile(const TArray<uint8>& Bytes, const FString& Directory, const FString& FileName, bool bLogSave = false);
  32. /** Read array of bytes from file at specified directory */
  33. UFUNCTION(BlueprintCallable, Category = FileUtility)
  34. bool ReadBytesFromFile(const FString& Directory, const FString& FileName, TArray<uint8>& OutBytes);
  35. };