From 9d42f9be9318a472db3e15f7ad6175b301c81dbc Mon Sep 17 00:00:00 2001 From: duncathan <dunc@duncathan.com> Date: Tue, 25 Feb 2020 20:06:06 -0600 Subject: [PATCH] fixes generation errors if CS+ folder was ever dropped onto the window --- src/main.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main.lua b/src/main.lua index 67935ce..f1f0b72 100644 --- a/src/main.lua +++ b/src/main.lua @@ -47,10 +47,23 @@ local function recursiveWrite(path, name) end end +local function recursivelyDelete( item ) + if lf.getInfo( item , "directory" ) then + for _, child in ipairs( lf.getDirectoryItems( item )) do + recursivelyDelete( item .. '/' .. child ) + lf.remove( item .. '/' .. child ) + end + elseif lf.getInfo( item ) then + lf.remove( item ) + end + lf.remove( item ) +end + function love.directorydropped(path) local success = Randomizer:_mountDirectory(path) --Randomizer:_unmountDirectory(path) if success then + recursivelyDelete('csdata') -- completely clear the folder, in case of user error :) recursiveWrite('mounted-data', 'csdata') Settings.settings.csdirectory = 'csdata' Settings:update()