summaryrefslogtreecommitdiffstats
path: root/heimdall-frontend/Source/Packaging.h
diff options
context:
space:
mode:
authorBenjamin Dobell <benjamin.dobell@glassechidna.com.au>2011-07-05 18:58:28 +0200
committerBenjamin Dobell <benjamin.dobell@glassechidna.com.au>2011-07-05 18:58:28 +0200
commitb6ffa766b21fe2c985437aa80824a3cd4c384de8 (patch)
treeda9f5c33b33074748bd981175d36d2974ff3fb98 /heimdall-frontend/Source/Packaging.h
parentMerge pull request #15 from alanorth/patch-1 (diff)
downloadHeimdall-b6ffa766b21fe2c985437aa80824a3cd4c384de8.tar
Heimdall-b6ffa766b21fe2c985437aa80824a3cd4c384de8.tar.gz
Heimdall-b6ffa766b21fe2c985437aa80824a3cd4c384de8.tar.bz2
Heimdall-b6ffa766b21fe2c985437aa80824a3cd4c384de8.tar.lz
Heimdall-b6ffa766b21fe2c985437aa80824a3cd4c384de8.tar.xz
Heimdall-b6ffa766b21fe2c985437aa80824a3cd4c384de8.tar.zst
Heimdall-b6ffa766b21fe2c985437aa80824a3cd4c384de8.zip
Diffstat (limited to '')
-rwxr-xr-xheimdall-frontend/Source/Packaging.h110
1 files changed, 110 insertions, 0 deletions
diff --git a/heimdall-frontend/Source/Packaging.h b/heimdall-frontend/Source/Packaging.h
new file mode 100755
index 0000000..c341f0f
--- /dev/null
+++ b/heimdall-frontend/Source/Packaging.h
@@ -0,0 +1,110 @@
+/* Copyright (c) 2010 Benjamin Dobell, Glass Echidna
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.*/
+
+#ifndef PACKAGING_H
+#define PACKAGING_H
+
+// Qt
+#include <QList>
+#include <QString>
+#include <QTemporaryFile>
+
+// Heimdall Frontend
+#include "PackageData.h"
+
+namespace HeimdallFrontend
+{
+ union TarHeader
+ {
+ enum
+ {
+ kBlockLength = 512,
+ kBlockReadCount = 8,
+ kBlockWriteCount = 8,
+
+ kTarHeaderLength = 257,
+ kUstarHeaderLength = 500,
+ };
+
+ enum : quint64
+ {
+ kMaxFileSize = 8589934592
+ };
+
+ enum
+ {
+ kModeOtherExecute = 1,
+ kModeOtherWrite = 1 << 1,
+ kModeOtherRead = 1 << 2,
+
+ kModeGroupExecute = 1 << 3,
+ kModeGroupWrite = 1 << 4,
+ kModeGroupRead = 1 << 5,
+
+ kModeOwnerExecute = 1 << 6,
+ kModeOwnerWrite = 1 << 7,
+ kModeOwnerRead = 1 << 8,
+
+ kModeReserved = 2 << 9,
+ kModeSetGid = 2 << 10,
+ kModeSetUid = 2 << 11
+ };
+
+ struct
+ {
+ char name[100];
+ char mode[8];
+ char userId[8];
+ char groupId[8];
+ char size[12];
+ char modifiedTime[12];
+ char checksum[8];
+ char typeFlag;
+ char linkName[100];
+ char magic[6];
+ char version[2];
+ char userName[32];
+ char groupName[32];
+ char devMajor[8];
+ char devMinor[8];
+ char prefix[155];
+ } fields;
+
+ char buffer[kBlockLength];
+ };
+
+ class Packaging
+ {
+ private:
+
+ // TODO: Add support for sparse files to both methods.
+ static bool ExtractTar(QTemporaryFile& tarFile, PackageData *outputPackageData);
+ static bool CreateTar(const PackageData& packageData, QTemporaryFile *outputTarFile); // Uses original TAR format.
+
+ public:
+
+ static const char *ustarMagic;
+
+ static bool ExtractPackage(const QString& packagePath, PackageData *outputPackageData);
+ static bool BuildPackage(const QString& packagePath, const PackageData& packageData);
+ };
+}
+
+#endif