xref: /haiku/src/apps/haikudepot/tar/TarArchiveService.h (revision c0936b5a0384bc6fe654d296ee54222a0f45d2b6)
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 "Stoppable.h"
11 #include "TarArchiveHeader.h"
12 
13 #include <String.h>
14 #include <Path.h>
15 
16 
17 class TarArchiveService {
18 public:
19 		static status_t			Unpack(BDataIO& tarDataIo,
20 									BPath& targetDirectoryPath,
21 									Stoppable* stoppable);
22 
23 private:
24 		static status_t			_EnsurePathToTarItemFile(
25 									BPath& targetDirectoryPath,
26 									BString &tarItemPath);
27 		static status_t			_ValidatePathComponent(
28 									const BString& component);
29 		static status_t			_UnpackItem(BDataIO& tarDataIo,
30 									BPath& targetDirectory,
31 									TarArchiveHeader& header);
32 		static status_t			_UnpackItemData(BDataIO& tarDataIo,
33 									BPath& targetFilePath,
34 									uint32 length);
35 
36 };
37 
38 #endif // TAR_ARCHIVE_SERVICE_H
39