Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
221
Merge Requests
221
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
50a8bb85
Commit
50a8bb85
authored
Mar 15, 2012
by
Dries
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Patch
#1473600
by amateescu, Berdir: Convert archiver.inc to
PSR-0
.
parent
eab48b59
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
4 additions
and
2105 deletions
+4
-2105
core/includes/archiver.inc
core/includes/archiver.inc
+0
-68
core/modules/system/system.api.php
core/modules/system/system.api.php
+1
-1
core/modules/system/system.archiver.inc
core/modules/system/system.archiver.inc
+0
-139
core/modules/system/system.info
core/modules/system/system.info
+0
-2
core/modules/system/system.module
core/modules/system/system.module
+2
-2
core/modules/system/system.tar.inc
core/modules/system/system.tar.inc
+0
-1892
core/modules/update/tests/update_test.module
core/modules/update/tests/update_test.module
+1
-1
No files found.
core/includes/archiver.inc
deleted
100644 → 0
View file @
eab48b59
<?php
/**
* @file
* Shared classes and interfaces for the archiver system.
*/
/**
* Defines the common interface for all Archiver classes.
*/
interface
ArchiverInterface
{
/**
* Constructs a new archiver instance.
*
* @param $file_path
* The full system path of the archive to manipulate. Only local files
* are supported. If the file does not yet exist, it will be created if
* appropriate.
*/
public
function
__construct
(
$file_path
);
/**
* Adds the specified file or directory to the archive.
*
* @param $file_path
* The full system path of the file or directory to add. Only local files
* and directories are supported.
*
* @return ArchiverInterface
* The called object.
*/
public
function
add
(
$file_path
);
/**
* Removes the specified file from the archive.
*
* @param $path
* The file name relative to the root of the archive to remove.
*
* @return ArchiverInterface
* The called object.
*/
public
function
remove
(
$path
);
/**
* Extracts multiple files in the archive to the specified path.
*
* @param $path
* A full system path of the directory to which to extract files.
* @param $files
* Optionally specify a list of files to be extracted. Files are
* relative to the root of the archive. If not specified, all files
* in the archive will be extracted.
*
* @return ArchiverInterface
* The called object.
*/
public
function
extract
(
$path
,
array
$files
=
array
());
/**
* Lists all files in the archive.
*
* @return
* An array of file names relative to the root of the archive.
*/
public
function
listContents
();
}
core/modules/system/system.api.php
View file @
50a8bb85
...
...
@@ -3493,7 +3493,7 @@ function hook_action_info_alter(&$actions) {
function
hook_archiver_info
()
{
return
array
(
'tar'
=>
array
(
'class'
=>
'
Archiver
Tar'
,
'class'
=>
'
Drupal\Component\Archiver\
Tar'
,
'extensions'
=>
array
(
'tar'
,
'tar.gz'
,
'tar.bz2'
),
),
);
...
...
core/modules/system/system.archiver.inc
deleted
100644 → 0
View file @
eab48b59
<?php
/**
* @file
* Archiver implementations provided by the system module.
*/
/**
* Archiver for .tar files.
*/
class
ArchiverTar
implements
ArchiverInterface
{
/**
* The underlying Archive_Tar instance that does the heavy lifting.
*
* @var Archive_Tar
*/
protected
$tar
;
public
function
__construct
(
$file_path
)
{
$this
->
tar
=
new
Archive_Tar
(
$file_path
);
}
public
function
add
(
$file_path
)
{
$this
->
tar
->
add
(
$file_path
);
return
$this
;
}
public
function
remove
(
$file_path
)
{
// @todo Archive_Tar doesn't have a remove operation
// so we'll have to simulate it somehow, probably by
// creating a new archive with everything but the removed
// file.
return
$this
;
}
public
function
extract
(
$path
,
Array
$files
=
array
())
{
if
(
$files
)
{
$this
->
tar
->
extractList
(
$files
,
$path
);
}
else
{
$this
->
tar
->
extract
(
$path
);
}
return
$this
;
}
public
function
listContents
()
{
$files
=
array
();
foreach
(
$this
->
tar
->
listContent
()
as
$file_data
)
{
$files
[]
=
$file_data
[
'filename'
];
}
return
$files
;
}
/**
* Retrieve the tar engine itself.
*
* In some cases it may be necessary to directly access the underlying
* Archive_Tar object for implementation-specific logic. This is for advanced
* use only as it is not shared by other implementations of ArchiveInterface.
*
* @return
* The Archive_Tar object used by this object.
*/
public
function
getArchive
()
{
return
$this
->
tar
;
}
}
/**
* Archiver for .zip files.
*
* @link http://php.net/zip
*/
class
ArchiverZip
implements
ArchiverInterface
{
/**
* The underlying ZipArchive instance that does the heavy lifting.
*
* @var ZipArchive
*/
protected
$zip
;
public
function
__construct
(
$file_path
)
{
$this
->
zip
=
new
ZipArchive
();
if
(
$this
->
zip
->
open
(
$file_path
)
!==
TRUE
)
{
// @todo: This should be an interface-specific exception some day.
throw
new
Exception
(
t
(
'Cannot open %file_path'
,
array
(
'%file_path'
=>
$file_path
)));
}
}
public
function
add
(
$file_path
)
{
$this
->
zip
->
addFile
(
$file_path
);
return
$this
;
}
public
function
remove
(
$file_path
)
{
$this
->
zip
->
deleteName
(
$file_path
);
return
$this
;
}
public
function
extract
(
$path
,
Array
$files
=
array
())
{
if
(
$files
)
{
$this
->
zip
->
extractTo
(
$path
,
$files
);
}
else
{
$this
->
zip
->
extractTo
(
$path
);
}
return
$this
;
}
public
function
listContents
()
{
$files
=
array
();
for
(
$i
=
0
;
$i
<
$this
->
zip
->
numFiles
;
$i
++
)
{
$files
[]
=
$this
->
zip
->
getNameIndex
(
$i
);
}
return
$files
;
}
/**
* Retrieve the zip engine itself.
*
* In some cases it may be necessary to directly access the underlying
* ZipArchive object for implementation-specific logic. This is for advanced
* use only as it is not shared by other implementations of ArchiveInterface.
*
* @return
* The ZipArchive object used by this object.
*/
public
function
getArchive
()
{
return
$this
->
zip
;
}
}
core/modules/system/system.info
View file @
50a8bb85
...
...
@@ -3,8 +3,6 @@ description = Handles general site configuration for administrators.
package
=
Core
version
=
VERSION
core
=
8.
x
files
[]
=
system
.
archiver
.
inc
files
[]
=
system
.
tar
.
inc
files
[]
=
system
.
test
required
=
TRUE
configure
=
admin
/
config
/
system
core/modules/system/system.module
View file @
50a8bb85
...
...
@@ -3948,12 +3948,12 @@ function system_date_format_delete($dfid) {
*/
function
system_archiver_info
()
{
$archivers
[
'tar'
]
=
array
(
'class'
=>
'
Archiver
Tar'
,
'class'
=>
'
Drupal\Component\Archiver\
Tar'
,
'extensions'
=>
array
(
'tar'
,
'tgz'
,
'tar.gz'
,
'tar.bz2'
),
);
if
(
function_exists
(
'zip_open'
))
{
$archivers
[
'zip'
]
=
array
(
'class'
=>
'
Archiver
Zip'
,
'class'
=>
'
Drupal\Component\Archiver\
Zip'
,
'extensions'
=>
array
(
'zip'
),
);
}
...
...
core/modules/system/system.tar.inc
deleted
100644 → 0
View file @
eab48b59
This diff is collapsed.
Click to expand it.
core/modules/update/tests/update_test.module
View file @
50a8bb85
...
...
@@ -121,7 +121,7 @@ function update_test_archiver_info() {
return
array
(
'update_test_archiver'
=>
array
(
// This is bogus, we only care about the extensions for now.
'class'
=>
'
Archiver
UpdateTest'
,
'class'
=>
'
Drupal\Component\Archiver\
UpdateTest'
,
'extensions'
=>
array
(
'update-test-extension'
),
),
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment