Source release 19.4.0
This commit is contained in:
@@ -7,63 +7,118 @@
|
||||
#ifndef WVCDM_UTIL_FILE_STORE_H_
|
||||
#define WVCDM_UTIL_FILE_STORE_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <stddef.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "disallow_copy_and_assign.h"
|
||||
#include "platform.h"
|
||||
#include "util_common.h"
|
||||
#include "wv_class_utils.h"
|
||||
|
||||
namespace wvutil {
|
||||
|
||||
// Fixed filename for ATSC DRM certificate pre-installed
|
||||
// on ATSC devices for ATSC licenses.
|
||||
static const std::string kAtscCertificateFileName = "atsccert.bin";
|
||||
// General filename for either global or unmapped app-origin
|
||||
// DRM certificates.
|
||||
static const std::string kCertificateFileName = "cert1.bin";
|
||||
// File extension for DRM and OEM certificate files.
|
||||
static const std::string kCertificateFileNameExt = ".bin";
|
||||
static const std::string kCertificateFileNamePrefix = "cert1_";
|
||||
// Filename prefix for mapped (scoped) DRM certificate filenames
|
||||
// specific to a particular app-origin.
|
||||
static const std::string kScopedCertificateFilenamePrefix = "cert1_";
|
||||
// TODO(b/376533901): Replace this constant with
|
||||
// kScopedCertificateFilenamePrefix in source code..
|
||||
static const std::string kCertificateFileNamePrefix =
|
||||
kScopedCertificateFilenamePrefix;
|
||||
// Legacy general filename for either global or unmapped app-origin
|
||||
// DRM certificates.
|
||||
static const std::string kLegacyCertificateFileName = "cert.bin";
|
||||
static const std::string kLegacyCertificateFileNamePrefix = "cert";
|
||||
// Legacy filename prefix for mapped (scoped) DRM certificate filenames
|
||||
// specific to a particular app-origin.
|
||||
static const std::string kLegacyScopedCertificateFilenamePrefix = "cert";
|
||||
// TODO(b/376533901): Replace this constant with
|
||||
// kLegacyScopedCertificateFilenamePrefix in source code..
|
||||
static const std::string kLegacyCertificateFileNamePrefix =
|
||||
kLegacyScopedCertificateFilenamePrefix;
|
||||
// Filename for global OEM certificates.
|
||||
static const std::string kOemCertificateFileName = "oemcert.bin";
|
||||
static const std::string kOemCertificateFileNamePrefix = "oemcert_";
|
||||
|
||||
// File class. The implementation is platform dependent.
|
||||
// File interface. The implementation is platform dependent.
|
||||
class File {
|
||||
public:
|
||||
WVCDM_DISALLOW_COPY_AND_MOVE(File);
|
||||
File() {}
|
||||
virtual ~File() {}
|
||||
virtual ssize_t Read(char* buffer, size_t bytes) = 0;
|
||||
virtual ssize_t Write(const char* buffer, size_t bytes) = 0;
|
||||
|
||||
friend class FileSystem;
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(File);
|
||||
};
|
||||
|
||||
// File system base class. The implementation is platform dependent.
|
||||
class FileSystem {
|
||||
public:
|
||||
WVCDM_DISALLOW_COPY_AND_MOVE(FileSystem);
|
||||
FileSystem();
|
||||
FileSystem(const std::string& origin, void* extra_data);
|
||||
virtual ~FileSystem();
|
||||
|
||||
// Concreate implementation of FileSystem.
|
||||
// Depending on the platform, this may be vendor or Widevine implemented.
|
||||
class Impl;
|
||||
|
||||
// defines as bit flag
|
||||
enum OpenFlags {
|
||||
kNoFlags = 0,
|
||||
kCreate = 1,
|
||||
kReadOnly = 2, // defaults to read and write access
|
||||
kTruncate = 4
|
||||
};
|
||||
// Flags for calls to Open.
|
||||
static constexpr int kNoFlags = 0;
|
||||
// Create file if does not already exist, open file if it does exist.
|
||||
static constexpr int kCreate = (1 << 0);
|
||||
// Open file as read-only; typically should not be used with kCreate.
|
||||
static constexpr int kReadOnly = (1 << 1);
|
||||
// Open file and truncated. May be used with kCreate; should not
|
||||
// be used with kReadOnly.
|
||||
static constexpr int kTruncate = (1 << 2);
|
||||
|
||||
virtual std::unique_ptr<File> Open(const std::string& file_path, int flags);
|
||||
|
||||
virtual bool Exists(const std::string& file_path);
|
||||
virtual bool Exists(const std::string& file_path, int* errno_value);
|
||||
virtual bool Remove(const std::string& file_path);
|
||||
// Checks if the |path| exists. The |path| may be a file or directory.
|
||||
// Return true if an entry in the file system exists; false otherwise.
|
||||
virtual bool Exists(const std::string& path);
|
||||
// Same as above, except the optional parameter of |errno_value| should
|
||||
// be set to 0 or the value of C errno when attempting to check
|
||||
// the existence of a file.
|
||||
virtual bool Exists(const std::string& path, int* errno_value);
|
||||
|
||||
// Removes the specified |path|.
|
||||
//
|
||||
// If |path| is a regular file, the file should be removed.
|
||||
// If |path| is a directory, both the directory and the directory
|
||||
// contents should be removed.
|
||||
//
|
||||
// Implementation must support a |path| containing a single wildcard
|
||||
// character in the filename component of the path.
|
||||
//
|
||||
// Return value:
|
||||
// - true : File/directory was removed, or file/directory did not exist
|
||||
// - false : File/directory could not be removed, or other error.
|
||||
virtual bool Remove(const std::string& path);
|
||||
|
||||
// Obtain the size of a file in bytes. |file_path| must be a file,
|
||||
// and not a directory.
|
||||
//
|
||||
// Return value:
|
||||
// - non-negative : size of file in bytes if file exists
|
||||
// - negative : file does not exist, or error occurred.
|
||||
virtual ssize_t FileSize(const std::string& file_path);
|
||||
|
||||
// Return the filenames stored at dir_path.
|
||||
// dir_path will be stripped from the returned names.
|
||||
// Return the entries stored at |dir_path| (includes both files
|
||||
// and directories).
|
||||
//
|
||||
// Return value:
|
||||
// - true : Directory exists, and directory entry names are stored
|
||||
// in |names|; |names| may be empty if directory was empty.
|
||||
// - false : Directory does not exist, |dir_path| is not a directory,
|
||||
// or error was encountered.
|
||||
virtual bool List(const std::string& dir_path,
|
||||
std::vector<std::string>* names);
|
||||
|
||||
@@ -78,8 +133,6 @@ class FileSystem {
|
||||
std::unique_ptr<FileSystem::Impl> impl_;
|
||||
std::string origin_;
|
||||
std::string identifier_;
|
||||
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(FileSystem);
|
||||
};
|
||||
|
||||
} // namespace wvutil
|
||||
|
||||
Reference in New Issue
Block a user