Filename Tracking System?
Blitz3D Forums/Blitz3D Programming/Filename Tracking System?
| ||
Hey guys, this is kind of a conceptual thing, I haven't coded this yet. I'm thinking of a way to track loaded assets filenames and store them in a list when you run a program. I'm finding that I have to keep cleaning house, so to speak when ever I'm set to distribute a demo version of my programs. I have a whole pile of files, of which over 25 percent I'm not using at all. I worry that I'm distributing files that aren't even being used. Anyway here's my idea. If you guys have a better idea please speak up. I'm open to any suggestions. Create a lib like... Global TrackFiles = True Type TFile Field FileName$ End Type Function TrackFile(FileName$) If TrackFiles then ;Check to see if the file is in the TFile list already For TF.TFile = Each TFile if TF\FileName = FileName then Return FileName next NewTF.TFile = New TFile\ NewTF\FileName = FileName End if Return FileName End if End Function Then in your game code you would use Mesh = LoadMesh(TrackFile("models/car.b3d")) Then you could generate a list of files that are actually used by the program. Of course this introduces yet another problem, b3d files, and the like, which reference textures. Any ideas? I'd like to come up with a solution that can move all the files need by the code to a new location on my drive without having to dice through it manually every time. |
| ||
Hmm...because the Blitz files are in ASCII, you could just go through each line like a regular file, and whenever it finds a certain function (i.e. LoadMesh), it can locate the string's beginning and end with Instr, and then Replace LoadMesh("whatever") with LoadMesh(TrackFile("whatever")). Perhaps that would work, and it'd run through your whole program. Hope this helps. |
| ||
I give it a go tonight. I don't think I'll worry too much about the texture files just yet. That's just a small part of project. As long as it catches the majority of the file, it'll still be better then digging through it manually. |
| ||
That sounds like a good start, quite a nice idea actually, I have the same problem. DeepThought, that won't work if you create filenames on the fly or have custom functions to do loading. ie function loadlevel(filename$)All of these will never be found. a$="hello" b$=".bmp" for n=1 to 10 image(n) = loadimage a$+n+b$ nextI think Craig has got the idea right of doing it within the code. Your problem with the associated files isn't a problem as you can get the texture names out of your meshes. Although, quite frankly not sure if it's worth the hassle. To add more function to it you could have an additonal program that scans all of the files in the working directory and compares it against the trackfile.dat file (see below) to see what differences there are and therefore what files to delete... maybe even add an autodelete option, although with this you'd have to pull the texture names out of your meshes. Futhermore when checking through the files trackfile it could highlight .BMPs .WAVs etc and suggest coverting these to PNGs or OGGs for example. I would also change your function a little and add another one that gets called when the program exits. Global TrackFiles = True Type TFile Field FileName$ End Type Function TrackFile$(FileName$) If Not TrackFiles Then Return ;Check to see if the file is in the TFile list already For TF.TFile = Each TFile If TF\FileName = FileName Then Return FileName Next ; Create a new TFile Tf.TFile = New TFile Tf\FileName = FileName Return FileName End Function Function SaveTrackFile(filename$ = "TrackFile.dat") fileout = WriteFile (filename) For tf.tfile = Each tfile WriteString(fileout,tf\filename) Next End Function Craig, I also deleted the duplicate thread in the showcase |
| ||
I tried it, it actually worked quite good. Wrote a routine that copies all the content subdirectories and files to a new location on the drive. It wasn't able to get all the files, but it did manage to get 99% of them making for a very slimmed down file demo directory. I'll post the final code when I get it to a point where it's more user friendly. |