| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import os | 5 import os |
| 6 | 6 |
| 7 import file_system | 7 import file_system |
| 8 from future import Future | 8 from future import Future |
| 9 | 9 |
| 10 class LocalFileSystem(file_system.FileSystem): | 10 class LocalFileSystem(file_system.FileSystem): |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 def Read(self, paths, binary=False): | 46 def Read(self, paths, binary=False): |
| 47 result = {} | 47 result = {} |
| 48 for path in paths: | 48 for path in paths: |
| 49 if path.endswith('/'): | 49 if path.endswith('/'): |
| 50 result[path] = self._ListDir(self._ConvertToFilepath(path)) | 50 result[path] = self._ListDir(self._ConvertToFilepath(path)) |
| 51 else: | 51 else: |
| 52 result[path] = self._ReadFile(self._ConvertToFilepath(path), binary) | 52 result[path] = self._ReadFile(self._ConvertToFilepath(path), binary) |
| 53 return Future(value=result) | 53 return Future(value=result) |
| 54 | 54 |
| 55 def _CreateStatInfo(self, path): |
| 56 if path.endswith('/'): |
| 57 versions = dict((filename, os.stat(os.path.join(path, filename)).st_mtime) |
| 58 for filename in os.listdir(path)) |
| 59 else: |
| 60 versions = None |
| 61 return self.StatInfo(os.stat(path).st_mtime, versions) |
| 62 |
| 55 def Stat(self, path): | 63 def Stat(self, path): |
| 56 try: | 64 try: |
| 57 return self.StatInfo( | 65 return self._CreateStatInfo(os.path.join(self._base_path, path)) |
| 58 os.stat(os.path.join(self._base_path, path)).st_mtime) | |
| 59 except OSError: | 66 except OSError: |
| 60 raise file_system.FileNotFoundError(path) | 67 raise file_system.FileNotFoundError(path) |
| 61 | |
| OLD | NEW |