OLD | NEW |
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 """The Volume Shadow Snapshots (VSS) file system implementation.""" | 2 """The Volume Shadow Snapshots (VSS) file system implementation.""" |
3 | 3 |
4 from __future__ import unicode_literals | 4 from __future__ import unicode_literals |
5 | 5 |
6 import pyvshadow | 6 import pyvshadow |
7 | 7 |
8 # This is necessary to prevent a circular import. | |
9 import dfvfs.vfs.vshadow_file_entry | |
10 | |
11 from dfvfs.lib import definitions | 8 from dfvfs.lib import definitions |
12 from dfvfs.lib import errors | 9 from dfvfs.lib import errors |
13 from dfvfs.lib import vshadow | 10 from dfvfs.lib import vshadow |
14 from dfvfs.path import vshadow_path_spec | 11 from dfvfs.path import vshadow_path_spec |
15 from dfvfs.resolver import resolver | 12 from dfvfs.resolver import resolver |
16 from dfvfs.vfs import file_system | 13 from dfvfs.vfs import file_system |
| 14 from dfvfs.vfs import vshadow_file_entry |
17 | 15 |
18 | 16 |
19 class VShadowFileSystem(file_system.FileSystem): | 17 class VShadowFileSystem(file_system.FileSystem): |
20 """File system that uses pyvshadow.""" | 18 """File system that uses pyvshadow.""" |
21 | 19 |
22 LOCATION_ROOT = '/' | 20 LOCATION_ROOT = '/' |
23 TYPE_INDICATOR = definitions.TYPE_INDICATOR_VSHADOW | 21 TYPE_INDICATOR = definitions.TYPE_INDICATOR_VSHADOW |
24 | 22 |
25 def __init__(self, resolver_context): | 23 def __init__(self, resolver_context): |
26 """Initializes a file system. | 24 """Initializes a file system. |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 VShadowFileEntry: file entry or None if not available. | 102 VShadowFileEntry: file entry or None if not available. |
105 """ | 103 """ |
106 store_index = vshadow.VShadowPathSpecGetStoreIndex(path_spec) | 104 store_index = vshadow.VShadowPathSpecGetStoreIndex(path_spec) |
107 | 105 |
108 # The virtual root file has not corresponding store index but | 106 # The virtual root file has not corresponding store index but |
109 # should have a location. | 107 # should have a location. |
110 if store_index is None: | 108 if store_index is None: |
111 location = getattr(path_spec, 'location', None) | 109 location = getattr(path_spec, 'location', None) |
112 if location is None or location != self.LOCATION_ROOT: | 110 if location is None or location != self.LOCATION_ROOT: |
113 return | 111 return |
114 return dfvfs.vfs.vshadow_file_entry.VShadowFileEntry( | 112 return vshadow_file_entry.VShadowFileEntry( |
115 self._resolver_context, self, path_spec, is_root=True, | 113 self._resolver_context, self, path_spec, is_root=True, |
116 is_virtual=True) | 114 is_virtual=True) |
117 | 115 |
118 if store_index < 0 or store_index >= self._vshadow_volume.number_of_stores: | 116 if store_index < 0 or store_index >= self._vshadow_volume.number_of_stores: |
119 return | 117 return |
120 return dfvfs.vfs.vshadow_file_entry.VShadowFileEntry( | 118 return vshadow_file_entry.VShadowFileEntry( |
121 self._resolver_context, self, path_spec) | 119 self._resolver_context, self, path_spec) |
122 | 120 |
123 def GetRootFileEntry(self): | 121 def GetRootFileEntry(self): |
124 """Retrieves the root file entry. | 122 """Retrieves the root file entry. |
125 | 123 |
126 Returns: | 124 Returns: |
127 VShadowFileEntry: file entry or None if not available. | 125 VShadowFileEntry: file entry or None if not available. |
128 """ | 126 """ |
129 path_spec = vshadow_path_spec.VShadowPathSpec( | 127 path_spec = vshadow_path_spec.VShadowPathSpec( |
130 location=self.LOCATION_ROOT, parent=self._path_spec.parent) | 128 location=self.LOCATION_ROOT, parent=self._path_spec.parent) |
(...skipping 12 matching lines...) Expand all Loading... |
143 if store_index is not None: | 141 if store_index is not None: |
144 return self._vshadow_volume.get_store(store_index) | 142 return self._vshadow_volume.get_store(store_index) |
145 | 143 |
146 def GetVShadowVolume(self): | 144 def GetVShadowVolume(self): |
147 """Retrieves a VSS volume. | 145 """Retrieves a VSS volume. |
148 | 146 |
149 Returns: | 147 Returns: |
150 pyvshadow.volume: a VSS volume. | 148 pyvshadow.volume: a VSS volume. |
151 """ | 149 """ |
152 return self._vshadow_volume | 150 return self._vshadow_volume |
OLD | NEW |