コード例 #1
0
    def testFileEntryExistsByPathSpec(self):
        """Test the file entry exists by path specification functionality."""
        file_system = zip_file_system.ZipFileSystem(self._resolver_context)
        self.assertIsNotNone(file_system)

        file_system.Open(self._zip_path_spec)

        path_spec = zip_path_spec.ZipPathSpec(location='/syslog',
                                              parent=self._os_path_spec)
        self.assertTrue(file_system.FileEntryExistsByPathSpec(path_spec))

        path_spec = zip_path_spec.ZipPathSpec(location='/bogus',
                                              parent=self._os_path_spec)
        self.assertFalse(file_system.FileEntryExistsByPathSpec(path_spec))

        file_system.Close()

        # Test on a zip file that has missing directory entries.
        test_file = self._GetTestFilePath(['missing_directory_entries.zip'])
        test_file_path_spec = os_path_spec.OSPathSpec(location=test_file)
        path_spec = zip_path_spec.ZipPathSpec(location='/',
                                              parent=test_file_path_spec)

        file_system = zip_file_system.ZipFileSystem(self._resolver_context)
        self.assertIsNotNone(file_system)
        file_system.Open(path_spec)

        path_spec = zip_path_spec.ZipPathSpec(location='/folder',
                                              parent=test_file_path_spec)
        self.assertTrue(file_system.FileEntryExistsByPathSpec(path_spec))

        path_spec = zip_path_spec.ZipPathSpec(location='/folder/syslog',
                                              parent=test_file_path_spec)
        self.assertTrue(file_system.FileEntryExistsByPathSpec(path_spec))

        file_system.Close()
コード例 #2
0
    def testFileEntryExistsByPathSpec(self):
        """Test the file entry exists by path specification functionality."""
        file_system = zip_file_system.ZipFileSystem(self._resolver_context)
        self.assertNotEqual(file_system, None)

        file_system.Open(path_spec=self._zip_path_spec)

        path_spec = zip_path_spec.ZipPathSpec(location=u'/syslog',
                                              parent=self._os_path_spec)
        self.assertTrue(file_system.FileEntryExistsByPathSpec(path_spec))

        path_spec = zip_path_spec.ZipPathSpec(location=u'/bogus',
                                              parent=self._os_path_spec)
        self.assertFalse(file_system.FileEntryExistsByPathSpec(path_spec))

        file_system.Close()
コード例 #3
0
    def testGetFileEntryByPathSpec(self):
        """Test the get entry by path specification functionality."""
        file_system = zip_file_system.ZipFileSystem(self._resolver_context)
        self.assertNotEqual(file_system, None)

        file_system.Open(path_spec=self._zip_path_spec)

        path_spec = zip_path_spec.ZipPathSpec(location=u'/syslog',
                                              parent=self._os_path_spec)
        file_entry = file_system.GetFileEntryByPathSpec(path_spec)

        self.assertNotEqual(file_entry, None)
        self.assertEqual(file_entry.name, u'syslog')

        path_spec = zip_path_spec.ZipPathSpec(location=u'/bogus',
                                              parent=self._os_path_spec)
        file_entry = file_system.GetFileEntryByPathSpec(path_spec)

        self.assertEqual(file_entry, None)

        file_system.Close()
コード例 #4
0
    def testGetFileEntryByPathSpec(self):
        """Tests the GetFileEntryByPathSpec function."""
        file_system = zip_file_system.ZipFileSystem(self._resolver_context)
        self.assertIsNotNone(file_system)

        file_system.Open(self._zip_path_spec)

        path_spec = zip_path_spec.ZipPathSpec(location=u'/syslog',
                                              parent=self._os_path_spec)
        file_entry = file_system.GetFileEntryByPathSpec(path_spec)

        self.assertIsNotNone(file_entry)
        self.assertEqual(file_entry.name, u'syslog')

        path_spec = zip_path_spec.ZipPathSpec(location=u'/bogus',
                                              parent=self._os_path_spec)
        file_entry = file_system.GetFileEntryByPathSpec(path_spec)

        self.assertIsNone(file_entry)

        file_system.Close()