mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
This adds parent path and file name to the Payload constructor. This will affect chrome.
PiperOrigin-RevId: 435223740
This commit is contained in:
committed by
Copybara-Service
parent
31b2aae6c5
commit
517d77f5aa
@@ -46,6 +46,7 @@ cc_library(
|
||||
srcs = ["file.cc"],
|
||||
hdrs = ["file.h"],
|
||||
visibility = [
|
||||
"//connections/implementation:__subpackages__",
|
||||
"//internal/platform/implementation:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
|
||||
@@ -26,24 +26,25 @@ namespace nearby {
|
||||
namespace shared {
|
||||
|
||||
// InputFile
|
||||
std::unique_ptr<IOFile> IOFile::CreateInputFile(const absl::string_view path,
|
||||
size_t size) {
|
||||
return absl::WrapUnique(new IOFile(path, size));
|
||||
std::unique_ptr<IOFile> IOFile::CreateInputFile(
|
||||
const absl::string_view file_path, size_t size) {
|
||||
return absl::WrapUnique(new IOFile(file_path, size));
|
||||
}
|
||||
|
||||
IOFile::IOFile(const absl::string_view path, size_t size)
|
||||
: file_(std::string(path.data(), path.size()),
|
||||
IOFile::IOFile(const absl::string_view file_path, size_t size)
|
||||
: file_(std::string(file_path.data(), file_path.size()),
|
||||
std::ios::binary | std::ios::in),
|
||||
path_(path),
|
||||
path_(file_path),
|
||||
total_size_(size) {}
|
||||
|
||||
std::unique_ptr<IOFile> IOFile::CreateOutputFile(const absl::string_view path) {
|
||||
return std::unique_ptr<IOFile>(new IOFile(path));
|
||||
}
|
||||
|
||||
IOFile::IOFile(const absl::string_view path)
|
||||
: file_(std::string(path.data(), path.size()),
|
||||
IOFile::IOFile(const absl::string_view file_path)
|
||||
: file_(std::string(file_path.data(), file_path.size()),
|
||||
std::ios::binary | std::ios::out | std::ios::trunc),
|
||||
path_({file_path.data(), file_path.size()}),
|
||||
total_size_(0) {}
|
||||
|
||||
ExceptionOr<ByteArray> IOFile::Read(std::int64_t size) {
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
#include <fstream>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "internal/platform/exception.h"
|
||||
#include "internal/platform/implementation/input_file.h"
|
||||
#include "internal/platform/implementation/output_file.h"
|
||||
#include "internal/platform/exception.h"
|
||||
|
||||
namespace location {
|
||||
namespace nearby {
|
||||
@@ -29,8 +29,9 @@ namespace shared {
|
||||
|
||||
class IOFile final : public api::InputFile, public api::OutputFile {
|
||||
public:
|
||||
static std::unique_ptr<IOFile> CreateInputFile(const absl::string_view path,
|
||||
size_t size);
|
||||
static std::unique_ptr<IOFile> CreateInputFile(
|
||||
const absl::string_view file_path, size_t size);
|
||||
|
||||
static std::unique_ptr<IOFile> CreateOutputFile(const absl::string_view path);
|
||||
|
||||
ExceptionOr<ByteArray> Read(std::int64_t size) override;
|
||||
@@ -44,10 +45,11 @@ class IOFile final : public api::InputFile, public api::OutputFile {
|
||||
Exception Flush() override;
|
||||
|
||||
private:
|
||||
explicit IOFile(const absl::string_view path, size_t size);
|
||||
explicit IOFile(const absl::string_view path);
|
||||
explicit IOFile(const absl::string_view file_path, size_t size);
|
||||
explicit IOFile(const absl::string_view file_path);
|
||||
|
||||
std::fstream file_;
|
||||
absl::string_view path_;
|
||||
std::string path_;
|
||||
std::int64_t total_size_;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user