Collecting all files in a directory.
#1

I need to get the file name of all the files in a specific folder/directory. This poses a problem because you cannot easily achieve this considering there are not any functions to handle this in pawn or in y_ini (the file system I'm using). So I looked around for a plugin, but this plugin was bugged and out dated so I could not use this. So my question is, how can I iterate through a directory and collect all the files/file names into one array so I can display it and use the collected data. Thanks in advance for the help, or attempts of help.
Reply
#2

You'll have to use one of the file plugins. There's no functionality for this in pawn.
Reply
#3

I always had problems doing this too therefore i first switched to SQLite and then MYSQL. Quering everything is easy and efficient.
Reply
#4

Does it create a local database, or do I need to have a server?
Reply
#5

Still need help.
Reply
#6

Quote:
Originally Posted by MP2
View Post
You'll have to use one of the file plugins. There's no functionality for this in pawn.
Reply
#7

There are multiple file plugins on the forums. If you have problem with the one you tried, try another.



If your files are numbered and are in format e.g. "1.ini", than you can make a loop like this:

pawn Code:
for (new i = 1, filename[12]; i <= 100; i++) // replace "100" with the maximum number you have in the directory
{
    format(filename, sizeof(filename), "%d.ini", i);

    if (fexist(filename))
    {
        // file exists, do whatever you want here
    }
    else continue;
}
If your files are not numbered, than you'll have to use a plugin.
Reply
#8

I must have skipped over the plugins then, Ill go search even more.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)