Archive: Recursive remove of empty directories


Recursive remove of empty directories
I'm a new convert from Wise InstallMaster (sudden need for Brazilian Portuguese which Wise doesn't do!) and am generally pretty impressed - got everything up and running in about a day.

First newbie question for you all...

Is there a simple way to recursively delete directories that are empty or only contain other empty directories?

Our products have many nested directories and it can see it becoming a bit of a bind to remember to include every level in reverse depth order so they get removed. I know about the RMDir /r but that seems very dangerous - it could delete a user's data.

Out of interest why does NSIS not use the "log of installed files" approach to uninstalling, instead requiring me to list all my files again?

Thanks for any help!


Use RMDir for the subdirectories too.

NSIS is a script based system, the installer sections do not have to match uninstaller sections. You can however create a log file during installation and use it during uninstallation.


Joost Verburg wrote: Use RMDir for the subdirectories too.
OK. That's what I am doing - it just seems to be a recipe for disaster since if I miss one sub-dir the whole parent directory structure will remain, despite being "empty". Guess I'll just have to be careful! ;)

Joost Verburg wrote: You can however create a log file during installation and use it during uninstallation.
Presuably I'd have to do this manually somehow - write to an INI file as I copy files and read it back from the uninstaller?

Thanks for the response.


Duncan

Originally posted by Dunyunkin
Presuably I'd have to do this manually somehow - write to an INI file as I copy files and read it back from the uninstaller?
Yes. You can put it all in a macro to make it easier to use.

As a result of my previous questions, I have written a plugin that will delete all subdirectories of a given directory if they are empty or only contain other empty subdirectories.
However there is an issue with linkage - I'm using findfirst, strcmp and various other functions - which then give me unresolved externals in Release builds.
I can resolve this by linking to LIBC but am I then asking for trouble? Can I assume everyone has the required support (it adds dependencies on Kernel32.dll and NTDLL.dll to my plugin DLL)?


Static linking should work fine. Can you add your plug-in to the NSIS Archive?


Staic linking should work fine.
Thanks!