Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Future Improvements (https://forums.graalonline.com/forums/forumdisplay.php?f=10)
-   -   loadSubFolders(str, int); (https://forums.graalonline.com/forums/showthread.php?t=80405)

xXziroXx 07-08-2008 01:30 PM

loadSubFolders(str, int);
 
I would like to request this EXTREMELY useful function. As of now, I can load a folder's content with loadFolder(str, int); - but that's it. If I have a lot of dynamically created folders (which I do) as subfolders to a folder, there is no way I can find them out at the moment - without resorting to saving the name of each created folder in an array (heaven forbid).

This function would only list the name of the subfolders to the folder sent as parameter.

Example:

PHP Code:

temp.foo loadSubFolders("levels/"0);
echo(
temp.foo); 

Would (on Mythic anyways) echo:

PHP Code:

audioganisgmapsimagesMUDLIBProjectCastleTownrandomizedstafftemplates 



So pwetty pwease, can this be added? :cry:

*begs*

Twinny 07-08-2008 02:01 PM

Can't you just do loadfolder([str]startfolder,[bool]recursive) and make recursive true? Recursive should grab every single file starting from start folder then all subfolders until it gets everything.

xXziroXx 07-08-2008 02:12 PM

Didn't work when I tried it, so I doubt it.

Twinny 07-08-2008 02:15 PM

PHP Code:

temp.array.loadfolder("twinny/test/*"1); 

Started at twinny/test/ and managed to grab all the files in the subfolders :). Just had to make sure NPC-Server had for twinny/test/* and twinny/test/*/*

xXziroXx 07-08-2008 02:23 PM

Quote:

Originally Posted by Twinny (Post 1401474)
PHP Code:

temp.array.loadfolder("twinny/test/*"1); 

Started at twinny/test/ and managed to grab all the files in the subfolders :). Just had to make sure NPC-Server had for twinny/test/* and twinny/test/*/*

Hmph, I see. It didn't work when I did:

PHP Code:

temp.foo.loadFolder("levels/MUDLIB/*.ini"1);
echo(
temp.foo); 

But this solved that issue:

PHP Code:

temp.foo.loadFolder("levels/MUDLIB/*/*.ini"1);
echo(
temp.foo); 

However, I reckon this could still prove a useful function to list what folders there are. No? :)

cbk1994 07-08-2008 07:35 PM

Loading the files in subfolders works flawlessly for my by setting the second parameter to true.

xXziroXx 07-08-2008 07:40 PM

Quote:

Originally Posted by cbk1994 (Post 1401540)
Loading the files in subfolders works flawlessly for my by setting the second parameter to true.

Did you even bother to read my post above your post? >_<

cbk1994 07-08-2008 08:11 PM

Quote:

Originally Posted by xXziroXx (Post 1401542)
Did you even bother to read my post above your post? >_<

Yes. I'm saying that I don't need to use the second /* like you have to.

xXziroXx 07-08-2008 08:22 PM

Were you trying it with a file extension? Because, it's when you do that you need that extra /*.

cbk1994 07-08-2008 08:23 PM

Quote:

Originally Posted by xXziroXx (Post 1401547)
Were you trying it with a file extension? Because, it's when you do that you need that extra /*.

No ;o

I've just always run my own check (file.ends( ".txt" ))

xXziroXx 07-08-2008 08:34 PM

Quote:

Originally Posted by cbk1994 (Post 1401548)
No ;o

I've just always run my own check (file.ends( ".txt" ))

Silly. :p

zokemon 07-09-2008 10:33 AM

Folders don't end in .ini so why would they show up?

xXziroXx 07-09-2008 01:55 PM

Quote:

Originally Posted by zokemon (Post 1401631)
Folders don't end in .ini so why would they show up?

DAMNIT, people need to learn how to read. -_-


PHP Code:

temp.foo.loadFolder("levels/*.nw"0); 

Will load all .nw files from levels folder.


PHP Code:

temp.foo.loadFolder("levels/*/*.nw"1); 

Will load all .nw files from levels folder, and direct subfolders (not indirect ones though).


PHP Code:

temp.foo.loadFolder("levels/*"0); 

Will load all files from levels folder.


PHP Code:

temp.foo.loadFolder("levels/*"1); 

Will load all files from levels folder and all subfolders.

zokemon 07-09-2008 10:46 PM

Quote:

Originally Posted by xXziroXx (Post 1401648)
DAMNIT, people need to learn how to read. -_-

Stuff

Exactly. Again, why would a folder end in .ini? It makes perfect sense why it doesn't work when you end your wildcard with an extension.

Inverness 07-10-2008 12:31 AM

Its a simple concept, loadfolder() will only include filenames that fit the wildcard. So obviously if you do loadfolder("levels/*.nw", 0); its only gonna include nw files in the array, there is no need to use variable.ends() to check extension unless you're dealing with more than one or something. If dealing with more than one it would probably be easier to use more than one loadfolder with different extensions.

Zero I don't think you understand how the function is working.


All times are GMT +2. The time now is 03:53 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.