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 versions = dict((filename, os.stat(os.path.join(path, filename)).st_mtime) | |
57 for filename in os.listdir(path)) | |
58 return self.StatInfo(os.stat(path).st_mtime, versions) | |
59 | |
55 def Stat(self, path): | 60 def Stat(self, path): |
56 try: | 61 try: |
57 return self.StatInfo( | 62 if not path.endswith('/'): |
58 os.stat(os.path.join(self._base_path, path)).st_mtime) | 63 return self.StatInfo( |
64 os.stat(os.path.join(self._base_path, path)).st_mtime, {}) | |
not at google - send to devlin
2012/08/13 05:34:15
This logic is basically repeated in _CreateStatInf
cduvall
2012/08/13 19:45:45
Done.
| |
65 return self._CreateStatInfo(os.path.join(self._base_path, path)) | |
59 except OSError: | 66 except OSError: |
60 raise file_system.FileNotFoundError(path) | 67 raise file_system.FileNotFoundError(path) |
61 | |
OLD | NEW |