[Lapetus-cvs] lapetus cdfs.c,1.2,1.3
Status: Inactive
Brought to you by:
cyberwarriorx
From: Theo B. <cyb...@us...> - 2008-01-09 22:09:58
|
Update of /cvsroot/lapetus/lapetus In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv19735 Modified Files: cdfs.c Log Message: -Can't remember what changed here. Oh well Index: cdfs.c =================================================================== RCS file: /cvsroot/lapetus/lapetus/cdfs.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- cdfs.c 3 Mar 2007 05:23:07 -0000 1.2 +++ cdfs.c 9 Jan 2008 22:09:55 -0000 1.3 @@ -156,7 +156,7 @@ sectbuffered = 0; // Read in lba 16 - if ((ret = CDReadSector(dirtbl, 166, SECT_2048, 1)) != LAPETUS_ERR_OK) + if ((ret = CDReadSector(dirtbl, 166, SECT_2048, 2048)) != LAPETUS_ERR_OK) return ret; CopyDirRecord(dirtbl+0x9C, &dirrec); @@ -186,13 +186,35 @@ // read the directory table, and find the next subdirectory. Once we're // in the correct level, parse through the table and find the file. - if ((ret = CDReadSector(dirtbl, 150+rootlba, SECT_2048, 1)) != LAPETUS_ERR_OK) + if ((ret = CDReadSector(dirtbl, 150+rootlba, SECT_2048, 2048)) != LAPETUS_ERR_OK) return ret; lba = rootlba + 1; sectorsleft = rootsize - 1; workbuffer = dirtbl; + if (path == NULL) + { + int i; + // Get first file(I may remove this feature yet) + for (i = 0; i < 3; i++) + { + if (workbuffer[0] == 0) + return LAPETUS_ERR_FILENOTFOUND; + + CopyDirRecord(workbuffer, &dirrec); + workbuffer += dirrec.recordsize; + } + + // We're done. + file->lba = lba; + file->size = dirrec.size; + file->sectpos = 0; + file->pos = 0; + + return LAPETUS_ERR_OK; + } + while(!done) { if ((p = strchr(path, '\\')) == NULL) @@ -231,7 +253,7 @@ if (sectorsleft > 0) { // Read in new sector - if ((ret = CDReadSector(dirtbl, 150+lba, SECT_2048, 1)) != LAPETUS_ERR_OK) + if ((ret = CDReadSector(dirtbl, 150+lba, SECT_2048, 2048)) != LAPETUS_ERR_OK) return ret; lba++; sectorsleft--; @@ -247,7 +269,7 @@ break; // Ok, we've found the next directory table, time to read it - if ((ret = CDReadSector(dirtbl, 150+lba, SECT_2048, 1)) != LAPETUS_ERR_OK) + if ((ret = CDReadSector(dirtbl, 150+lba, SECT_2048, 2048)) != LAPETUS_ERR_OK) return ret; lba++; sectorsleft--; @@ -294,14 +316,13 @@ int CDFSRead(u8 *buffer, int size, int num, file_struct *file) { int ret; - int sectreadsize=(size * num) / 2048; // Only sector-aligned transfers supported for now - if ((size * num) % 2048 == 0 && file->pos == 0) + if (file->pos == 0) { // Straight sectors reads. Nice and fast - if ((ret = CDReadSector(buffer, 150+file->lba+file->sectpos, SECT_2048, sectreadsize)) == LAPETUS_ERR_OK) - file->sectpos += sectreadsize; + if ((ret = CDReadSector(buffer, 150+file->lba+file->sectpos, SECT_2048, size * num)) == LAPETUS_ERR_OK) + file->sectpos += (size * num); return ret; } else |