Browse Source

* clean .o and .s from smartlinkpath when starting the writer

peter 25 years ago
parent
commit
65d78b71d2
1 changed files with 42 additions and 5 deletions
  1. 42 5
      compiler/assemble.pas

+ 42 - 5
compiler/assemble.pas

@@ -42,6 +42,9 @@ const
 type
 type
   PAsmList=^TAsmList;
   PAsmList=^TAsmList;
   TAsmList=object
   TAsmList=object
+  private
+    procedure CreateSmartLinkPath(const s:string);
+  public
   {filenames}
   {filenames}
     path     : pathstr;
     path     : pathstr;
     name     : namestr;
     name     : namestr;
@@ -427,6 +430,40 @@ begin
 end;
 end;
 
 
 
 
+procedure TAsmList.CreateSmartLinkPath(const s:string);
+var
+  dir : searchrec;
+begin
+  if PathExists(s) then
+   begin
+     { the path exists, now we clean only all the .o and .s files }
+     { .o files }
+     findfirst(s+dirsep+'*'+target_info.objext,anyfile,dir);
+     while (doserror=0) do
+      begin
+        RemoveFile(s+dirsep+dir.name);
+        findnext(dir);
+      end;
+     findclose(dir);
+     { .s files }
+     findfirst(s+dirsep+'*'+target_info.asmext,anyfile,dir);
+     while (doserror=0) do
+      begin
+        RemoveFile(s+dirsep+dir.name);
+        findnext(dir);
+      end;
+     findclose(dir);
+   end
+  else
+   begin
+     {$I-}
+      mkdir(s);
+     {$I+}
+     if ioresult<>0 then;
+   end;
+end;
+
+
 Constructor TAsmList.Init(smart:boolean);
 Constructor TAsmList.Init(smart:boolean);
 begin
 begin
 { load start values }
 { load start values }
@@ -443,10 +480,7 @@ begin
   if SmartAsm then
   if SmartAsm then
    begin
    begin
      path:=current_module^.outputpath^+FixFileName(current_module^.modulename^)+target_info.smartext;
      path:=current_module^.outputpath^+FixFileName(current_module^.modulename^)+target_info.smartext;
-     {$I-}
-      mkdir(path);
-     {$I+}
-     if ioresult<>0 then;
+     CreateSmartLinkPath(path);
      path:=FixPath(path,false);
      path:=FixPath(path,false);
    end
    end
   else
   else
@@ -565,7 +599,10 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.63  2000-04-04 15:05:03  pierre
+  Revision 1.64  2000-06-01 13:02:45  peter
+    * clean .o and .s from smartlinkpath when starting the writer
+
+  Revision 1.63  2000/04/04 15:05:03  pierre
    + accept nasmwin32 output
    + accept nasmwin32 output
 
 
   Revision 1.62  2000/02/24 18:41:38  peter
   Revision 1.62  2000/02/24 18:41:38  peter