def GetFileEntryByPathSpec(self, path_spec):
    """Retrieves a file entry for a path specification.

    Args:
      path_spec (PathSpec): a path specification.

    Returns:
      TSKPartitionFileEntry: a file entry or None of not available.
    """
    tsk_vs_part, partition_index = tsk_partition.GetTSKVsPartByPathSpec(
        self._tsk_volume, path_spec)

    location = getattr(path_spec, 'location', None)

    # The virtual root file has no corresponding TSK volume system part object
    # but should have a location.
    if tsk_vs_part is None:
      if location is None or location != self.LOCATION_ROOT:
        return None

      return tsk_partition_file_entry.TSKPartitionFileEntry(
          self._resolver_context, self, path_spec, is_root=True,
          is_virtual=True)

    if location is None and partition_index is not None:
      path_spec.location = '/p{0:d}'.format(partition_index)

    return tsk_partition_file_entry.TSKPartitionFileEntry(
        self._resolver_context, self, path_spec)
Esempio n. 2
0
    def testIntialize(self):
        """Test the initialize functionality."""
        file_entry = tsk_partition_file_entry.TSKPartitionFileEntry(
            self._resolver_context, self._file_system,
            self._tsk_partition_path_spec)

        self.assertIsNotNone(file_entry)
Esempio n. 3
0
    def testIntialize(self):
        """Test the __init__ function."""
        file_entry = tsk_partition_file_entry.TSKPartitionFileEntry(
            self._resolver_context,
            self._file_system,
            self._tsk_partition_path_spec,
            is_virtual=True)

        self.assertIsNotNone(file_entry)