1 /* Copyright 2018 The TensorFlow Authors. All Rights Reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 ==============================================================================*/ 15 16 #ifndef TENSORFLOW_CORE_PLATFORM_NULL_FILE_SYSTEM_H_ 17 #define TENSORFLOW_CORE_PLATFORM_NULL_FILE_SYSTEM_H_ 18 19 #include <memory> 20 #include <string> 21 #include <vector> 22 23 #include "tensorflow/core/platform/env.h" 24 #include "tensorflow/core/platform/file_system.h" 25 #include "tensorflow/core/platform/file_system_helper.h" 26 27 namespace tensorflow { 28 29 // START_SKIP_DOXYGEN 30 31 #ifndef SWIG 32 // Degenerate file system that provides no implementations. 33 class NullFileSystem : public FileSystem { 34 public: NullFileSystem()35 NullFileSystem() {} 36 37 ~NullFileSystem() override = default; 38 NewRandomAccessFile(const string & fname,std::unique_ptr<RandomAccessFile> * result)39 Status NewRandomAccessFile( 40 const string& fname, std::unique_ptr<RandomAccessFile>* result) override { 41 return errors::Unimplemented("NewRandomAccessFile unimplemented"); 42 } 43 NewWritableFile(const string & fname,std::unique_ptr<WritableFile> * result)44 Status NewWritableFile(const string& fname, 45 std::unique_ptr<WritableFile>* result) override { 46 return errors::Unimplemented("NewWritableFile unimplemented"); 47 } 48 NewAppendableFile(const string & fname,std::unique_ptr<WritableFile> * result)49 Status NewAppendableFile(const string& fname, 50 std::unique_ptr<WritableFile>* result) override { 51 return errors::Unimplemented("NewAppendableFile unimplemented"); 52 } 53 NewReadOnlyMemoryRegionFromFile(const string & fname,std::unique_ptr<ReadOnlyMemoryRegion> * result)54 Status NewReadOnlyMemoryRegionFromFile( 55 const string& fname, 56 std::unique_ptr<ReadOnlyMemoryRegion>* result) override { 57 return errors::Unimplemented( 58 "NewReadOnlyMemoryRegionFromFile unimplemented"); 59 } 60 FileExists(const string & fname)61 Status FileExists(const string& fname) override { 62 return errors::Unimplemented("FileExists unimplemented"); 63 } 64 GetChildren(const string & dir,std::vector<string> * result)65 Status GetChildren(const string& dir, std::vector<string>* result) override { 66 return errors::Unimplemented("GetChildren unimplemented"); 67 } 68 GetMatchingPaths(const string & pattern,std::vector<string> * results)69 Status GetMatchingPaths(const string& pattern, 70 std::vector<string>* results) override { 71 return internal::GetMatchingPaths(this, Env::Default(), pattern, results); 72 } 73 DeleteFile(const string & fname)74 Status DeleteFile(const string& fname) override { 75 return errors::Unimplemented("DeleteFile unimplemented"); 76 } 77 CreateDir(const string & dirname)78 Status CreateDir(const string& dirname) override { 79 return errors::Unimplemented("CreateDir unimplemented"); 80 } 81 DeleteDir(const string & dirname)82 Status DeleteDir(const string& dirname) override { 83 return errors::Unimplemented("DeleteDir unimplemented"); 84 } 85 GetFileSize(const string & fname,uint64 * file_size)86 Status GetFileSize(const string& fname, uint64* file_size) override { 87 return errors::Unimplemented("GetFileSize unimplemented"); 88 } 89 RenameFile(const string & src,const string & target)90 Status RenameFile(const string& src, const string& target) override { 91 return errors::Unimplemented("RenameFile unimplemented"); 92 } 93 Stat(const string & fname,FileStatistics * stat)94 Status Stat(const string& fname, FileStatistics* stat) override { 95 return errors::Unimplemented("Stat unimplemented"); 96 } 97 }; 98 #endif 99 100 // END_SKIP_DOXYGEN 101 102 } // namespace tensorflow 103 104 #endif // TENSORFLOW_CORE_PLATFORM_NULL_FILE_SYSTEM_H_ 105