コード例 #1
0
ファイル: data_range_path_spec.py プロジェクト: tincho9/dfvfs
    def testInitialize(self):
        """Tests the path specification initialization."""
        path_spec = data_range_path_spec.DataRangePathSpec(
            range_offset=0x2000, range_size=0x1000, parent=self._path_spec)

        self.assertIsNotNone(path_spec)

        with self.assertRaises(ValueError):
            data_range_path_spec.DataRangePathSpec(range_offset=0x2000,
                                                   range_size=0x1000,
                                                   parent=None)

        with self.assertRaises(ValueError):
            data_range_path_spec.DataRangePathSpec(range_offset=0x2000,
                                                   range_size=None,
                                                   parent=self._path_spec)

        with self.assertRaises(ValueError):
            data_range_path_spec.DataRangePathSpec(range_offset=None,
                                                   range_size=0x1000,
                                                   parent=self._path_spec)

        with self.assertRaises(ValueError):
            data_range_path_spec.DataRangePathSpec(range_offset=None,
                                                   range_size=0x1000,
                                                   parent=self._path_spec,
                                                   bogus='BOGUS')
コード例 #2
0
 def setUp(self):
     """Sets up the needed objects used throughout the test."""
     self._resolver_context = context.Context()
     test_file = os.path.join(u'test_data', u'syslog')
     self._os_path_spec = os_path_spec.OSPathSpec(location=test_file)
     self._data_range_path_spec = data_range_path_spec.DataRangePathSpec(
         range_offset=167, range_size=1080, parent=self._os_path_spec)
コード例 #3
0
 def setUp(self):
     """Sets up the needed objects used throughout the test."""
     self._resolver_context = context.Context()
     test_file = self._GetTestFilePath([u'syslog'])
     path_spec = os_path_spec.OSPathSpec(location=test_file)
     self._data_range_path_spec = (data_range_path_spec.DataRangePathSpec(
         range_offset=0x1c0, range_size=0x41, parent=path_spec))
コード例 #4
0
ファイル: gzip_file_io.py プロジェクト: thezedwards/dfvfs
  def _OpenFileObject(self, path_spec):
    """Opens the file-like object defined by path specification.

    Args:
      path_spec: optional the path specification (instance of path.PathSpec).
                 The default is None.

    Returns:
      A file-like object.
    """
    gzip_file_object = resolver.Resolver.OpenFileObject(
        path_spec.parent, resolver_context=self._resolver_context)

    try:
      self._ReadFileHeader(gzip_file_object)
      self._ReadFileFooter(gzip_file_object)

    finally:
      gzip_file_object.close()

    path_spec_data_range = data_range_path_spec.DataRangePathSpec(
        range_offset=self._compressed_data_offset,
        range_size=self._compressed_data_size, parent=path_spec.parent)
    path_spec_compressed_stream = (
        compressed_stream_path_spec.CompressedStreamPathSpec(
            compression_method=definitions.COMPRESSION_METHOD_DEFLATE,
            parent=path_spec_data_range))

    return resolver.Resolver.OpenFileObject(
        path_spec_compressed_stream, resolver_context=self._resolver_context)
コード例 #5
0
    def GetRootFileEntry(self):
        """Retrieves the root file entry.

    Returns:
      DataRangeFileEntry: a file entry or None if not available.
    """
        path_spec = data_range_path_spec.DataRangePathSpec(
            range_offset=self._range_offset,
            range_size=self._range_size,
            parent=self._path_spec.parent)
        return self.GetFileEntryByPathSpec(path_spec)
コード例 #6
0
    def GetRootFileEntry(self):
        """Retrieves the root file entry.

    Returns:
      A file entry (instance of vfs.FileEntry) or None.
    """
        path_spec = data_range_path_spec.DataRangePathSpec(
            range_offset=self._range_offset,
            range_size=self._range_size,
            parent=self._path_spec.parent)
        return self.GetFileEntryByPathSpec(path_spec)
コード例 #7
0
    def setUp(self):
        """Sets up the needed objects used throughout the test."""
        self._resolver_context = context.Context()
        test_file = self._GetTestFilePath(['syslog'])
        self._SkipIfPathNotExists(test_file)

        path_spec = os_path_spec.OSPathSpec(location=test_file)
        self._data_range_path_spec = (data_range_path_spec.DataRangePathSpec(
            range_offset=0x1c0, range_size=0x41, parent=path_spec))

        self._file_system = (data_range_file_system.DataRangeFileSystem(
            self._resolver_context))
        self._file_system.Open(self._data_range_path_spec)
コード例 #8
0
  def testComparable(self):
    """Tests the path specification comparable property."""
    path_spec = data_range_path_spec.DataRangePathSpec(
        range_offset=0x2000, range_size=0x1000, parent=self._path_spec)

    self.assertNotEqual(path_spec, None)

    expected_comparable = u'\n'.join([
        u'type: TEST',
        u'type: DATA_RANGE, range_offset: 0x00002000, range_size: 0x00001000',
        u''])

    self.assertEqual(path_spec.comparable, expected_comparable)