summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpixel <pixel>2006-07-17 16:11:25 +0000
committerpixel <pixel>2006-07-17 16:11:25 +0000
commit9344bc8b92273a869b509a33a28bd6e5ebfedaf6 (patch)
tree9d5c314d82f2c52a0c46cadb0bfc4a42bc3b193f
parent3712d0a948d336ad8a61b72fd203a92a46e867f2 (diff)
Fixing the path table issue... and the name-from-template one as well!
Damn, how was this working before... ?
-rw-r--r--includes/isobuilder.h6
-rw-r--r--lib/isobuilder.cpp109
2 files changed, 76 insertions, 39 deletions
diff --git a/includes/isobuilder.h b/includes/isobuilder.h
index 7f86f05..a18e64d 100644
--- a/includes/isobuilder.h
+++ b/includes/isobuilder.h
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: isobuilder.h,v 1.13 2005-11-02 21:34:02 pixel Exp $ */
+/* $Id: isobuilder.h,v 1.14 2006-07-17 16:11:25 pixel Exp $ */
#ifndef __ISOBUILDER_H__
#define __ISOBUILDER_H__
@@ -47,7 +47,7 @@ class isobuilder : public Base {
virtual ~DirTree();
void fromdir(cdutils::DirEntry *);
void dumpdirs(isobuilder *) throw (GeneralException);
- int buildpath(Byte * data, int size, bool bigendian = false) throw (GeneralException);
+ int buildpath(Byte * data, int size, bool bigendian = false);
bool isdir();
void setbasicsxa();
int sector;
@@ -64,6 +64,8 @@ class isobuilder : public Base {
DirTree * Brother();
DirTree * Find(const String &);
private:
+ int buildpath_r(Byte * data, int size, int current_level, int level_to_dump, bool bigendian) throw (GeneralException);
+ int maxlevel(int current_level = 1);
DirTree * father, * child, * brother;
bool dir;
int node;
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)