From ff9f16ddf447e406d5589e78b09aea0d450e0fd4 Mon Sep 17 00:00:00 2001 From: Neil Blakey-Milner Date: Tue, 20 Sep 2005 10:32:06 +0000 Subject: [PATCH] Add KTZipImportStorage, which can be used to bulk import documents from a zip file. --- lib/import/zipimportstorage.inc.php | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+), 0 deletions(-) create mode 100644 lib/import/zipimportstorage.inc.php diff --git a/lib/import/zipimportstorage.inc.php b/lib/import/zipimportstorage.inc.php new file mode 100644 index 0000000..3677b89 --- /dev/null +++ b/lib/import/zipimportstorage.inc.php @@ -0,0 +1,64 @@ +sZipPath = $sZipPath; + } + + function init() { + $sTmpPath = tempnam('/tmp', 'zipimportstorage'); + if ($sTmpPath === false) { + return PEAR::raiseError("Could not create temporary directory for zip storage"); + } + unlink($sTmpPath); + mkdir($sTmpPath, 0700); + $this->sBasePath = $sTmpPath; + $aArgs = array( + "unzip", + "-q", "-n", + "-d", $sTmpPath, + $this->sZipPath + ); + $sCommand = KTUtil::safeShellString($aArgs); + $res = system($sCommand); + if ($res === false) { + return PEAR::raiseError("Could not retrieve contents from zip storage"); + } + } + function cleanup() { + if ($this->sBasePath && file_exists($this->sBasePath)) { + // XXX: Only works on Unix-like systems for now. + system(KTUtil::safeShellString(array('/bin/rm', '-rf', $this->sBasePath))); + $this->sBasePath = null; + } + } +} + +?> -- libgit2 0.21.4