AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   open_dir() + next_file() +? alphabetical. (https://forums.alliedmods.net/showthread.php?t=109639)

fysiks 11-19-2009 18:45

open_dir() + next_file() +? alphabetical.
 
I'm trying to read files in alphabetically but when I use this the files are not alphabetical.

PHP Code:

    new filename[32], len
    
    
new pDir open_dir(szFilepathfilenamecharsmax(filename))
    
    if(
pDir)
    {
        do
        {
            
len strlen(filename)

            if(
len 4)
            {
                if( 
equal(filename[len 4], ".ini") )
                {
                    
// Load file!!!
                    
server_print("Filename: %s"filename)
                    
// server_print(">>>>Yippeeeee!!!!!!!")
                
}
            }
        } while( 
next_file(pDirfilenamecharsmax(filename)) )
        
close_dir(pDir)
    } 

Output:
Code:

test
Filename: maps2.ini
Filename: maps3.ini
Filename: maps4.ini
Filename: maps1.ini

The ultimate goal is to be able to define the order files are read by prefixing the filenames with 1, 2, 3, etc. Like rc#.d folders in linux (I'm using Fedora).

joropito 11-19-2009 19:53

Re: open_dir() + next_file() +? alphabetical.
 
Put the list of files in array, sort the array and the use the sorted array.

open_dir / next_file will return the files in order as they appear in the disk (physically)

fysiks 11-19-2009 20:29

Re: open_dir() + next_file() +? alphabetical.
 
I was hoping to process file's inline. :(. But it can easily be done this way.


All times are GMT -4. The time now is 05:30.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.