[ Merge of http://go/wvgerrit/171310 ] Offline license not found errors are identified by CdmResponseEnum 347 (KEYSET_ID_NOT_FOUND_4). No addition file system information is shared. Checks for file existance use the stat command. The stat call can return error codes from errno.h when the command fails. These are now converted into sub error codes and returned along with the offline license file not found error. This also includes a change to log stat errors other than ENOENT (no such file or directory) as a warning rather than verbose. Bug: 276225520 Test: file_store_unittest, file_utils_unittest, GtsMediaTestCases Change-Id: Ic09d036549582cd65783b49fa96ffefc4bf562c7
88 lines
2.6 KiB
C++
88 lines
2.6 KiB
C++
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
|
|
// source code may only be used and distributed under the Widevine License
|
|
// Agreement.
|
|
//
|
|
// File - Platform independent interface for a File class
|
|
//
|
|
#ifndef WVCDM_UTIL_FILE_STORE_H_
|
|
#define WVCDM_UTIL_FILE_STORE_H_
|
|
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "disallow_copy_and_assign.h"
|
|
#include "platform.h"
|
|
#include "util_common.h"
|
|
|
|
namespace wvutil {
|
|
|
|
static const std::string kAtscCertificateFileName = "atsccert.bin";
|
|
static const std::string kCertificateFileName = "cert1.bin";
|
|
static const std::string kCertificateFileNameExt = ".bin";
|
|
static const std::string kCertificateFileNamePrefix = "cert1_";
|
|
static const std::string kLegacyCertificateFileName = "cert.bin";
|
|
static const std::string kLegacyCertificateFileNamePrefix = "cert";
|
|
static const std::string kOemCertificateFileName = "oemcert.bin";
|
|
static const std::string kOemCertificateFileNamePrefix = "oemcert_";
|
|
|
|
// File class. The implementation is platform dependent.
|
|
class File {
|
|
public:
|
|
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);
|
|
};
|
|
|
|
class FileSystem {
|
|
public:
|
|
FileSystem();
|
|
FileSystem(const std::string& origin, void* extra_data);
|
|
virtual ~FileSystem();
|
|
|
|
class Impl;
|
|
|
|
// defines as bit flag
|
|
enum OpenFlags {
|
|
kNoFlags = 0,
|
|
kCreate = 1,
|
|
kReadOnly = 2, // defaults to read and write access
|
|
kTruncate = 4
|
|
};
|
|
|
|
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);
|
|
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.
|
|
virtual bool List(const std::string& dir_path,
|
|
std::vector<std::string>* names);
|
|
|
|
const std::string& origin() const { return origin_; }
|
|
void set_origin(const std::string& origin);
|
|
|
|
const std::string& identifier() const { return identifier_; }
|
|
void set_identifier(const std::string& identifier);
|
|
bool IsGlobal() const { return identifier_.empty(); }
|
|
|
|
private:
|
|
std::unique_ptr<FileSystem::Impl> impl_;
|
|
std::string origin_;
|
|
std::string identifier_;
|
|
|
|
CORE_DISALLOW_COPY_AND_ASSIGN(FileSystem);
|
|
};
|
|
|
|
} // namespace wvutil
|
|
|
|
#endif // WVCDM_UTIL_FILE_STORE_H_
|