1 /* Copyright 2015 Google Inc. 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_WINDOWS_WINDOWS_FILE_SYSTEM_H_ 17 #define TENSORFLOW_CORE_PLATFORM_WINDOWS_WINDOWS_FILE_SYSTEM_H_ 18 19 #include "tensorflow/core/platform/file_system.h" 20 #include "tensorflow/core/platform/path.h" 21 #include "tensorflow/core/platform/platform.h" 22 23 #ifdef PLATFORM_WINDOWS 24 #undef DeleteFile 25 #endif 26 27 namespace tensorflow { 28 29 class WindowsFileSystem : public FileSystem { 30 public: WindowsFileSystem()31 WindowsFileSystem() {} 32 ~WindowsFileSystem()33 ~WindowsFileSystem() {} 34 35 TF_USE_FILESYSTEM_METHODS_WITH_NO_TRANSACTION_SUPPORT; 36 37 Status NewRandomAccessFile( 38 const string& fname, TransactionToken* token, 39 std::unique_ptr<RandomAccessFile>* result) override; 40 41 Status NewWritableFile(const string& fname, TransactionToken* token, 42 std::unique_ptr<WritableFile>* result) override; 43 44 Status NewAppendableFile(const string& fname, TransactionToken* token, 45 std::unique_ptr<WritableFile>* result) override; 46 47 Status NewReadOnlyMemoryRegionFromFile( 48 const string& fname, TransactionToken* token, 49 std::unique_ptr<ReadOnlyMemoryRegion>* result) override; 50 51 Status FileExists(const string& fname, TransactionToken* token) override; 52 53 Status GetChildren(const string& dir, TransactionToken* token, 54 std::vector<string>* result) override; 55 56 Status GetMatchingPaths(const string& pattern, TransactionToken* token, 57 std::vector<string>* result) override; 58 59 bool Match(const string& filename, const string& pattern) override; 60 61 Status Stat(const string& fname, TransactionToken* token, 62 FileStatistics* stat) override; 63 64 Status DeleteFile(const string& fname, TransactionToken* token) override; 65 66 Status CreateDir(const string& name, TransactionToken* token) override; 67 68 Status DeleteDir(const string& name, TransactionToken* token) override; 69 70 Status GetFileSize(const string& fname, TransactionToken* token, 71 uint64* size) override; 72 73 Status IsDirectory(const string& fname, TransactionToken* token) override; 74 75 Status RenameFile(const string& src, const string& target, 76 TransactionToken* token) override; 77 TranslateName(const string & name)78 string TranslateName(const string& name) const override { return name; } 79 Separator()80 char Separator() const override { return '\\'; }; 81 }; 82 83 class LocalWinFileSystem : public WindowsFileSystem { 84 public: TranslateName(const string & name)85 string TranslateName(const string& name) const override { 86 StringPiece scheme, host, path; 87 io::ParseURI(name, &scheme, &host, &path); 88 return string(path); 89 } 90 }; 91 92 } // namespace tensorflow 93 94 #endif // TENSORFLOW_CORE_PLATFORM_WINDOWS_WINDOWS_FILE_SYSTEM_H_ 95