asar_util.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright (c) 2015 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ELECTRON_SHELL_COMMON_ASAR_ASAR_UTIL_H_
  5. #define ELECTRON_SHELL_COMMON_ASAR_ASAR_UTIL_H_
  6. #include <memory>
  7. #include <string>
  8. namespace base {
  9. class FilePath;
  10. }
  11. namespace asar {
  12. class Archive;
  13. struct IntegrityPayload;
  14. // Gets or creates and caches a new Archive from the path.
  15. std::shared_ptr<Archive> GetOrCreateAsarArchive(const base::FilePath& path);
  16. // Destroy cached Archive objects.
  17. void ClearArchives();
  18. // Separates the path to Archive out.
  19. bool GetAsarArchivePath(const base::FilePath& full_path,
  20. base::FilePath* asar_path,
  21. base::FilePath* relative_path,
  22. bool allow_root = false);
  23. // Same with base::ReadFileToString but supports asar Archive.
  24. bool ReadFileToString(const base::FilePath& path, std::string* contents);
  25. void ValidateIntegrityOrDie(const char* data,
  26. size_t size,
  27. const IntegrityPayload& integrity);
  28. } // namespace asar
  29. #endif // ELECTRON_SHELL_COMMON_ASAR_ASAR_UTIL_H_