mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-12 12:41:30 +00:00
- fixed creation of human readable archives
This commit is contained in:
parent
720d5532a8
commit
5aa68fb85a
|
@ -37,7 +37,9 @@ if (!$user->isAdmin()) {
|
||||||
* be followed by '/'
|
* be followed by '/'
|
||||||
*/
|
*/
|
||||||
function TarAddHeader($f,$phisfn,$archfn) { /* {{{ */
|
function TarAddHeader($f,$phisfn,$archfn) { /* {{{ */
|
||||||
$info=stat($phisfn);
|
$info=@stat($phisfn);
|
||||||
|
if($info === false)
|
||||||
|
return false;
|
||||||
$ouid=sprintf("%6s ", decoct($info[4]));
|
$ouid=sprintf("%6s ", decoct($info[4]));
|
||||||
$ogid=sprintf("%6s ", decoct($info[5]));
|
$ogid=sprintf("%6s ", decoct($info[5]));
|
||||||
$omode=sprintf("%6s ", decoct(fileperms($phisfn)));
|
$omode=sprintf("%6s ", decoct(fileperms($phisfn)));
|
||||||
|
@ -79,16 +81,17 @@ function TarAddHeader($f,$phisfn,$archfn) { /* {{{ */
|
||||||
// phisfn: path to file
|
// phisfn: path to file
|
||||||
// code by calmarius at nospam dot atw dot hu
|
// code by calmarius at nospam dot atw dot hu
|
||||||
function TarWriteContents($f,$phisfn) { /* {{{ */
|
function TarWriteContents($f,$phisfn) { /* {{{ */
|
||||||
if (@is_dir($phisfn)) {
|
if(!file_exists($phisfn))
|
||||||
return;
|
return;
|
||||||
} else {
|
if (@is_dir($phisfn)) {
|
||||||
$size=filesize($phisfn);
|
return;
|
||||||
$padding=$size % 512 ? 512-$size%512 : 0;
|
}
|
||||||
$f2=fopen($phisfn,"rb");
|
$size=filesize($phisfn);
|
||||||
while (!feof($f2)) fwrite($f,fread($f2,1024*1024));
|
$padding=$size % 512 ? 512-$size%512 : 0;
|
||||||
$pstr=sprintf("a%d",$padding);
|
$f2=fopen($phisfn,"rb");
|
||||||
fwrite($f,pack($pstr,''));
|
while (!feof($f2)) fwrite($f,fread($f2,1024*1024));
|
||||||
}
|
$pstr=sprintf("a%d",$padding);
|
||||||
|
fwrite($f,pack($pstr,''));
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
// Adds 1024 byte footer at the end of the tar file
|
// Adds 1024 byte footer at the end of the tar file
|
||||||
|
@ -124,10 +127,10 @@ function createFolderTar($folder,$ark) { /* {{{ */
|
||||||
if (is_object($latestContent)) {
|
if (is_object($latestContent)) {
|
||||||
TarAddHeader(
|
TarAddHeader(
|
||||||
$ark,
|
$ark,
|
||||||
$dms->contentDir.$latestContent->getDir().$latestContent->getVersion().$latestContent->getFileType(),
|
$dms->contentDir.$latestContent->getPath(),
|
||||||
getFolderPathPlainAST($folder)."/".$document->getID()."_".mydmsDecodeString($latestContent->getOriginalFileName()));
|
getFolderPathPlainAST($folder)."/".$document->getID()."_".mydmsDecodeString($latestContent->getOriginalFileName()));
|
||||||
|
|
||||||
TarWriteContents($ark, $dms->contentDir.$latestContent->getDir().$latestContent->getVersion().$latestContent->getFileType());
|
TarWriteContents($ark, $dms->contentDir.$latestContent->getPath());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user