]> git.sur5r.net Git - cc65/blobdiff - src/ar65/objfile.c
Allow to set the ProDOS type and auxtype on creating new files in a similiar way...
[cc65] / src / ar65 / objfile.c
index e165fc1671064236aea5e3347770ac51a80ddbb5..11d4de8f7e55332c7224a0656aa6897889433b34 100644 (file)
@@ -7,7 +7,7 @@
 /*                                                                          */
 /*                                                                          */
 /* (C) 1998-2003 Ullrich von Bassewitz                                       */
-/*               Römerstrasse 52                                             */
+/*               Römerstraße 52                                              */
 /*               D-70794 Filderstadt                                         */
 /* EMail:        uz@cc65.org                                                 */
 /*                                                                          */
@@ -113,6 +113,8 @@ void ObjReadHeader (FILE* Obj, ObjHeader* H, const char* Name)
     H->StrPoolSize  = Read32 (Obj);
     H->AssertOffs   = Read32 (Obj);
     H->AssertSize   = Read32 (Obj);
+    H->ScopeOffs    = Read32 (Obj);
+    H->ScopeSize    = Read32 (Obj);
 }
 
 
@@ -141,6 +143,8 @@ void ObjWriteHeader (FILE* Obj, ObjHeader* H)
     Write32 (Obj, H->StrPoolSize);
     Write32 (Obj, H->AssertOffs);
     Write32 (Obj, H->AssertSize);
+    Write32 (Obj, H->ScopeOffs);
+    Write32 (Obj, H->ScopeSize);
 }
 
 
@@ -160,8 +164,15 @@ void ObjAdd (const char* Name)
        Error ("Could not open `%s': %s", Name, strerror (errno));
     }
 
-    /* Get the modification time of the object file */
-    if (fstat (fileno (Obj), &StatBuf) != 0) {
+    /* Get the modification time of the object file. There a race condition 
+     * here, since we cannot use fileno() (non standard identifier in standard
+     * header file), and therefore not fstat. When using stat with the    
+     * file name, there's a risk that the file was deleted and recreated
+     * while it was open. Since mtime and size are only used to check
+     * if a file has changed in the debugger, we will ignore this problem
+     * here.
+     */
+    if (stat (Name, &StatBuf) != 0) {
        Error ("Cannot stat object file `%s': %s", Name, strerror (errno));
     }
 
@@ -225,6 +236,8 @@ void ObjAdd (const char* Name)
     H.LineInfoOffs = LibCopyTo (Obj, H.LineInfoSize) - O->Start;
     fseek (Obj, H.AssertOffs, SEEK_SET);
     H.AssertOffs = LibCopyTo (Obj, H.AssertSize) - O->Start;
+    fseek (Obj, H.ScopeOffs, SEEK_SET);
+    H.ScopeOffs = LibCopyTo (Obj, H.ScopeSize) - O->Start;
 
     /* Calculate the amount of data written */
     O->Size = ftell (NewLib) - O->Start;