Jump to content











Photo
- - - - -

DirDelete


  • Please log in to reply
2 replies to this topic

#1 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 15 September 2006 - 09:36 AM

As posted already in the MkISOFs topic:
When running from RAM and then building the project again, the target directory is not deleted.

Commands:
[ClearTarget]

If,ExistDir,"%TargetDir%",Echo,"Deleting [%targetdir%]"

If,ExistDir,"%TargetDir%",DirDelete,"%TargetDir%"

If,ExistDir,"%TargetDir%",Exit,"%TargetDir% could not be deleted!"

After the first run I have the following folder structure
[attachment=323:attachment]

In the second run, after executing [ClearTarget], I have:
[attachment=324:attachment]
The Ramboot folder is emptied, but not deleted. Everything else remains.

When before the second run I manually delete the ramboot folder, I get:
[attachment=325:attachment]
The target folder is completely emptied, but still exists!

@Nuno: I think a short view into the source code is necessary.

Peter

#2 Brito

Brito

    Platinum Member

  • .script developer
  • 10616 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 15 September 2006 - 12:07 PM

I'm not using internal delphi functions to delete dirs - I've switched to winAPI some time ago, here's the code in any case:
function DirDelete(Dir : String) : Boolean;

var

 tom : TSHFileOpStruct;

begin

 ZeroMemory(@tom,SizeOf(tom));

 with tom do

 begin

   wFunc := FO_DELETE;

   fFlags := FOF_SILENT or FOF_NOCONFIRMATION;

   pFrom := PChar(Dir + #0);

 end;

 RESULT := (0 = ShFileOperation(tom));

end;

All errors and question messages are automatically overwritten with "FOF_SILENT or FOF_NOCONFIRMATION", otherwise it uses the same method used by explorer to delete files.

If dirdelete is not deleting the folder, then I'd assume there is still one handle that protects this folder from being deleted..

I use this nifty tool to check why files and folders get locked and wich programs are locking them..

http://www.softpedia.../Unlocker.shtml


You've also mentioned that a thread from winbuilder might be preventing the folder from being deleted, and when checking from explorer it is already free to be erased. I guess the best way of knowing is tracking each command to check the behaviour - but this might take some time to know if this is the reason or not..

:P

#3 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 15 September 2006 - 03:48 PM

I got a different error which I could not explain to myself:
The code
If,ExistFile,"%TargetDir%\i386\system32\drivers\#1s",ShellExecute,"hide","makecab.exe","#$q%TargetDir%\i386\system32\drivers\#1s#$q #$q%TargetDir%\i386\system32\drivers\#1_#$q"

If,ExistFile,"%TargetDir%\i386\system32\drivers\#1_",FileDelete,"%TargetDir%\i386\system32\drivers\#1s"
run well with two files.
With the third file there was the error "could not delete"

I found the reason:
My first two files have been expanded out of a cab, while the third one was copied.
AND: My Source Directory is ReadOnly.

I took away the ReadOnly, the mentioned error did not occur again.

AND: The DeleteDir issue seems to be solved, too :P

Peter




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users