PDA

View Full Version : How to determine that a folder is empty?


jbotwood
03-16-2005, 11:28 AM
I want to validate a folder and check that it is empty, but can't figure out how to do this unless I know a filename in the folder. I have tried searching the folder for *.*, but returns a blank when I search a folder containing files. Also, I want to search a folder that may only contain other folders, so I'm not sure how I would do this?

Jeff

gspillane
03-17-2005, 02:34 AM
HI Jeff,

If friedrich doesn't have an easy answer using his built-in functions it would be an easy job to create the appropriate function and put it in a DLL and call the function from within the script and having the function return the relevant value. I can give you a hand if you need it.

Best Regards
Geoff Spillane
Data Down Under

jbotwood
03-22-2005, 10:57 AM
Thanks very much for the offer of help. My trouble is I am not a programmer and don't have any programming tools except for SB5, so even if you told me what to do to implement it I wouldn't be able to! :-(

I have tried using GetFileInfo to get the size of the folder, and the size of the folder\*.* but these don't work either. This also means i have no way of checking the size of a folder and it's contents during an installation, which would also be handy.

My best idea so far is to search for a large number of commonly found file extensions and see if anything turns up on any of the searches, or in the case of size testing to add them all up individually. Just means a lot of code and the end result cannot be very accurate...

How about freeware DLLs that do things like this? Do you know where I could find one?

Regards,

Jeff

gspillane
03-23-2005, 02:29 AM
Hi Jeff,

No problems I'll put one together for you, no charge :) , but I can't get to it for another week. Just let me know exactly what you need to look for and what feedback you need from the function. eg You need to look to see if a particular folder (full path?) exists and if so does it contain any files (certain files?), function returns "1" if it exists and has files, otherwise "0".

Best Regards,

Geoff Spillane
Data Down Under

jbotwood
04-11-2005, 09:26 AM
Thanks so much for the offer (I didn't reply for a while because I have been away from my installer for the last two weeks doing lesser work here). I would definately take you up on your kind offer, but I now think this is a bug:

I have the new version of SetupBuilder now with the very eagerly awaited help file (yeah!!) which quotes:

The Search for File function lets you search for files on the local system

Parameters

File Name
[in] The name of the file that you want to search for. You can use the * and ? wildcards in this field to search for files that match a specific pattern

Path to Search
[in] The path to the folder that you want to search in

Return Values

If the function succeeds, the %_SB_ERRORCODE% return value is nonzero.
If the function fails, the return value is zero

The Search for File function recurses through subfolders during the search

I am searching a folder with many subfolders, each containing a file called 'accura.exe'

If I try File Name=* or *.* or *.exe or a*.exe or accur?.exe

Then my return variable is always NULL. The %_SB_ERRORCODE% return value is always 0. If I search for a known filename, then it recursively lists every instance of the filename exactly as specified, but this is the only instance where this command works as in the help file

Jeff
Data Design Services

linder
04-11-2005, 09:34 AM
Sorry, the documentation is not correct. Wildcard characters (* and ?) are not allowed.

jbotwood
04-11-2005, 09:41 AM
Ah ok, do you have any other suggestion as a way to do this, or should i go the custom DLL route?

Jeff

linder
04-11-2005, 10:34 AM
Jeff,

I'll check if it is possible to add a search feature to handle wildcards. I'll let you know tomorrow.

jbotwood
04-13-2005, 04:50 AM
Thanks very much Friedrich, if you could add this feature it would be awesome

Jeff