oops.. only build it when it _is_ valid.
[AROS-Contrib.git] / FryingPan / ISOBuilder / RRStructures.cpp
blob11749ec3a667bd8aba21ea3e6469646dfdacbe79
1 /*
2 * FryingPan - Amiga CD/DVD Recording Software (User Interface and supporting Libraries only)
3 * Copyright (C) 2001-2011 Tomasz Wiszkowski Tomasz.Wiszkowski at gmail.com
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public License
7 * as published by the Free Software Foundation; either version 2.1
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include "RRStructures.h"
21 #include "ISOStructures.h"
22 #include <LibC/LibC.h>
24 RRExt::RRExt(uint8 id1, uint8 id2, uint8 flags, uint8 sets)
26 this->id[0] = id1;
27 this->id[1] = id2;
28 this->flags = flags;
29 this->sets = sets;
32 RRExt::~RRExt()
36 uint8 RRExt::Length()
38 return 5;
41 uint8* RRExt::PutData(uint8* loc)
43 *loc++ = id[0];
44 *loc++ = id[1];
45 *loc++ = Length();
46 *loc++ = 1;
48 if (sets & Set_Flags)
49 *loc++ = flags;
51 return loc;
54 void RRExt::SetFlags(uint8 flags)
56 this->flags = flags;
59 uint8 RRExt::GetFlags()
61 return flags;
65 RR_NM::RR_NM(const char* name) :
66 RRExt('N', 'M')
68 SetName(name);
71 void RR_NM::SetName(const char* name)
73 this->name = name;
76 uint8 RR_NM::Length()
78 return RRExt::Length()+name.Length();
81 uint8 *RR_NM::PutData(uint8* loc)
83 loc = RRExt::PutData(loc);
84 strncpy((char*)loc, name.Data(), name.Length());
85 loc += name.Length();
86 return loc;
90 RR_RR::RR_RR(uint8 flags) :
91 RRExt('R', 'R', flags)
96 RR_AS::RR_AS(const char* comment, uint8 protection) :
97 RRExt('A', 'S')
99 this->comment = comment;
100 this->protection = protection;
103 uint8 RR_AS::Length()
105 uint8 size = 0;
106 uint8 flags = 0;
108 size = comment.Length();
109 if (size != 0)
111 size++;
112 flags |= 2;
115 if (protection != 0)
117 size += 4;
118 flags |= 1;
121 RRExt::SetFlags(flags);
122 if (flags == 0)
123 return 0;
125 return RRExt::Length() + size;
128 uint8 *RR_AS::PutData(uint8* loc)
130 uint8 flags = RRExt::GetFlags();
132 if (flags == 0)
133 return loc;
135 loc = RRExt::PutData(loc);
137 if (flags & 1)
139 *loc++ = 0;
140 *loc++ = 0;
141 *loc++ = 0;
142 *loc++ = protection;
145 if (flags & 2)
147 *loc++ = comment.Length()+1;
148 strncpy((char*)loc, comment.Data(), comment.Length());
149 loc += comment.Length();
152 return loc;
155 void RR_AS::SetFlags(uint8 flags)
157 protection = flags;
160 void RR_AS::SetElemComment(const char* comment)
162 this->comment = comment;
165 const String &RR_AS::GetElemComment() const
167 return comment;
171 RR_SP::RR_SP() :
172 RRExt('S', 'P')
176 uint8 RR_SP::Length()
178 return 7;
181 uint8 *RR_SP::PutData(uint8* loc)
183 *loc++ = 'S';
184 *loc++ = 'P';
185 *loc++ = 7;
186 *loc++ = 1;
187 *loc++ = 0xBE;
188 *loc++ = 0xEF;
189 *loc++ = 0x00;
190 return loc;
194 RR_PX::RR_PX(uint8 prot, bool dir) :
195 RRExt('P', 'X')
197 SetFlags(prot);
198 SetDir(dir);
201 uint8 RR_PX::Length()
203 return 44;
206 uint8 *RR_PX::PutData(uint8* loc)
208 val733 *v;
210 *loc++ = 'P';
211 *loc++ = 'X';
212 *loc++ = 44;
213 *loc++ = 1;
214 v = (val733*)loc;
215 v->setVal(flags);
216 loc += sizeof(val733);
218 v = (val733*)loc;
219 v->setVal(0);
220 loc += sizeof(val733);
222 v = (val733*)loc;
223 v->setVal(0);
224 loc += sizeof(val733);
226 v = (val733*)loc;
227 v->setVal(0);
228 loc += sizeof(val733);
230 v = (val733*)loc;
231 v->setVal(0);
232 loc += sizeof(val733);
234 return loc;
237 void RR_PX::SetFlags(uint8 p)
239 prot = p;
241 flags = 0;
243 if ((prot & 8) == 0)
244 flags |= S_IROTH | S_IRGRP | S_IRUSR;
245 if ((prot & 4) == 0)
246 flags |= S_IWOTH | S_IWGRP | S_IWUSR;
247 if ((prot & 2) == 0)
248 flags |= S_IXOTH | S_IXGRP | S_IXUSR;
250 if (dir)
251 flags |= S_IFDIR;
252 else
253 flags |= S_IFREG;
256 uint8 RR_PX::GetFlags()
258 return prot;
261 void RR_PX::SetDir(bool dir)
263 this->dir = dir;
265 flags &= ~(S_IFDIR | S_IFREG);
266 if (dir)
267 flags |= S_IFDIR;
268 else
269 flags |= S_IFREG;
273 * RR_CE: content extension entry
274 * no flags
276 RR_CE::RR_CE() :
277 RRExt('C', 'E', 0, 0)
281 void RR_CE::setBlock(uint32 block)
283 this->block = (block);
286 void RR_CE::setOffset(uint32 offset)
288 this->offset = (offset);
291 void RR_CE::setLength(uint32 length)
293 this->length = (length);
296 uint8 RR_CE::Length()
298 return 28;
301 uint8 *RR_CE::PutData(uint8* loc)
303 val733 *v;
305 loc = RRExt::PutData(loc);
307 v = (val733*)loc;
308 v->setVal(block);
309 v++;
310 v->setVal(offset);
311 v++;
312 v->setVal(length);
314 return (uint8*) v;