| OLD | NEW |
| 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2011 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 errno | 5 import errno |
| 6 import fnmatch | 6 import fnmatch |
| 7 import os | 7 import os |
| 8 import re | 8 import re |
| 9 import StringIO | 9 import StringIO |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 return self._sep | 31 return self._sep |
| 32 | 32 |
| 33 def _split(self, path): | 33 def _split(self, path): |
| 34 return path.rsplit(self.sep, 1) | 34 return path.rsplit(self.sep, 1) |
| 35 | 35 |
| 36 def abspath(self, path): | 36 def abspath(self, path): |
| 37 if path.endswith(self.sep): | 37 if path.endswith(self.sep): |
| 38 return path[:-1] | 38 return path[:-1] |
| 39 return path | 39 return path |
| 40 | 40 |
| 41 def basename(self, path): |
| 42 if self.sep not in path: |
| 43 return '' |
| 44 return self._split(path)[-1] or self.sep |
| 45 |
| 41 def dirname(self, path): | 46 def dirname(self, path): |
| 42 if self.sep not in path: | 47 if self.sep not in path: |
| 43 return '' | 48 return '' |
| 44 return self._split(path)[0] or self.sep | 49 return self._split(path)[0] or self.sep |
| 45 | 50 |
| 46 def exists(self, path): | 51 def exists(self, path): |
| 47 return self.isfile(path) or self.isdir(path) | 52 return self.isfile(path) or self.isdir(path) |
| 48 | 53 |
| 49 def isabs(self, path): | 54 def isabs(self, path): |
| 50 return path.startswith(self.sep) | 55 return path.startswith(self.sep) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 80 if self.files[path] is None: | 85 if self.files[path] is None: |
| 81 _RaiseNotFound(path) | 86 _RaiseNotFound(path) |
| 82 return self.files[path] | 87 return self.files[path] |
| 83 | 88 |
| 84 @staticmethod | 89 @staticmethod |
| 85 def relpath(path, base): | 90 def relpath(path, base): |
| 86 # This implementation is wrong in many ways; assert to check them for now. | 91 # This implementation is wrong in many ways; assert to check them for now. |
| 87 assert path.startswith(base) | 92 assert path.startswith(base) |
| 88 assert base.endswith('/') | 93 assert base.endswith('/') |
| 89 return path[len(base):] | 94 return path[len(base):] |
| OLD | NEW |