summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/cdutils.cpp27
-rw-r--r--lib/isobuilder.cpp28
-rw-r--r--lib/luacd.cpp116
3 files changed, 117 insertions, 54 deletions
diff --git a/lib/cdutils.cpp b/lib/cdutils.cpp
index ba830f6..685d0f1 100644
--- a/lib/cdutils.cpp
+++ b/lib/cdutils.cpp
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: cdutils.cpp,v 1.17 2003-12-08 15:12:57 pixel Exp $ */
+/* $Id: cdutils.cpp,v 1.18 2003-12-10 02:59:31 pixel Exp $ */
#include <stdio.h>
#include <string.h>
@@ -202,7 +202,7 @@ long cdutils::read_sector(Byte * buffer, int type, int number) {
return sec_sizes[type];
}
-void cdutils::read_datas(Byte * buffer, int type, int number, long size) {
+void cdutils::read_datas(Byte * buffer, long size, int type, int number) {
Byte sector[2352];
int i, n, reste;
@@ -224,7 +224,7 @@ void cdutils::read_datas(Byte * buffer, int type, int number, long size) {
}
}
-void cdutils::read_file(Handle * file, int type, int number, long size) {
+void cdutils::read_file(Handle * file, long size, int type, int number) {
Byte sector[2352];
int i, n, reste;
@@ -279,7 +279,7 @@ void cdutils::write_sector(Byte * buffer, int type, int number) {
}
}
-void cdutils::write_datas(Byte * buffer, int type, int number, long size) {
+void cdutils::write_datas(Byte * buffer, long size, int type, int number) {
long nbsectors, i;
unsigned char sector[2352];
@@ -304,8 +304,8 @@ void cdutils::write_datas(Byte * buffer, int type, int number, long size) {
}
}
-void cdutils::write_file(Handle * file, int type, int number) {
- long size, nbsectors, i;
+void cdutils::write_file(Handle * file, long size, int type, int number) {
+ long nbsectors, i;
unsigned char buffer[2352];
if (type == GUESS) {
@@ -316,7 +316,8 @@ void cdutils::write_file(Handle * file, int type, int number) {
sector_seek(number);
}
- size = file->GetSize();
+ if (size < 0)
+ size = file->GetSize();
nbsectors = size / sec_sizes[type];
if (size % sec_sizes[type]) {
@@ -391,7 +392,7 @@ int cdutils::show_dir(struct DirEntry * dir) {
}
buffer = (Byte *) malloc(dir->Size);
- read_datas(buffer, GUESS, dir->Sector, dir->Size);
+ read_datas(buffer, dir->Size, GUESS, dir->Sector);
ptr = 0;
while(ptr < dir->Size) {
@@ -412,7 +413,7 @@ struct cdutils::DirEntry cdutils::find_dir_entry(struct DirEntry * dir, String n
}
buffer = (unsigned char *) malloc(size = dir->Size);
- read_datas(buffer, GUESS, dir->Sector, dir->Size);
+ read_datas(buffer, dir->Size, GUESS, dir->Sector);
ptr = 0;
while(ptr < size) {
@@ -442,7 +443,7 @@ struct cdutils::DirEntry * cdutils::find_dir_entry(Byte ** bufout, struct cdutil
}
buffer = (Byte *) malloc(size = dir->Size);
- read_datas(buffer, GUESS, dir->Sector, dir->Size);
+ read_datas(buffer, dir->Size, GUESS, dir->Sector);
ptr = 0;
while(ptr < size) {
@@ -584,7 +585,7 @@ int cdutils::get_pt_infos() {
}
buffer = (Byte *) malloc(ptl);
- read_datas(buffer, GUESS, !pt1 ? pt2 : pt1, ptl);
+ read_datas(buffer, ptl, GUESS, !pt1 ? pt2 : pt1);
if (buffer[0] == 1)
if (buffer[1] == 0)
@@ -613,7 +614,7 @@ int cdutils::show_pt_infos() {
}
buffer = (Byte *) malloc(ptl);
- read_datas(buffer, GUESS, !pt1 ? pt2 : pt1, ptl);
+ read_datas(buffer, ptl, GUESS, !pt1 ? pt2 : pt1);
printm(M_BARE, "node^paren@sector : name\n");
for (ptr = 0, i = 1; buffer[ptr]; ptr += ptr & 1, i++) {
@@ -851,7 +852,7 @@ ssize_t cdfile::read(void *buf, size_t count) throw (GeneralException) {
buf = (Byte *) buf + nstartbytes;
if (count) {
- cd->read_datas((Byte *) buf, mode, startsec + 1, count);
+ cd->read_datas((Byte *) buf, count, mode, startsec + 1);
}
itell += count + nstartbytes;
diff --git a/lib/isobuilder.cpp b/lib/isobuilder.cpp
index 85760d5..d267063 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.7 2003-12-08 15:12:57 pixel Exp $ */
+/* $Id: isobuilder.cpp,v 1.8 2003-12-10 02:59:32 pixel Exp $ */
#include "isobuilder.h"
@@ -150,9 +150,9 @@ void isobuilder::DirTree::dumpdirs(isobuilder * builder) throw (GeneralException
for (p = child; p; p = p->brother) {
if (p->dir) {
p->dumpdirs(builder);
- if (p->hardhide)
- continue;
}
+ if (p->hardhide)
+ continue;
while (!(R = p->buildentry(dir, cursectsize))) {
cursiz -= 2048;
dir += cursectsize;
@@ -329,6 +329,7 @@ void isobuilder::DirTree::fromdir(cdutils::DirEntry * d) {
t.second = d->Second;
t.hundredths = 0;
t.offset = d->Offset;
+ creation = t;
s = 33 + d->N;
if (s & 1) {
@@ -353,6 +354,10 @@ void isobuilder::DirTree::fromdir(cdutils::DirEntry * d) {
}
}
+bool isobuilder::DirTree::isdir() {
+ return dir;
+}
+
void isobuilder::DirTree::setbasicsxa() {
have_xa = true;
if (dir)
@@ -456,6 +461,9 @@ int isobuilder::putfile(Handle * file, int mode, int n) {
size_t filesize;
int fsect;
+ if (mode < 0)
+ mode = dmode;
+
if (n >= 0) {
sector = n;
} else {
@@ -607,12 +615,14 @@ isobuilder::DirTree * isobuilder::createdir(DirTree * p, const String & _name, i
r = new DirTree(p);
- r->name = _name;
r->creation = p->creation;
- r->fromdir(d);
+ if (d)
+ r->fromdir(d);
if (_name != "")
r->name = _name;
r->size = size * 2048;
+ if (!r->size)
+ r->size = d->Size;
r->sector = lastdispsect;
if (mode >= 0)
r->mode = mode;
@@ -651,7 +661,7 @@ isobuilder::DirTree * isobuilder::createfile(DirTree * p, Handle * file, const S
r->mode = dmode;
}
-void isobuilder::copydir(isobuilder::DirTree * r, const String & _name, cdutils * cd, cdutils::DirEntry * d, int mode) {
+void isobuilder::copydir(isobuilder::DirTree * r, cdutils * cd, cdutils::DirEntry * d, int mode) {
Byte datas[2048];
cdutils::DirEntry * p;
int nsectors = d->Size / 2048, ssize, c = 0;
@@ -660,10 +670,6 @@ void isobuilder::copydir(isobuilder::DirTree * r, const String & _name, cdutils
if (mode < 0)
mode = dmode;
- r->fromdir(d);
- if (_name != "")
- r->name = _name;
-
while (nsectors) {
cd->read_sector(datas, mode, d->Sector + c++);
nsectors--;
@@ -676,7 +682,7 @@ void isobuilder::copydir(isobuilder::DirTree * r, const String & _name, cdutils
pbuf[p->N] = 0;
if (p->Flags & 2) {
if (!((p->N == 1) && ((p->id[0] == 0) || (p->id[0] == 1))))
- copydir(createdir(r, "", p->Size / 2048, p, mode), "", cd, p, mode);
+ copydir(createdir(r, "", p->Size / 2048, p, mode), cd, p, mode);
} else {
printm(M_INFO, "Dupping %s\n", pbuf);
int fmode;
diff --git a/lib/luacd.cpp b/lib/luacd.cpp
index 47cb05b..68b3028 100644
--- a/lib/luacd.cpp
+++ b/lib/luacd.cpp
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: luacd.cpp,v 1.3 2003-12-08 15:12:57 pixel Exp $ */
+/* $Id: luacd.cpp,v 1.4 2003-12-10 02:59:32 pixel Exp $ */
#include "luacd.h"
@@ -57,14 +57,14 @@ enum cdutils_functions_t {
struct lua_functypes_t cdutils_methods[] = {
{ CDUTILS_SETISOW, "set_iso_w", 1, 1, {LUA_OBJECT} },
- { CDUTILS_GUESSTYPE, "guesstype", 0, 1, {LUA_NUMBER} },
+ { CDUTILS_GUESSTYPE, "guessmode", 0, 1, {LUA_NUMBER} },
{ CDUTILS_SECTORSEEK, "sectorseek", 1, 1, {LUA_NUMBER} },
{ CDUTILS_READSECTOR, "readsector", 0, 2, {LUA_NUMBER, LUA_NUMBER} },
- { CDUTILS_READDATAS, "readdatas", 3, 3, {LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} },
- { CDUTILS_READFILE, "readfile", 4, 4, {LUA_OBJECT, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} },
+ { CDUTILS_READDATAS, "readdatas", 1, 3, {LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} },
+ { CDUTILS_READFILE, "readfile", 2, 4, {LUA_OBJECT, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} },
{ CDUTILS_WRITESECTOR, "writesector", 1, 3, {LUA_TABLE, LUA_NUMBER, LUA_NUMBER} },
- { CDUTILS_WRITEDATAS, "writedatas", 4, 4, {LUA_TABLE, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} },
- { CDUTILS_WRITEFILE, "writefile", 1, 3, {LUA_OBJECT, LUA_NUMBER, LUA_NUMBER} },
+ { CDUTILS_WRITEDATAS, "writedatas", 2, 4, {LUA_TABLE, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} },
+ { CDUTILS_WRITEFILE, "writefile", 1, 4, {LUA_OBJECT, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} },
{ CDUTILS_GETISOINFOS, "getisoinfos", 0, 0, 0 },
{ CDUTILS_GETPTINFOS, "getptinfos", 0, 0, 0 },
{ CDUTILS_FINDPATH, "findpath", 1, 1, {LUA_STRING} },
@@ -204,7 +204,7 @@ void Luacdutils::pushstatics(Lua * L) throw (GeneralException) {
}
int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) {
- int r = 0, sect = -1, mode = GUESS, size, i;
+ int r = 0, sect = -1, mode = GUESS, size = -1, i;
Handle * h;
Byte sdatas[2352], * datas;
String path;
@@ -241,11 +241,13 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) {
r = 1;
break;
case CDUTILS_READDATAS:
- mode = L->tonumber(2);
- sect = L->tonumber(3);
- size = L->tonumber(4);
+ size = L->tonumber(2);
+ if (n >= 2)
+ mode = L->tonumber(3);
+ if (n == 3)
+ sect = L->tonumber(3);
datas = (Byte *) malloc(size);
- cd->read_datas(datas, mode, sect, size);
+ cd->read_datas(datas, size, mode, sect);
L->newtable();
for (i = 0; i < size; i++) {
L->push((lua_Number) i);
@@ -257,10 +259,12 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) {
break;
case CDUTILS_READFILE:
h = (Handle *) LuaObject::getme(L, 2);
- mode = L->tonumber(3);
- sect = L->tonumber(4);
size = L->tonumber(5);
- cd->read_file(h, mode, sect, size);
+ if (n >= 3)
+ mode = L->tonumber(4);
+ if (n == 4)
+ sect = L->tonumber(5);
+ cd->read_file(h, size, mode, sect);
break;
case CDUTILS_WRITESECTOR:
if (n >= 2)
@@ -276,9 +280,11 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) {
cd->write_sector(datas, mode, sect);
break;
case CDUTILS_WRITEDATAS:
- mode = L->tonumber(3);
- sect = L->tonumber(4);
- size = L->tonumber(5);
+ size = L->tonumber(3);
+ if (n >= 3)
+ mode = L->tonumber(4);
+ if (n == 4)
+ sect = L->tonumber(5);
datas = (Byte *) malloc(size);
for (i = 0; i < size; i++) {
@@ -287,16 +293,18 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) {
sdatas[i] = L->tonumber();
L->pop();
}
- cd->write_datas(datas, mode, sect, size);
+ cd->write_datas(datas, size, mode, sect);
free(datas);
break;
case CDUTILS_WRITEFILE:
h = (Handle *) LuaObject::getme(L, 2);
if (n >= 2)
- mode = L->tonumber(3);
- if (n == 3)
- sect = L->tonumber(4);
- cd->write_file(h, mode, sect);
+ size = L->tonumber(3);
+ if (n >= 3)
+ mode = L->tonumber(4);
+ if (n == 4)
+ sect = L->tonumber(5);
+ cd->write_file(h, size, mode, sect);
break;
case CDUTILS_GETISOINFOS:
L->push((lua_Number) cd->get_iso_infos());
@@ -519,6 +527,8 @@ Luadirentry::Luadirentry(cdutils::DirEntry * _dir) : dir(_dir) { }
enum direntry_methods_t {
DIRENTRY_INDEX = 0,
+ DIRENTRY_ISHIDDEN,
+ DIRENTRY_ISDIR,
DIRENTRY_HASXA,
DIRENTRY_ISXADIR,
DIRENTRY_ISXAAUDIO,
@@ -529,6 +539,8 @@ enum direntry_methods_t {
struct lua_functypes_t direntry_methods[] = {
{ DIRENTRY_INDEX, "index", 1, 1, {LUA_STRING} },
+ { DIRENTRY_ISHIDDEN, "ishidden", 0, 0, 0 },
+ { DIRENTRY_ISDIR, "isdir", 0, 0, 0 },
{ DIRENTRY_HASXA, "hasxa", 0, 0, 0 },
{ DIRENTRY_ISXADIR, "isxadir", 0, 0, 0 },
{ DIRENTRY_ISXAAUDIO, "isxaaudio", 0, 0, 0 },
@@ -541,6 +553,8 @@ struct lua_functypes_t direntry_methods[] = {
class sLua_direntry : public Base {
public:
DECLARE_METHOD(direntry, DIRENTRY_INDEX);
+ DECLARE_METHOD(direntry, DIRENTRY_ISHIDDEN);
+ DECLARE_METHOD(direntry, DIRENTRY_ISDIR);
DECLARE_METHOD(direntry, DIRENTRY_HASXA);
DECLARE_METHOD(direntry, DIRENTRY_ISXADIR);
DECLARE_METHOD(direntry, DIRENTRY_ISXAAUDIO);
@@ -555,6 +569,8 @@ void Luadirentry::pushmembers(Lua * L) {
pushme(L, dir);
PUSH_METAMETHOD(direntry, DIRENTRY_INDEX);
+ PUSH_METHOD(direntry, DIRENTRY_ISHIDDEN);
+ PUSH_METHOD(direntry, DIRENTRY_ISDIR);
PUSH_METHOD(direntry, DIRENTRY_HASXA);
PUSH_METHOD(direntry, DIRENTRY_ISXADIR);
PUSH_METHOD(direntry, DIRENTRY_ISXAAUDIO);
@@ -590,6 +606,14 @@ int sLua_direntry::direntry_proceed(Lua * L, int n, direntry * dir, int caller)
L->push(has_xa);
r = 1;
break;
+ case DIRENTRY_ISHIDDEN:
+ L->push(dir->Flags & 1 ? true : false);
+ r = 1;
+ break;
+ case DIRENTRY_ISDIR:
+ L->push(dir->Flags & 2 ? true : false);
+ r = 1;
+ break;
case DIRENTRY_ISXADIR:
L->push(p[4] & 0x80 ? true : false);
r = 1;
@@ -672,18 +696,29 @@ enum cddate_methods_t {
CDDATE_NEWINDEX,
};
+enum cddate_functions_t {
+ CDDATE_NEWCDDATE = 0,
+};
+
struct lua_functypes_t cddate_methods[] = {
{ CDDATE_INDEX, "index", 1, 1, {LUA_STRING} },
{ CDDATE_NEWINDEX, "newindex", 2, 2, {LUA_STRING, LUA_NUMBER} },
{ -1, 0, 0, 0, 0 }
};
+struct lua_functypes_t cddate_functions[] = {
+ { CDDATE_NEWCDDATE, "cddate", 0, 0, 0 },
+ { -1, 0, 0, 0, 0 }
+};
+
class sLua_cddate : public Base {
public:
DECLARE_METHOD(cddate, CDDATE_INDEX);
DECLARE_METHOD(cddate, CDDATE_NEWINDEX);
+ DECLARE_FUNCTION(cddate, CDDATE_NEWCDDATE);
private:
static int cddate_proceed(Lua * L, int n, cddate * obj, int caller);
+ static int cddate_proceed_statics(Lua * L, int n, int caller);
};
void Luacddate::pushmembers(Lua * L) {
@@ -693,6 +728,13 @@ void Luacddate::pushmembers(Lua * L) {
PUSH_METAMETHOD(cddate, CDDATE_NEWINDEX);
}
+void Luacddate::pushstatics(Lua * L) throw (GeneralException) {
+ CHECK_METHODS(cddate);
+ CHECK_FUNCTIONS(cddate);
+
+ PUSH_FUNCTION(cddate, CDDATE_NEWCDDATE);
+}
+
int sLua_cddate::cddate_proceed(Lua * L, int n, cddate * date, int caller) {
int r, value;
String key;
@@ -701,7 +743,7 @@ int sLua_cddate::cddate_proceed(Lua * L, int n, cddate * date, int caller) {
case CDDATE_INDEX:
key = L->tostring(2);
r = 1;
- if (key == "year") {
+ if (key == "year") {
L->push((lua_Number) date->year);
} else if (key == "month") {
L->push((lua_Number) date->month);
@@ -749,6 +791,19 @@ int sLua_cddate::cddate_proceed(Lua * L, int n, cddate * date, int caller) {
return r;
}
+int sLua_cddate::cddate_proceed_statics(Lua * L, int n, int caller) {
+ int r = 0;
+
+ switch (caller) {
+ case CDDATE_NEWCDDATE:
+ {
+ Luacddate t(new cddate());
+ t.pushdestruct(L);
+ }
+ }
+
+ return r;
+}
/**********************\
|** class PVD exports **|
@@ -1124,6 +1179,8 @@ int sLua_DirTree::DirTree_proceed(Lua * L, int n, DirTree * dir, int caller) {
} else if (key == "brother") {
LuaDirTree tdir(dir->Brother());
tdir.push(L);
+ } else if (key == "isdir") {
+ L->push(dir->isdir());
} else {
invalid = true;
}
@@ -1298,7 +1355,7 @@ struct lua_functypes_t isobuilder_methods[] = {
{ ISOBUILDER_SETBASICS, "setbasics", 1, 5, {LUA_OBJECT, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} },
{ ISOBUILDER_CREATEDIR, "createdir", 2, 5, {LUA_OBJECT, LUA_STRING, LUA_NUMBER, LUA_OBJECT, LUA_NUMBER} },
{ ISOBUILDER_CREATEFILE, "createfile", 3, 5, {LUA_OBJECT, LUA_OBJECT, LUA_STRING, LUA_OBJECT, LUA_NUMBER} },
- { ISOBUILDER_COPYDIR, "copydir", 4, 5, {LUA_OBJECT, LUA_STRING, LUA_OBJECT, LUA_OBJECT, LUA_NUMBER} },
+ { ISOBUILDER_COPYDIR, "copydir", 3, 4, {LUA_OBJECT, LUA_OBJECT, LUA_OBJECT, LUA_NUMBER} },
{ ISOBUILDER_CLOSE, "close", 0, 2, {LUA_OBJECT, LUA_NUMBER} },
{ -1, 0, 0, 0, 0 }
};
@@ -1505,12 +1562,11 @@ int sLua_isobuilder::isobuilder_proceed(Lua * L, int n, isobuilder * iso, int ca
break;
case ISOBUILDER_COPYDIR:
dirt = (DirTree *) LuaObject::getme(L, 2);
- name = L->tostring(3);
- cd = (cdutils *) LuaObject::getme(L, 4);
- dire = (direntry *) LuaObject::getme(L, 5);
- if (n >= 5)
- mode = L->tonumber(6);
- iso->copydir(dirt, name, cd, dire, mode);
+ cd = (cdutils *) LuaObject::getme(L, 3);
+ dire = (direntry *) LuaObject::getme(L, 4);
+ if (n >= 4)
+ mode = L->tonumber(5);
+ iso->copydir(dirt, cd, dire, mode);
break;
case ISOBUILDER_CLOSE:
if (n >= 1)