2 ** 2012-06-03, Ullrich von Bassewitz. Based on code by Groepaz.
3 ** 2014-07-16, Greg King
13 void __fastcall__ seekdir (register DIR* dir, long offs)
17 unsigned char buf[128];
19 /* Make sure that we have a reasonable value for offs. We reject
20 ** negative numbers by converting them to (very high) unsigned values.
22 if ((unsigned long)offs > 0x1000uL) {
27 /* Close the directory file descriptor */
30 /* Reopen it using the old name */
31 dir->fd = open (dir->name, O_RDONLY);
37 /* Skip until we've reached the target offset in the directory */
38 o = dir->off = (unsigned)offs;
41 /* Determine size of next chunk to read */
42 if (o > sizeof (buf)) {
46 count = (unsigned char)o;
51 if (!_dirread (dir, buf, count)) {