]> git.sur5r.net Git - cc65/blobdiff - libsrc/apple2/readdir.c
don't use constructor to setup runtime stack
[cc65] / libsrc / apple2 / readdir.c
index f4653cfae42e17a749503ab7b1f5b7d350399b0f..eaa196baccc58f80a3887aeb861422f5614fd411 100644 (file)
@@ -43,9 +43,9 @@
 
 
 
-struct dirent* __fastcall__ readdir (DIR* dir)
+struct dirent* __fastcall__ readdir (register DIR* dir)
 {
-    char* entry;
+    register unsigned char* entry;
 
     /* Search for the next active directory entry */
     do {
@@ -71,11 +71,20 @@ struct dirent* __fastcall__ readdir (DIR* dir)
 
        /* Switch to next entry */
        ++dir->current_entry;
-    } while (entry[0] == 0);
+    } while (entry[0x00] == 0);
 
-    /* Zero-terminate name */
-    entry[1 + (entry[0] & 15)] = '\0';
+    /* Move creation date/time to allow for next step below */
+    *(unsigned long*)&entry[0x1A] = *(unsigned long*)&entry[0x18];
+
+    /* Feature unsigned long access to EOF by extension from 3 to 4 bytes */
+    entry[0x18] = 0;
+
+    /* Move file type to allow for next step below */
+    entry[0x19] = entry[0x10];
+
+    /* Zero-terminate file name */
+    entry[0x01 + (entry[0x00] & 0x0F)] = 0;
 
     /* Return success */
-    return (struct dirent*)&entry[1];
+    return (struct dirent*)&entry[0x01];
 }