Files
nearby/cpp/platform/impl/shared/file_impl.h
T
Himanshu Jaju cffbc04508 Roll forward to cl/314549634
Change-Id: I4d1e7eacd5fa4078a094571ad6d5f51e422535ff
2020-06-03 11:18:32 -07:00

47 lines
1.1 KiB
C++

#ifndef PLATFORM_IMPL_SHARED_FILE_IMPL_H_
#define PLATFORM_IMPL_SHARED_FILE_IMPL_H_
#include <cstdint>
#include <fstream>
#include "platform/api/input_file.h"
#include "platform/api/output_file.h"
#include "platform/exception.h"
#include "platform/ptr.h"
namespace location {
namespace nearby {
class InputFileImpl final : public InputFile {
public:
InputFileImpl(const std::string& path, std::int64_t size);
~InputFileImpl() override {}
ExceptionOr<ConstPtr<ByteArray>> read(std::int64_t size) override;
std::string getFilePath() const override;
std::int64_t getTotalSize() const override;
void close() override;
private:
std::ifstream file_;
const std::string path_;
const std::int64_t total_size_;
};
class OutputFileImpl final : public OutputFile {
public:
explicit OutputFileImpl(const std::string& path);
~OutputFileImpl() override {}
Exception::Value write(ConstPtr<ByteArray> data) override;
void close() override;
private:
std::ofstream file_;
};
} // namespace nearby
} // namespace location
#endif // PLATFORM_IMPL_SHARED_FILE_IMPL_H_