summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/isobuilder.cpp109
1 files changed, 72 insertions, 37 deletions
diff --git a/lib/isobuilder.cpp b/lib/isobuilder.cpp
index 327b55c..107fbe8 100644
--- a/lib/isobuilder.cpp
+++ b/lib/isobuilder.cpp
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: isobuilder.cpp,v 1.18 2005-11-02 21:34:02 pixel Exp $ */
+/* $Id: isobuilder.cpp,v 1.19 2006-07-17 16:11:25 pixel Exp $ */
#include "isobuilder.h"
@@ -169,55 +169,84 @@ void isobuilder::DirTree::dumpdirs(isobuilder * builder) throw (GeneralException
free(odir);
}
+int isobuilder::DirTree::maxlevel(int current_level) {
+ int m_level_c = 0, m_level_b = 0;
+ if (dir) {
+ if (child) {
+ m_level_c = child->maxlevel(current_level + 1);
+ }
+ }
+
+ if (brother) {
+ m_level_b = brother->maxlevel(current_level);
+ }
+
+ return max(current_level, max(m_level_c, m_level_b));
+}
+
int isobuilder::DirTree::buildpath(Byte * data, int size, bool bigendian) throw (GeneralException) {
- int N, r, tr;
+ int maxlv = maxlevel(), i, R, cumul = 0;
+
+ for (i = 1; i < maxlv; i++) {
+ R = buildpath_r(data, size, 1, i, bigendian);
+ data += R;
+ cumul += R;
+ }
+
+ return cumul;
+}
+
+int isobuilder::DirTree::buildpath_r(Byte * data, int size, int current_level, int level_to_dump, bool bigendian) throw (GeneralException) {
+ int N, r = 0, tr;
Uint16 pn;
char pbuf[256], pad;
if (!dir) {
if (brother) {
- return brother->buildpath(data, size, bigendian);
+ return brother->buildpath_r(data, size, current_level, level_to_dump, bigendian);
} else {
return 0;
}
}
- if (!father) {
- numerate(1);
- N = 1;
- pbuf[0] = 0;
- pn = 1;
- } else {
- N = name.strlen();
- strcpy(pbuf, name.to_charp());
- pn = father->node;
- }
+ if (current_level == level_to_dump) {
+ if (!father) {
+ numerate(1);
+ N = 1;
+ pbuf[0] = 0;
+ pn = 1;
+ } else {
+ N = name.strlen();
+ strcpy(pbuf, name.to_charp());
+ pn = father->node;
+ }
- pad = N & 1;
- size -= (r = N + pad + 8);
+ pad = N & 1;
+ size -= (r = N + pad + 8);
- if (size < 0)
- throw GeneralException("Path table too small.");
+ if (size < 0)
+ throw GeneralException("Path table too small.");
- data[0] = N;
- data[1] = 0;
- *((Uint32 *) (data + 2)) = bigendian ? cdutils::to_BE32(sector) : cdutils::to_LE32(sector);
- *((Uint16 *) (data + 6)) = bigendian ? cdutils::to_BE16(pn) : cdutils::to_LE16(pn);
- memcpy(data + 8, pbuf, N);
- if (pad)
- data[8 + N] = 0;
+ data[0] = N;
+ data[1] = 0;
+ *((Uint32 *) (data + 2)) = bigendian ? cdutils::to_BE32(sector) : cdutils::to_LE32(sector);
+ *((Uint16 *) (data + 6)) = bigendian ? cdutils::to_BE16(pn) : cdutils::to_LE16(pn);
+ memcpy(data + 8, pbuf, N);
+ if (pad)
+ data[8 + N] = 0;
- data += r;
+ data += r;
+ }
- if (brother) {
- tr = brother->buildpath(data, size, bigendian);
+ if (child) {
+ tr = child->buildpath_r(data, size, current_level + 1, level_to_dump, bigendian);
r += tr;
size -= tr;
data += tr;
}
- if (child) {
- tr = child->buildpath(data, size, bigendian);
+ if (brother) {
+ tr = brother->buildpath_r(data, size, current_level, level_to_dump, bigendian);
r += tr;
size -= tr;
data += tr;
@@ -236,6 +265,10 @@ int isobuilder::DirTree::buildentry(Byte * buffer, int spaceleft, bool put_xa) {
memset(pbuf, 0, 256);
+ if (name == "BM2.ELF") {
+ printm(M_INFO, "GRON");
+ }
+
if (name == ".") {
N = 1;
pbuf[0] = 0;
@@ -314,14 +347,16 @@ void isobuilder::DirTree::fromdir(cdutils::DirEntry * d) {
return;
}
- if ((d->N == 1) && (d->id[0] == 0)) {
- name = ".";
- } else if ((d->N == 1) && (d->id[0] == 1)) {
- name = "..";
- } else {
- memcpy(pbuf, d->id, s = (d->N - ((d->Flags & 2) ? 0 : 2)));
- pbuf[s] = 0;
- name = pbuf;
+ if (name == "") {
+ if ((d->N == 1) && (d->id[0] == 0)) {
+ name = ".";
+ } else if ((d->N == 1) && (d->id[0] == 1)) {
+ name = "..";
+ } else {
+ memcpy(pbuf, d->id, s = (d->N - ((d->Flags & 2) ? 0 : 2)));
+ pbuf[s] = 0;
+ name = pbuf;
+ }
}
hidden = d->Flags & 1;
if (d->Year < 70)