xref: /haiku/src/apps/haikudepot/tar/TarArchiveService.h (revision 6889394848e2dc9f41ff53b12141d572822ca0c6)
1 /*
2  * Copyright 2017, Andrew Lindesay <apl@lindesay.co.nz>.
3  * All rights reserved. Distributed under the terms of the MIT License.
4  */
5 
6 #ifndef TAR_ARCHIVE_SERVICE_H
7 #define TAR_ARCHIVE_SERVICE_H
8 
9 #include "AbstractServerProcess.h"
10 #include "TarArchiveHeader.h"
11 
12 #include <String.h>
13 #include <Path.h>
14 
15 
16 class TarArchiveService {
17 public:
18 		static status_t			Unpack(BDataIO& tarDataIo,
19 									BPath& targetDirectoryPath);
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