|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +#pragma once |
| 21 | + |
| 22 | +#include <string> |
| 23 | + |
| 24 | +#include "iceberg/iceberg_export.h" |
| 25 | + |
| 26 | +namespace iceberg { |
| 27 | +namespace io { |
| 28 | + |
| 29 | +class ICEBERG_EXPORT InputFile { |
| 30 | + public: |
| 31 | + explicit InputFile(std::string path) : path_(std::move(path)) {} |
| 32 | + |
| 33 | + virtual ~InputFile() = default; |
| 34 | + |
| 35 | + virtual bool exists() const = 0; |
| 36 | + |
| 37 | + const std::string& path() const { return path_; } |
| 38 | + |
| 39 | + protected: |
| 40 | + std::string path_; |
| 41 | +}; |
| 42 | + |
| 43 | +class ICEBERG_EXPORT OutputFile { |
| 44 | + public: |
| 45 | + explicit OutputFile(std::string path) : path_(std::move(path)) {} |
| 46 | + |
| 47 | + virtual ~OutputFile() = default; |
| 48 | + |
| 49 | + virtual void create() = 0; |
| 50 | + |
| 51 | + const std::string& path() const { return path_; } |
| 52 | + |
| 53 | + protected: |
| 54 | + std::string path_; |
| 55 | +}; |
| 56 | + |
| 57 | +class ICEBERG_EXPORT FileIO { |
| 58 | + public: |
| 59 | + explicit FileIO(std::string name) : name_(std::move(name)) {} |
| 60 | + |
| 61 | + virtual ~FileIO() = default; |
| 62 | + |
| 63 | + virtual std::shared_ptr<InputFile> newInputFile(const std::string& path) = 0; |
| 64 | + virtual std::shared_ptr<OutputFile> newOutputFile(const std::string& path) = 0; |
| 65 | + |
| 66 | + virtual void DeleteFile(const std::string& path) = 0; |
| 67 | + void DeleteFile(const InputFile& ifile) { return DeleteFile(ifile.path()); } |
| 68 | + void DeleteFile(const OutputFile& ofile) { return DeleteFile(ofile.path()); } |
| 69 | + |
| 70 | + const std::string& name() const { return name_; } |
| 71 | + |
| 72 | + protected: |
| 73 | + std::string name_; |
| 74 | +}; |
| 75 | + |
| 76 | +} // namespace io |
| 77 | +} // namespace iceberg |
0 commit comments