asar_util.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. #include "base/containers/span.h"
  9. namespace base {
  10. class FilePath;
  11. }
  12. namespace asar {
  13. class Archive;
  14. struct IntegrityPayload;
  15. // Gets or creates and caches a new Archive from the path.
  16. std::shared_ptr<Archive> GetOrCreateAsarArchive(const base::FilePath& path);
  17. // Separates the path to Archive out.
  18. bool GetAsarArchivePath(const base::FilePath& full_path,
  19. base::FilePath* asar_path,
  20. base::FilePath* relative_path,
  21. bool allow_root = false);
  22. // Same with base::ReadFileToString but supports asar Archive.
  23. bool ReadFileToString(const base::FilePath& path, std::string* contents);
  24. void ValidateIntegrityOrDie(base::span<const uint8_t> input,
  25. const IntegrityPayload& integrity);
  26. } // namespace asar
  27. #endif // ELECTRON_SHELL_COMMON_ASAR_ASAR_UTIL_H_