Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Cescano
9
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 27th Jul 2015 07:44 Edited at: 27th Jul 2015 07:44
Is there a way to delete a directory without having to clear all the files inside? the delete directory command works only if the directory is empty
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 27th Jul 2015 09:58 Edited at: 27th Jul 2015 09:59
This code will delete the directory with all files and sub-folders.

Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 27th Jul 2015 10:27
Wicked function

Out of curiosity, why do you need to delete directories Cescano?

Cescano
9
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 27th Jul 2015 17:55
Because when you extract a .pak file a folder is created, and after loading the media I need to remove that temporary folder with all the content inside
Cescano
9
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 27th Jul 2015 19:18
I don't know if I am doing something wrong, the texture folder is removed, the sounds folder is still there for some reason
Cescano
9
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 27th Jul 2015 20:25
I am having a headache, if I try to compile the game with these .pak implemented, the game doesn't compile and highlight the 2nd file of the project where i recall:

path = get dir$()
dirName = path+"\TextureExtract"
DeleteDirectory(dirName)


If I try to set path and dirName as globals it runs, but when the game loads the data it crashes
Cescano
9
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 27th Jul 2015 20:37
Probably it crashes because just the 1st attempt to delete the directory works, the 2nd folder I try to delete doesn't work, I am stuck
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 27th Jul 2015 20:52
For some reason the function seems to be a one time deal. I will see if I can fix this when I get home from work tonight.
Cescano
9
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 27th Jul 2015 20:53
Thank you for your help Wicked
Cescano
9
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 28th Jul 2015 00:43
I have also tried to use this function:




and calling it using this one for example:



It seems to work if I load the menu, but when I load the game's data the program crash, probably because of too many files deleted and Windows close the process for security reason?
We discovered a new earth but we couldn't even delete a folder without crashing the program, sometimes things are more complex than what they should be
Cescano
9
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 28th Jul 2015 02:53
I have been able to let it work using the last function I mentioned, so dbpro commands only, it seems, what was wrong is that when I have created the .pak files I have used the "open to write" command inside the folder to copy, so that the .pak just created was included in the final .pak file, giving errors when opening the files from it.

The only problem I have noticed is that using the packs there is a bit of lag in some moments, for example when I try to change music (as I delete the current song and load a new one, so I should open the .pak file into a folder, and then remove the content and the folder), nothing huge but having the files open in the normal folders wasn't giving me any lag before, probably this is the cost to have a minimum protection for the files (so that normal people could not access my media directly).
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 28th Jul 2015 10:05 Edited at: 28th Jul 2015 10:11
Now, I remember the problem with using that API in DBPro. The SHFILEOPSTRUCT structure strings need to be double NULL terminated. For that reason I wrote the attached single function Plug-In a year or two ago. If the folders you’re deleting only contain files and no sub-folders then you can stick with your method.

Plug-In function usage:

Attachments

Login to view attachments
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 28th Jul 2015 10:09 Edited at: 28th Jul 2015 10:10
WickedX will probably provide the more easy solution; but if all else fails, you may need to hard code the operation with a few recursive functions. I have a file querying snippet here; but this will only provide you with information about files in a directory, and it will not search sub directories.

lol, just posted this almost at the same time as WickedX

Cescano
9
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 28th Jul 2015 21:19 Edited at: 28th Jul 2015 21:22
I have been able to fix the lag when entering buildings, previously I was extracting the Whole .pak folder to take a random music to play, now I use read fileblock to extract just the file I need from the main music.pak file, thanks to some posts in the forums here I have been able to let work this command which used "normally" doesn't work.
Cescano
9
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 28th Jul 2015 22:19
Nevermind, I just noticed that the same song was taken from the pack, so to skip and take the last file for example, it would lag as much as using read dirblock and extract the Whole folder, isn't there a way to grab a file from a .pak file without following the order of the files? It's just stupid that I have to extract 20 songs if I want to take the number 21

Login to post a reply

Server time is: 2024-04-19 18:04:02
Your offset time is: 2024-04-19 18:04:02