diff options
Diffstat (limited to 'heimdall-frontend/Source/Packaging.h')
-rwxr-xr-x | heimdall-frontend/Source/Packaging.h | 110 |
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 |