You are here

DirectoryCleanupForce with wildcard

3 posts / 0 new
Last post
darksabre76
darksabre76's picture
Offline
Last seen: 2 months 2 weeks ago
Developer
Joined: 2011-04-19 23:28
DirectoryCleanupForce with wildcard

I'm currently working on a program that creates a partial-randomly named directory to work with and then leaves it there after runtime. I assume it's being used as a temporary file storage location, but that is inconsequential because I want to remove it. Unfortunately, DirectoryCleanupForce doesn't seem to work with wildcards. Is there a way of getting rid of these directories? Or will I have to resort to using NSIS scripting? Below is the exact code I have written in the launcher.ini file.

[DirectoriesCleanupForce]
1=%USERPROFILE%\.asy
2=%PAL:AppDir%\asy\asy_*

Thanks in advance.

Magibon
Offline
Last seen: 10 years 6 months ago
Joined: 2011-12-06 07:57
Custom.nsh

it's been a while since i've made a portableapp..
but if i recall correctly..
you have to use "FindFirst", or "ForEach" with wildcards...

- are the directories empty?
if so.. you can use locate plugin.
ie. locate::RMDirEmpty.

if not..
- create a file called "Custom.nsh" w/following content:


!define FindFirstDelete `!insertmacro FindFirstDelete`
!macro FindFirstDelete _PATH _NAME
     FindFirst $R0 $R1 `${_PATH}\${_NAME}`
       ${DoWhile} $R1 != ""
       RMDir /r `${_PATH}\$R1`
     FindNext $R0 $R1
       ${Loop}
     FindClose $R0
!macroend

${SegmentFile}
${SegmentPostPrimary}
     ${FindFirstDelete} `$PROFILE` `.asy*`
     ; uncomment if you're positive it's necessary to delete folder below.
     ;${FindFirstDelete} `$AppDirectory\asy` `*asy`
!macroend

NOTE: i wouldn't worry about folders inside the app. directory.

darksabre76
darksabre76's picture
Offline
Last seen: 2 months 2 weeks ago
Developer
Joined: 2011-04-19 23:28
Thanks

I was hoping for something in the launcher, but that NSIS script looks like it'll do the trick. Thanks for the code and advice. I'll try it out.

Log in or register to post comments