28.01.2013, 12:29
(
Последний раз редактировалось Swimor; 04.02.2013 в 14:08.
)
RL_FILES - makes your life easy
version: 1.3.1, tutorial: here
Hello,
Know the feeling when you must create loop over whole directory?
And what if the file names not "1.ini, 2.ini 3.ini"? Yes, This plugin will fix this!
Some time ago i asked how to do this (here) and get this answer:
And now I have developed little plugin that will fix this.
Installation
Simply, In "server.cfg" add:
And where you want to use the plugin add at the top:
Functions - Files
fcheck - check if file exist by id,
dir - The directory where you check if file exist in
idx - id of the file that you checking
fnum - count number of files in directory,
dir - The directory where you count the files
fname - returns file name by id,
dir - The directory where your files in
idx - id of the file that you want to get
name - variable that stores the name of the file
len(optional) - maximum length of the name
fprint - print all files in directory,
dir - The directory where you want to print all files
fend - delete the file ext,
file - file name with ext
Functions - Directories
dopen - Open specific directory,
dir[] - The directory that you want to open
dreopen - reOpen already opened directory,
Dir:dir - The opened directory that you want to re-open
dread - Read files / directories from already opened dir,
Dir:dir - The opened directory that you want to read from
dclose - Close (end) working with directory,
Dir:dir - The opened directory that you want to close
dcreate - Create directory,
dir[] - Name of the directory that you want to create
dremove - Delete directory,
dir[] - Name of the directory that you want to
drename - Rename directory,
dir[] - Name of the directory that you want to
dexist - Check if specific directory exist,
dir[] - Name of the directory that you want to
Examples
Here is my files:
We can do loop over all files in the directory
This will print the flowing,
Here some example how to create /ClanList command:
Here example of reading directory:
Credits
Download
1.3.1:
Mediafire: http://www.mediafire.com/download.php?dsypn2vfbxam0l7
PasteBin (Include): http://pastebin.com/P2jAHzPc
Source: http://www.mediafire.com/download.php?phz1x848421xo40
1.2.7:
Mediafire: http://www.mediafire.com/?sv34wfoeee5b9e2
PasteBin (Include): http://pastebin.com/GyEgzfkK
Source: http://www.mediafire.com/?713o1ddl9aj2tym
1.2.4:
Mediafire: http://www.mediafire.com/?r8t9tl55rmv5fbz
PasteBin (Include): http://pastebin.com/6Gnk2Tw0
Source: http://www.mediafire.com/?713o1ddl9aj2tym
1.2.1:
Mediafire - http://www.mediafire.com/?1az34pcg20krlla
PasteBin (Include) - http://pastebin.com/YM68UVKb
Source - http://www.mediafire.com/?3kk28924r5txydi
Notes
Bugs & Suggestions
Whats new?
Enjoy!
version: 1.3.1, tutorial: here
Hello,
Know the feeling when you must create loop over whole directory?
And what if the file names not "1.ini, 2.ini 3.ini"? Yes, This plugin will fix this!
Some time ago i asked how to do this (here) and get this answer:
Quote:
This is just in case you saved the files in numerical order. |
Installation
Simply, In "server.cfg" add:
Код:
plugins X rl_files.dll X
pawn Код:
#include <rl_files>
fcheck - check if file exist by id,
pawn Код:
fcheck(dir[], idx)
idx - id of the file that you checking
pawn Код:
if(!fcheck(NULL_DIR, 0)) return 1;
pawn Код:
fnum(dir[])
pawn Код:
new
test = fnum(NULL_DIR);
pawn Код:
fname(dir[], idx, name[], len = sizeof(name))
idx - id of the file that you want to get
name - variable that stores the name of the file
len(optional) - maximum length of the name
pawn Код:
new
file[32];
fname(NULL_DIR, 0, file);
printf("%s", file);
pawn Код:
fprint(dir[])
pawn Код:
fprint(NULL_DIR);
pawn Код:
fend(file[])
pawn Код:
printf("file name \"test.ini\" without ext is: \"%s\"", fend("test.ini"));
dopen - Open specific directory,
pawn Код:
Dir:dopen(const dir[])
pawn Код:
new
Dir:test = dopen("test");
pawn Код:
dreopen(Dir:dir)
pawn Код:
dreopen(test);
pawn Код:
dread(Dir:dir, file[], &type)
pawn Код:
while(dread(test, str, type)) {
printf("%s: %s, type: %d", (type == TYPE_DIR)? ("dir"):("file"), str, type);
}
pawn Код:
dclose(Dir:dir)
pawn Код:
dclose(test);
pawn Код:
dcreate(const dir[])
pawn Код:
dcreate("test");
pawn Код:
dremove(const dir[], bool:empty = true)
pawn Код:
dremove("test", true);
pawn Код:
drename(const oldname[], const newname[])
pawn Код:
drename("test", "test2");
pawn Код:
dexist(const dir[])
pawn Код:
if(dexist("test"))
print("folder \"test\" exists!");
Here is my files:
Код:
Ccsds.tdssa hdgsadgsa.dshdg dsjhfkfdg.dssdsaf hmmippewg.dsa test.iinfhfbd
pawn Код:
new
idx,
file[MAX_FILE_NAME];
while(idx < fnum(NULL_DIR)) {
fname(NULL_DIR, idx, file);
printf("file number %d: %s", idx, file);
idx++;
}
Quote:
file number 0: Ccsds.tdssa file number 1: hdgsadgsa.dshdg file number 2: dsjhfkfdg.dssdsaf file number 3: hmmippewg.dsa file number 4: test.iinfhfbd |
pawn Код:
if(!strcmp(cmdtext,"/ClanList",true)) {
new
idx,
file[MAX_FILE_NAME];
while(idx < fnum("Clans")) {
fname("Clans", idx, file);
SendClientMessage(playerid, 0xFF0000FF, fend(file)); // Send the message to client
idx++;
}
return 1;
}
pawn Код:
// Reading Directories functions
new
Dir:test = dopen("test"), // Open directory
str[64],
type;
while(dread(test, str, type)) { // Read directory
printf("%s: %s, type: %d", (type == TYPE_DIR)? ("dir"):("file"), str, type);
}
dclose(test); // Close directory
Quote:
Thanks to: RaFaeL - Scripting, PAWN Kyosaur - How to build plugin Gamer_Z - Help in passing arrays by reference SA:MP Team past, present, future - SA:MP. |
Quote:
By downloading this file you accept that you never will post it as yours! |
1.3.1:
Mediafire: http://www.mediafire.com/download.php?dsypn2vfbxam0l7
PasteBin (Include): http://pastebin.com/P2jAHzPc
Source: http://www.mediafire.com/download.php?phz1x848421xo40
1.2.7:
Mediafire: http://www.mediafire.com/?sv34wfoeee5b9e2
PasteBin (Include): http://pastebin.com/GyEgzfkK
Source: http://www.mediafire.com/?713o1ddl9aj2tym
1.2.4:
Mediafire: http://www.mediafire.com/?r8t9tl55rmv5fbz
PasteBin (Include): http://pastebin.com/6Gnk2Tw0
Source: http://www.mediafire.com/?713o1ddl9aj2tym
1.2.1:
Mediafire - http://www.mediafire.com/?1az34pcg20krlla
PasteBin (Include) - http://pastebin.com/YM68UVKb
Source - http://www.mediafire.com/?3kk28924r5txydi
Notes
Quote:
* There are no limit number of files in directory * Soon I will release new version with allot of new function! * There are limit to opened directories (16) |
Quote:
Known bugs: * Some times there are "Empty lines" appers - Seems Done |
Quote:
Suggestions (v1.3.1): * In fend check if ext is there - Done * farray, will make arrays of files, will improve the plugin performance asswell. - Freezed * dmove, will give option to move directories with the files in it. - In progress |
Quote:
v1.3.1: * Dir:dopen(const dir[]) - Open directory * dreopen(Dir:dir) - Reopen the directory (start file counting from 0) * dread(Dir:dir, file[], &type) - Get files and sub directories from directory * dclose(Dir:dir) - Close directory * dcreate(const dir[]) - Create new directory * dremove(const dir[], bool:empty = true) - Delete exist directory * drename(const oldname[], const newname[]) - Rename directory to new name * dexist(const dir[]) - Check if directory exist |
Quote:
v1.2.7: * Fixed bug in the plugin * Default dir[] = "." |
Quote:
v1.2.4: * fnum(dir[]) now PAWN scripted function * plugin speed performance is now fester |