apk_assets.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2015 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef BASE_ANDROID_APK_ASSETS_H_
  5. #define BASE_ANDROID_APK_ASSETS_H_
  6. #include <string>
  7. #include "base/android/jni_android.h"
  8. #include "base/files/file_path.h"
  9. #include "base/files/memory_mapped_file.h"
  10. namespace base {
  11. namespace android {
  12. // Opens an asset (e.g. a .pak file) from the apk.
  13. // Can be used from renderer process.
  14. // Fails if the asset is not stored uncompressed within the .apk.
  15. // Returns: The File Descriptor of the asset, or -1 upon failure.
  16. // Input arguments:
  17. // - |file_path|: Path to file within .apk. e.g.: assets/foo.pak
  18. // Output arguments:
  19. // - |region|: size & offset (in bytes) within the .apk of the asset.
  20. BASE_EXPORT int OpenApkAsset(
  21. const std::string& file_path,
  22. base::MemoryMappedFile::Region* region);
  23. // Registers an uncompressed asset from within the apk in the
  24. // FileDescriptorStore.
  25. // Returns: true in case of success, false otherwise.
  26. BASE_EXPORT bool RegisterApkAssetWithFileDescriptorStore(
  27. const std::string& key,
  28. const base::FilePath& file_path);
  29. } // namespace android
  30. } // namespace base
  31. #endif // BASE_ANDROID_APK_ASSETS_H_