PDA

View Full Version : File Functions


TheStan
06-29-2008, 09:34 PM
Recently, I found a need for a few quick access file functions. They may or may not help you but I thought it would be helpful to release to the public. :)

I replaced the percent signs with "#" signs. For the problem with the request error.


public function getfolder(folder) {
temp.folder.loadfolder(folder @ "*", 0);
return temp.folder;
}
public function getfilelines(file) {
temp.lines.loadlines(file);
return temp.lines;
}
public function getfilevars(file) {
temp.vars = new TStaticVar();
temp.vars.loadvars(file, 0);
return temp.vars.getdynamicvarnames();
}
public function garbagecollect(fold, filetype) {
temp.folder = null;
temp.f = null;
temp.file = null;

folder.loadfolder(format("#s*.#s", fold, filetype), 0);
echo(folder);
for (f: folder) {
if (filesize(format("#s#s", fold, f)) < 1) {
//deletefile(folder @ f);
//deletefile(f);
}
else {
file = new TStaticVar();
file.loadvars(format("#s#s", fold, f));

if (file.getdynamicvarnames().size() < 1) {
//deletefile(folder @ f);
//deletefile(f);
}
}
}
}



Determine whether or not you like the code through the reputation. :)

projectigi
06-29-2008, 10:05 PM
uh what about the last function?
echo?
commented out delete file? o.o

Tigairius
06-30-2008, 12:07 AM
Uh, okay? Always nice to have more code gallery additions :) It's not worth repping though.

TheStan
06-30-2008, 12:57 AM
uh what about the last function?
echo?
commented out delete file? o.o

I commented out delete file because I'm not sure which one is the proper way, with the filepath or just the file name.

Uh, okay? Always nice to have more code gallery additions :) It's not worth repping though.

Lmao, rightyo Tig.