2 * Copyright 2007-2009, Haiku, Inc.
3 * Distributed under the terms of the MIT license.
6 * Ćukasz 'Sil2100' Zemczak <sil2100@vexillium.org>
14 #include <Directory.h>
21 // Local macro for the parser debug output
22 //#define DEBUG_PARSER
24 # define parser_debug(format, args...) fprintf(stderr, format, ##args)
26 # define parser_debug(format, args...)
36 // Existing item overwriting policy of a single file
45 const uint32 P_NO_KIND
= 0;
46 const uint32 P_KIND_SCRIPT
= 1;
47 const uint32 P_KIND_FILE
= 2;
48 const uint32 P_KIND_DIRECTORY
= 3;
49 const uint32 P_KIND_SYM_LINK
= 4;
51 extern status_t
inflate_data(uint8
* in
, uint32 inSize
, uint8
* out
,
56 ItemState(uint8 _policy
)
76 PackageItem(BFile
* parent
, const BString
& path
,
77 uint8 type
, uint32 ctime
, uint32 mtime
,
78 uint64 offset
= 0, uint64 size
= 0);
79 virtual ~PackageItem();
81 virtual status_t
DoInstall(const char* path
= NULL
,
82 ItemState
*state
= NULL
) = 0;
83 virtual void SetTo(BFile
* parent
, const BString
& path
,
84 uint8 type
, uint32 ctime
, uint32 mtime
,
85 uint64 offset
= 0, uint64 size
= 0);
86 virtual const uint32
ItemKind() {return P_NO_KIND
;};
89 status_t
InitPath(const char* path
, BPath
* destination
);
90 status_t
HandleAttributes(BPath
* destination
, BNode
* node
,
93 status_t
ParseAttribute(uint8
* buffer
, BNode
* node
,
94 char** attrName
, uint32
* nameSize
,
95 uint32
* attrType
, uint8
** attrData
,
96 uint64
* dataSize
, uint8
** temp
,
97 uint64
* tempSize
, uint64
* attrCSize
,
98 uint64
* attrOSize
, bool* attrStarted
,
100 status_t
SkipAttribute(uint8
* buffer
, bool* attrStarted
,
102 status_t
ParseData(uint8
* buffer
, BFile
* file
,
103 uint64 originalSize
, bool* done
);
110 uint32 fCreationTime
;
111 uint32 fModificationTime
;
117 class PackageDirectory
: public PackageItem
{
119 PackageDirectory(BFile
* parent
, const BString
& path
,
120 uint8 type
, uint32 ctime
, uint32 mtime
,
121 uint64 offset
= 0, uint64 size
= 0);
123 virtual status_t
DoInstall(const char* path
= NULL
,
124 ItemState
* state
= NULL
);
125 virtual const uint32
ItemKind();
129 class PackageScript
: public PackageItem
{
131 PackageScript(BFile
* parent
, const BString
& path
,
132 uint8 type
, uint64 offset
= 0, uint64 size
= 0,
133 uint64 originalSize
= 0);
135 virtual status_t
DoInstall(const char* path
= NULL
,
136 ItemState
*state
= NULL
);
137 virtual const uint32
ItemKind();
139 thread_id
GetThreadId() { return fThreadId
; }
140 void SetThreadId(thread_id id
) { fThreadId
= id
; }
143 status_t
_ParseScript(uint8
* buffer
, uint64 originalSize
,
144 BString
& script
, bool* done
);
145 status_t
_RunScript(const char* workingDirectory
,
146 const BString
& script
);
149 uint64 fOriginalSize
;
154 class PackageFile
: public PackageItem
{
156 PackageFile(BFile
* parent
, const BString
& path
,
157 uint8 type
, uint32 ctime
, uint32 mtime
,
158 uint64 offset
, uint64 size
, uint64 originalSize
,
159 uint32 platform
, const BString
& mime
,
160 const BString
& signature
, uint32 mode
);
162 virtual status_t
DoInstall(const char* path
= NULL
,
163 ItemState
* state
= NULL
);
164 virtual const uint32
ItemKind();
167 uint64 fOriginalSize
;
176 class PackageLink
: public PackageItem
{
178 PackageLink(BFile
* parent
, const BString
& path
,
179 const BString
& link
, uint8 type
, uint32 ctime
,
180 uint32 mtime
, uint32 mode
, uint64 offset
= 0,
183 virtual status_t
DoInstall(const char* path
= NULL
,
184 ItemState
*state
= NULL
);
185 virtual const uint32
ItemKind();
192 #endif // PACKAGE_ITEM_H