Copy Directory if it doesn't already exist
BlitzMax Forums/BlitzMax Programming/Copy Directory if it doesn't already exist
| ||
I know this should be easy enough... but I just can't seem to grasp it at the moment... :( So I've got everything within my (OS X) App but of course we don't want the user to save their saves, etc to here. I've also got some pre-made user files in the App's resource folder. What I want to do is make it so the App checks to see if this folder already exists in the users Application Support folder, if it doesn't it copies this pre-made folder over to Application Support folder. If anyone could provide me with some sample code to do this that would be super! |
| ||
I recommend you check out Brucey's bah.Volumes module. All the functions you need are in there. http://code.google.com/p/maxmods/wiki/VolumesModule |
| ||
And because it's the season of giving here's some code.Import bah.Volumes Local appSupport:String=GetUserAppDir()+"/MyGame/SaveDir" Local appResource:String=StripDir(AppFile)+".app/Contents/Resources/SaveDir" If FileType(appSupport)=0 CopyDir appResource,appSupport EndIf Last edited 2011 |
| ||
Thank you kindly for your Christistmas generosity Dave! |
| ||
If FileType(Path)=FILETYPE_DIR ? Would be 0, I believe, if it doesn't exist? |
| ||
Yes. ImaginaryHuman is correct. I made a booboo.Import bah.Volumes Local appSupport:String=GetUserAppDir()+"/MyGame/SaveDir" Local appResource:String=StripDir(AppFile)+".app/Contents/Resources/SaveDir" If FileType(appSupport)=2 CopyDir appResource,appSupport EndIfCorrected. |
| ||
Thanks ImaginaryHuman. Thank you both and I hope you both have a very merry Christmas. |