1 /* 2 * Copyright 2017-2018, Andrew Lindesay <apl@lindesay.co.nz>. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 #ifndef TAR_ARCHIVE_SERVICE_H 6 #define TAR_ARCHIVE_SERVICE_H 7 8 #include "Stoppable.h" 9 #include "TarArchiveHeader.h" 10 11 #include <String.h> 12 #include <Path.h> 13 14 15 class TarArchiveService { 16 public: 17 static status_t Unpack(BDataIO& tarDataIo, 18 BPath& targetDirectoryPath, 19 Stoppable* stoppable); 20 21 private: 22 static status_t _EnsurePathToTarItemFile( 23 BPath& targetDirectoryPath, 24 BString &tarItemPath); 25 static status_t _ValidatePathComponent( 26 const BString& component); 27 static status_t _UnpackItem(BDataIO& tarDataIo, 28 BPath& targetDirectory, 29 TarArchiveHeader& header); 30 static status_t _UnpackItemData(BDataIO& tarDataIo, 31 BPath& targetFilePath, 32 uint32 length); 33 34 }; 35 36 #endif // TAR_ARCHIVE_SERVICE_H 37