PDA

View Full Version : Checking for file delete/create results


DavidMacLean
01-26-2006, 02:29 PM
Building project step 'Create Release directory'...
A subdirectory or file C:\Foo\Bar already exists.

Building project step 'Empty output directory'...
File C:\Foo\Bar\*.BPL' does not exists


The above results using a RUN PROGRAM action, eg

%DOSCMD% CALL DEL %RELEASEDIR%\*.BPL


It is not an error if the file to be deleted is already deleted. Similarly, it is not an error if the directory to be created already exists.

Yet if I shut off "fail on errors", what happens when there is a real error?

Any advice...? Please and thank you.

kinook
01-26-2006, 03:48 PM
For the create case, conditionally build the step only if the folder doesn't exist. See the Create dest dir step of the Recurse.bld sample.

In the delete case, testing here on Windows XP SP2 (with %DOSCMD% resolving to C:\WINDOWS\system32\cmd.exe /C), that command does return a 0 (success) exit code if no matching files are found, but if it does something different in your environment, you could treat a failure with output containing 'does not exist' as success by adding (VBScript) code like this to the step's vbld_StepDone script event function:

If InStr(Application.ExpandMacros("%LASTSTEP_OUTPUT%"), "does not exist") Then
Step.BuildStatus = vbldStepStatSucceeded
End If

See help on script events for more details: http://www.visualbuild.com/Manual/?scriptevents.htm

DavidMacLean
01-27-2006, 12:04 PM
Thank you for a prompt and helpful reply