Raised This Month: $32 Target: $400
 8% 

open_dir() + next_file() +? alphabetical.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-19-2009 , 18:45   open_dir() + next_file() +? alphabetical.
Reply With Quote #1

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).
__________________
fysiks is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 11-19-2009 , 19:53   Re: open_dir() + next_file() +? alphabetical.
Reply With Quote #2

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)
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-19-2009 , 20:29   Re: open_dir() + next_file() +? alphabetical.
Reply With Quote #3

I was hoping to process file's inline. . But it can easily be done this way.
__________________
fysiks is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:15.


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