My patcher removes legacy files just fine... but it leaves the empty directory structure installed. Anyway to have that removed automatically as well?
Thanks.
Professional Software Development Tools
My patcher removes legacy files just fine... but it leaves the empty directory structure installed. Anyway to have that removed automatically as well?
Thanks.
You could do that from the TrueUpdate server script using Folder.Delete actions.
--[[ Indigo Rose Software Developer ]]
Yeah, I was hoping to avoid that.
The current scenario where the files just get deleted automatically is the best.
I can use Folder.Delete like you suggested, but that requires me to have knowledge of what is being removed. Unless I just go through and recursively delete any empty folder...
BTW, when do legacy files get deleted? Does it happen before the "On Post Patch" actions?
Thanks.
Do you mean with Visual Patch 3.0? (Your original post didn't specify.)
--[[ Indigo Rose Software Developer ]]
Ahhh yeah, I posted in the wrong forum.
VP3.
No worries...
PATCH_STAGE_REMOVING_LEGACY_FILES happens right after PATCH_STAGE_PATCHING_FILES in the patching sequence.
So, right after all of the files are patched.
(I would have just said so above, but I was checking the source code to make sure.)
It goes like this:
- Initialize some Lua variables (_CommandLineArgs, %SourceFolder%, etc.)
- Begin the log file.
- Initialize the language support.
- Verify the file archive integrity.
- Load action plugins.
- Do any Global Script includes.
- Run the Global Functions script.
- Run the On Startup actions.
- Show the Before Patching screens.
- Run the On Pre Patch actions.
- Start writing the log file to disk.
- Show While Patching screen.
- Patch files.
- Remove legacy files.
- Handle any files that need to be deleted or moved on reboot.
- Destroy the progress screen controller.
- Run the On Post Patch actions.
- Show the After Patching screens.
- Run the On Shutdown actions.
- Delete any temp files.
- Exit the patch.
--[[ Indigo Rose Software Developer ]]
In case anyone needs this:
--[[
************************************************** ********************************
Function: RemoveEmptyFolders
Purpose: Recursively remove empty folders starting from the given folder.
Arguments: (string) rootFolder
Returns: nothing
************************************************** ********************************
--]]
function g_RemoveEmptyFolders( rootFolder )
folders = Folder.Find( rootFolder, "*", false, nil );
if ( folders ) then
-- recursively remove empty folders
for i, folderName in folders do
g_RemoveEmptyFolders( folderName );
end
end
-- All of the empty sub-folders have been removed. Do one last check to see
-- if this folder has files or folders in it, if not, then remove it.
folders = Folder.Find( rootFolder, "*", false, nil );
files = File.Find( rootFolder, "*.*", false, false, nil, nil );
if ( (not folders) and (not files) ) then
-- This folder is also empty. Remove it.
Debug.Print( "Folder to be removed: " .. rootFolder .. "\r\n" );
Folder.Delete( rootFolder );
end
end