Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions dfvfs/file_io/vmdk_file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,14 @@ def _OpenFileObject(self, path_spec):
)

# Note that we cannot use pyvmdk's open_extent_data_files_as_file_objects
# function since it does not handle the file system abstraction dfVFS
# provides.
# function since it does not handle the file system abstraction dfVFS provides.

file_system = resolver.Resolver.OpenFileSystem(
parent_path_spec, resolver_context=self._resolver_context
)

file_object = resolver.Resolver.OpenFileObject(
parent_path_spec, resolver_context=self._resolver_context
)

vmdk_handle = pyvmdk.handle()
vmdk_handle.open_file_object(file_object)

Expand All @@ -64,19 +61,19 @@ def _OpenFileObject(self, path_spec):
filename = extent_data_filename

# The last parent location path segment contains the extent data filename.
# Since we want to check if the next extent data file exists we remove
# the previous one form the path segments list and add the new filename.
# After that the path segments list can be used to create the location
# string.
# Since we want to check if the next extent data file exists we remove the
# previous one form the path segments list and add the new filename. After
# that the path segments list can be used to create the location string.

parent_location_path_segments.pop()
parent_location_path_segments.append(filename)
extent_data_file_location = file_system.JoinPath(
parent_location_path_segments
)
# Note that we do not want to set the keyword arguments when not used
# because the path specification base class will check for unused keyword
# arguments and raise.

# Note that we don't want to set the keyword arguments when not used
# because the path specification base class will check for unused
# keyword arguments and raise.
kwargs = path_spec_factory.Factory.GetProperties(parent_path_spec)

kwargs["location"] = extent_data_file_location
Expand All @@ -86,9 +83,21 @@ def _OpenFileObject(self, path_spec):
extent_data_file_path_spec = path_spec_factory.Factory.NewPathSpec(
parent_path_spec.type_indicator, **kwargs
)

if not file_system.FileEntryExistsByPathSpec(extent_data_file_path_spec):
break
if vmdk_handle.number_of_extents > 1:
break

if vmdk_handle.disk_type not in (
pyvmdk.disk_types.MONOLITHIC_SPARSE,
pyvmdk.disk_types.STREAM_OPTIMIZED,
):
break

if extent_descriptor.type != pyvmdk.extent_types.SPARSE:
break

# VMDK file was likely renamed.
extent_data_file_path_spec = parent_path_spec

extent_data_files.append(extent_data_file_path_spec)

Expand Down
Loading