OLD | NEW |
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 """The encrypted stream file system implementation.""" | 2 """The encrypted stream file system implementation.""" |
3 | 3 |
| 4 from __future__ import unicode_literals |
| 5 |
4 from dfvfs.lib import definitions | 6 from dfvfs.lib import definitions |
5 from dfvfs.lib import errors | 7 from dfvfs.lib import errors |
6 from dfvfs.path import encrypted_stream_path_spec | 8 from dfvfs.path import encrypted_stream_path_spec |
7 from dfvfs.resolver import resolver | 9 from dfvfs.resolver import resolver |
8 from dfvfs.vfs import encrypted_stream_file_entry | 10 from dfvfs.vfs import encrypted_stream_file_entry |
9 from dfvfs.vfs import root_only_file_system | 11 from dfvfs.vfs import root_only_file_system |
10 | 12 |
11 | 13 |
12 class EncryptedStreamFileSystem(root_only_file_system.RootOnlyFileSystem): | 14 class EncryptedStreamFileSystem(root_only_file_system.RootOnlyFileSystem): |
13 """Class that implements a compresses stream file system object.""" | 15 """Class that implements a compresses stream file system object.""" |
(...skipping 25 matching lines...) Expand all Loading... |
39 mode: optional file access mode. The default is 'rb' read-only binary. | 41 mode: optional file access mode. The default is 'rb' read-only binary. |
40 | 42 |
41 Raises: | 43 Raises: |
42 AccessError: if the access to open the file was denied. | 44 AccessError: if the access to open the file was denied. |
43 IOError: if the file system object could not be opened. | 45 IOError: if the file system object could not be opened. |
44 PathSpecError: if the path specification is incorrect. | 46 PathSpecError: if the path specification is incorrect. |
45 ValueError: if the path specification is invalid. | 47 ValueError: if the path specification is invalid. |
46 """ | 48 """ |
47 if not path_spec.HasParent(): | 49 if not path_spec.HasParent(): |
48 raise errors.PathSpecError( | 50 raise errors.PathSpecError( |
49 u'Unsupported path specification without parent.') | 51 'Unsupported path specification without parent.') |
50 | 52 |
51 resolver.Resolver.key_chain.ExtractCredentialsFromPathSpec(path_spec) | 53 resolver.Resolver.key_chain.ExtractCredentialsFromPathSpec(path_spec) |
52 | 54 |
53 encryption_method = getattr(path_spec, u'encryption_method', None) | 55 encryption_method = getattr(path_spec, 'encryption_method', None) |
54 if not encryption_method: | 56 if not encryption_method: |
55 raise errors.PathSpecError( | 57 raise errors.PathSpecError( |
56 u'Unsupported path specification without encryption method.') | 58 'Unsupported path specification without encryption method.') |
57 | 59 |
58 self._encryption_method = encryption_method | 60 self._encryption_method = encryption_method |
59 | 61 |
60 def GetFileEntryByPathSpec(self, path_spec): | 62 def GetFileEntryByPathSpec(self, path_spec): |
61 """Retrieves a file entry for a path specification. | 63 """Retrieves a file entry for a path specification. |
62 | 64 |
63 Args: | 65 Args: |
64 path_spec: a path specification (instance of PathSpec). | 66 path_spec: a path specification (instance of PathSpec). |
65 | 67 |
66 Returns: | 68 Returns: |
67 A file entry (instance of vfs.FileEntry) or None. | 69 A file entry (instance of vfs.FileEntry) or None. |
68 """ | 70 """ |
69 return encrypted_stream_file_entry.EncryptedStreamFileEntry( | 71 return encrypted_stream_file_entry.EncryptedStreamFileEntry( |
70 self._resolver_context, self, path_spec, is_root=True, is_virtual=True) | 72 self._resolver_context, self, path_spec, is_root=True, is_virtual=True) |
71 | 73 |
72 def GetRootFileEntry(self): | 74 def GetRootFileEntry(self): |
73 """Retrieves the root file entry. | 75 """Retrieves the root file entry. |
74 | 76 |
75 Returns: | 77 Returns: |
76 A file entry (instance of vfs.FileEntry) or None. | 78 A file entry (instance of vfs.FileEntry) or None. |
77 """ | 79 """ |
78 path_spec = encrypted_stream_path_spec.EncryptedStreamPathSpec( | 80 path_spec = encrypted_stream_path_spec.EncryptedStreamPathSpec( |
79 encryption_method=self._encryption_method, | 81 encryption_method=self._encryption_method, |
80 parent=self._path_spec.parent) | 82 parent=self._path_spec.parent) |
81 return self.GetFileEntryByPathSpec(path_spec) | 83 return self.GetFileEntryByPathSpec(path_spec) |
OLD | NEW |