|
|
1.1 ! root 1: /* ! 2: * ! 3: * (c) 2005-2009 Laurent Vivier <[email protected]> ! 4: * ! 5: * This file has been copied from EMILE, http://emile.sf.net ! 6: * ! 7: */ ! 8: ! 9: #include "libiso9660.h" ! 10: #include "libopenbios/bindings.h" ! 11: #include "libc/diskio.h" ! 12: ! 13: #define offsetof(t,m) ((long)&(((t *)0)->m)) ! 14: ! 15: static void read_extent(iso9660_DIR *dir) ! 16: { ! 17: seek_io(dir->volume->fd, dir->extent * ISOFS_BLOCK_SIZE); ! 18: read_io(dir->volume->fd, dir->buffer, ISOFS_BLOCK_SIZE); ! 19: ! 20: dir->len -= ISOFS_BLOCK_SIZE; ! 21: dir->extent ++; ! 22: dir->index = 0; ! 23: } ! 24: ! 25: struct iso_directory_record *iso9660_readdir(iso9660_DIR *dir) ! 26: { ! 27: struct iso_directory_record *idr; ! 28: ! 29: if (dir->index > ! 30: ISOFS_BLOCK_SIZE - offsetof(struct iso_directory_record, name[0])) ! 31: { ! 32: if (dir->len <= 0) ! 33: return NULL; ! 34: ! 35: read_extent(dir); ! 36: } ! 37: ! 38: idr = (struct iso_directory_record *) &dir->buffer[dir->index]; ! 39: if (idr->length[0] == 0) { ! 40: if (dir->len <= 0) ! 41: return NULL; ! 42: ! 43: read_extent(dir); ! 44: idr = (struct iso_directory_record *) &dir->buffer[dir->index]; ! 45: } ! 46: ! 47: dir->index += dir->buffer[dir->index]; ! 48: ! 49: return idr; ! 50: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.