Author Topic: Getting folders.  (Read 1103 times)

Is there a way to get in a certain folder?

Please elaborate, do you mean find all files in a folder?

Quote
findFirstFile (string pattern)
   -Used to return the first file in the directory system matching the given pattern
   -Returns a string

   findFirstFile(“/fps”, “*.cs”);

findNextFile (string pattern)
   -Used to return the next file matching a search begun in findFirstFile
   -Returns a string

   findNextFile(“/fps”, “*.cs”);

getFileCount (string pattern)
-Used to return the number of files in the directory tree that match the given pattern
   -Returns a numeric

   getFileCount(“/fps/client/scripts”, “*.cs”);

I mean find folders, not files, I know how to do that.

If your wanting to count folders or look for a specific folder, I'm not sure.  If you're wanting Blockland to recognize file or folders that weren't there at startup, do this:

Code: [Select]
setModPaths(getModPaths());

I want to get all folders in the add-ons folder and then add them to a list.

The only way I can think of doing that is looping through all the files in Add-Ons/ and recording their folders.
Code: [Select]
for(%i=findFirstFile("Add-Ons/*.cs");%i=findNextFile("Add-Ons/*/*");%i!$=""){
//filepath
%path = filePath(%i);
// folder (inside add-ons)
%folder = getSubStr(%path, 8, strLen(%path) - 8); // may need to change the numbers, but you get the idea
}
« Last Edit: November 27, 2007, 01:20:11 PM by Randy »

Wait, that only searches for FILES in the Add-Ons folder.  He wants FOLDERS in the Add-Ons folder.

You need to make a search method using findFirstFile / findNextFile with Add-Ons/*/*.*.  It won't find folders without files and it won't find subdirectories of folders within Add-Ons, but I think it's the only way possible.