Home | History | Annotate | Download | only in windows
      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/lib/io/path.h"
     20 #include "tensorflow/core/platform/file_system.h"
     21 
     22 #ifdef PLATFORM_WINDOWS
     23 #undef DeleteFile
     24 #endif
     25 
     26 namespace tensorflow {
     27 
     28 class WindowsFileSystem : public FileSystem {
     29  public:
     30   WindowsFileSystem() {}
     31 
     32   ~WindowsFileSystem() {}
     33 
     34   Status NewRandomAccessFile(
     35       const string& fname, std::unique_ptr<RandomAccessFile>* result) override;
     36 
     37   Status NewWritableFile(const string& fname,
     38                          std::unique_ptr<WritableFile>* result) override;
     39 
     40   Status NewAppendableFile(const string& fname,
     41                            std::unique_ptr<WritableFile>* result) override;
     42 
     43   Status NewReadOnlyMemoryRegionFromFile(
     44       const string& fname,
     45       std::unique_ptr<ReadOnlyMemoryRegion>* result) override;
     46 
     47   Status FileExists(const string& fname) override;
     48 
     49   Status GetChildren(const string& dir, std::vector<string>* result) override;
     50 
     51   Status GetMatchingPaths(const string& pattern,
     52                           std::vector<string>* result) override;
     53 
     54   Status Stat(const string& fname, FileStatistics* stat) override;
     55 
     56   Status DeleteFile(const string& fname) override;
     57 
     58   Status CreateDir(const string& name) override;
     59 
     60   Status DeleteDir(const string& name) override;
     61 
     62   Status GetFileSize(const string& fname, uint64* size) override;
     63 
     64   Status RenameFile(const string& src, const string& target) override;
     65 
     66   string TranslateName(const string& name) const override { return name; }
     67 };
     68 
     69 class LocalWinFileSystem : public WindowsFileSystem {
     70  public:
     71   string TranslateName(const string& name) const override {
     72     StringPiece scheme, host, path;
     73     io::ParseURI(name, &scheme, &host, &path);
     74     return string(path);
     75   }
     76 };
     77 
     78 }  // namespace tensorflow
     79 
     80 #endif  // TENSORFLOW_CORE_PLATFORM_WINDOWS_WINDOWS_FILE_SYSTEM_H_
     81