Delete .DSO
by Taron James · in Technical Issues · 10/09/2002 (12:28 pm) · 3 replies
Ok im just trying to learn about VB, as my first project i decided to write a little proggy that would delete the dso files in the Realmwars demo, i figured it might be usefull, im not sure how to post this as a resource, so ill put the source code here, from this i figure it could be easily adapted to your individual projects, i have built a .exe that works ok, i would appreciate any input, its simple im just trying to learn and is probaly unproffessional ut hey we try, anyway heres the source.
Private Sub Command1_Click() Open "C:\DSOMatrix.txt" For Output As #1 Print #1, "@Echo Off" Print #1, "cls" Print #1, "@del C:\GarageGames\RealmWars\*.dso" Print #1, "cls" Print #1, "@del C:\GarageGames\RealmWars\rw\*.dso" Print #1, "cls" Print #1, "@del C:\GarageGames\RealmWars\rw\server\*.dso" Print #1, "cls" Print #1, "@del C:\GarageGames\RealmWars\rw\server\scripts\*.dso" Print #1, "cls" Print #1, "@del C:\GarageGames\RealmWars\rw\data\*.dso" Print #1, "cls" Print #1, "@del C:\GarageGames\RealmWars\rw\client\*.dso" Print #1, "cls" Print #1, "@del C:\GarageGames\RealmWars\rw\client\scripts\*.dso" Print #1, "cls" Print #1, "@del C:\GarageGames\RealmWars\rw\client\ui\*.dso" Print #1, "cls" Close #1 Name "C:\DSOMatrix.txt" As "C:\DSOMatrix.bat" Shell "C:\DSOMatrix.bat" MsgBox "All RealmWars .DSO Files Deleteted!" Kill "C:\DSOMatrix.bat" End End Sub Private Sub Command2_Click() End End SubHope this of some use any pointers welcome
#2
To get this working, first add the following function to the end of the consoleFunctions.cc file:
Then, add the following function to resManager.cc:
Then add the following to resManager.h (at line 315 or thereabouts):
Finally, add the following function to your common package in the main.cs file (found in example\common\):
Good luck with it. Haven't had any problems yet, but I'd like some feedback on the code and whether it works for you or not...
10/09/2002 (9:47 pm)
I don't know how much use anyone will get out of this, but I've got the game auto-deleting dsos without too much trouble. To get this working, first add the following function to the end of the consoleFunctions.cc file:
// Adds the deleteFile function to the console
ConsoleFunction(deleteFile, bool, 2, 2, "deleteFile(fileName)")
{
argc;
Con::expandScriptFilename(scriptFilenameBuffer, sizeof(scriptFilenameBuffer), argv[1]);
return bool(ResourceManager->deleteFile(scriptFilenameBuffer));
}Then, add the following function to resManager.cc:
// Delete file functionality, returns 0 on fail, 1 on succeed
bool ResManager::deleteFile (const char *fileName)
{
// If there's no filename, fail out.
if (!fileName)
return 0;
// Prevent a little nastiness...
if(!dStrstr(fileName, ".."))
{
// Comment the Con::warnf out if you want quiet deletion (ie. no console spam)
Con::warnf("Deleting file '%s'.", fileName);
// Actually delete the file.
dFileDelete(fileName);
}
return 1;
}Then add the following to resManager.h (at line 315 or thereabouts):
bool deleteFile(const char * fileName);
Finally, add the following function to your common package in the main.cs file (found in example\common\):
// Quit override
function quit()
{
echo("Deleting DSOs...");
// Create a new script object to handle the list of dso files
%tmp = new ScriptObject() {};
// Set the initial file count to zero
%num = 0;
// Search for *.dso files
%search = "*.dso";
// Search the directory tree for .dso files and construct a list.
for(%file = findFirstFile(%search); %file !$= ""; %file = findNextFile(%search))
{
%tmp.file[%num] = %file;
%num++;
}
// Cycle through the list and delete each file.
for (%i = 0; %i < %num; %i++)
{
deleteFile(%tmp.file[%i]);
}
// Delete the script object.
%tmp.delete();
// Return to the parent function.
return parent::quit();
}Good luck with it. Haven't had any problems yet, but I'd like some feedback on the code and whether it works for you or not...
#3
10/12/2002 (8:39 am)
The only Problem is this Daniel, people wanting to modify an existing game couldnt do so unless they have the TGE source code, or you have implemented this into your finished game. most people playing a given game may not neccasarily own the TGE source, writing a small (third party) application for a given game as in my example would simply be a matter of studying the directory structure of a game and altering the code to suit the game directory, so i think people especialy mod teams may find this of some use.
Associate Kyle Carter
del /S *.dso
Whenever I want to wipe out my DSO files, I just run that. The batch file lives inside my Torque Example directory.
Of course, the VB solution is ultimately more powerful ;)