ZipReader.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // Copyright aXiuShen. All Rights Reserved.
  2. #pragma once
  3. #include "CoreMinimal.h"
  4. #include "ZipReader.generated.h"
  5. class UZipReaderImp;
  6. UCLASS(BlueprintType, Blueprintable)
  7. class WEBVIEW_API UZipReader : public UObject
  8. {
  9. GENERATED_BODY()
  10. public:
  11. /**
  12. * Open on zip file
  13. * @param zipFile only support zip
  14. * @param passwd pass word
  15. * @return false is failed,true is successful and move to first file
  16. */
  17. UFUNCTION(BlueprintCallable, Category = "Web View")
  18. bool Open(const FString& zipFile, const FString& passwd);
  19. /**
  20. * Get zip all file list. contains dir
  21. * @return all file
  22. * e.g: file1.txt dir/ dir/file.png
  23. */
  24. UFUNCTION(BlueprintCallable, Category = "Web View")
  25. TArray<FString> GetAllFileNames();
  26. /**
  27. * move pointer of file to first
  28. * @return false is failed,true is successful
  29. */
  30. UFUNCTION(BlueprintCallable, Category = "Web View")
  31. bool MoveToFirstFile();
  32. /**
  33. * move pointer of file to next from cur position
  34. * @return false is failed,true is successful
  35. */
  36. UFUNCTION(BlueprintCallable, Category = "Web View")
  37. bool MoveToNextFile();
  38. /**
  39. * move pointer of file to special file
  40. * @param fileName Move to destination file location
  41. * @param caseSensitive Match case
  42. * @return false is failed,true is successful
  43. */
  44. UFUNCTION(BlueprintCallable, Category = "Web View")
  45. bool MoveToFile(const FString& fileName, bool caseSensitive=true);
  46. /**
  47. * Get the current file name
  48. * @return file name
  49. */
  50. UFUNCTION(BlueprintCallable, Category = "Web View")
  51. FString GetFileName();
  52. /**
  53. * Get the current file size
  54. * @return file size
  55. */
  56. UFUNCTION(BlueprintCallable, Category = "Web View")
  57. int32 GetFileSize();
  58. /**
  59. * Get the current file content into buffer
  60. * @param data file content
  61. * @return false is failed,true is successful
  62. */
  63. UFUNCTION(BlueprintCallable, Category = "Web View")
  64. bool ReadToString(FString& data);
  65. /**
  66. * Get the current file content into directory
  67. * @param Dir directory used to save file
  68. * @return false is failed,true is successful
  69. */
  70. UFUNCTION(BlueprintCallable, Category = "Web View")
  71. bool ReadToDir(const FString& Dir);
  72. /**
  73. * Get all files content into directory
  74. * @param Dir directory used to save file
  75. * @return false is failed,true is successful
  76. */
  77. UFUNCTION(BlueprintCallable, Category = "Web View")
  78. bool ReadAllToDir(const FString& Dir);
  79. /**
  80. * check object has open zip file
  81. * @return false is failed,true is successful
  82. */
  83. UFUNCTION(BlueprintCallable, Category = "Web View")
  84. bool IsValid();
  85. private:
  86. private:
  87. TSharedPtr<UZipReaderImp> zipFilePtr;
  88. };