SA-MP Forums Archive
[Plugin] [REL]tfile 3.0 Best file system! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Plugin Development (https://sampforum.blast.hk/forumdisplay.php?fid=18)
+--- Thread: [Plugin] [REL]tfile 3.0 Best file system! (/showthread.php?tid=354128)

Pages: 1 2


[REL]tfile 3.1 Best ini files system #update 16.07.12 - Terminator3 - 25.06.2012

I present you, my new plugin named tfile 3.0, is based on C++ fstream and it's better than standard file.inc (more characters available)

Why it is better then others file systems?
Almost all to set one value to file must use one function, in my plugin you use one function to save or get unlimited number of data

Functions:

fGetData(const file[], const format[], {Float,_}:...)
Get the data from the file
Return numbers of getting values from file


fSaveData(const file[], const format[], {Float,_}:...)
Saves data to the file
Returns true if all is correct


fAddData(const file[], const string[], bool:exist = false)
Add data to the file
Returns true if all is correct


fDeleteData(const file[], const key[])
Deletes the data from the file
Returns true if all is correct


fKeyExist(const file[], const key[])
Check if key or keys (max 32) exist in file
For one key returns true/false, for more returns number that represented by bits which one key exist or not


fCreate(const file[], const string[])
Creates a file and saves something to him
Returns true if all is correct

Additional functions

fConvertTags(const file[], oldtag, newtag)
Convert diverting char
Returns true if all is correct


fChangeConfig(keytab = '=', nicelook = false, ignorekeycase = false, keysize = 30, linesize = 256)
Returns true if all is correct



*What is the format? i explain the example
pawn Code:
new pass[24], Float:hp, sex = 'F';
GetPlayerHealth(playerid, hp);
fSaveData("test.txt", "Money<d>Pass<s>HP<f>sex<c>", GetPlayerMoney(playerid), pass, hp, sex);
and in file we find:
Quote:

Money=10000
Pass=mama
HP=100.0
sex=F

and the same to get:
pawn Code:
new money, pass[24], Float:hp, sex;
fGetData("test.txt", "Money<d>Pass<s>HP<f>sex<c>", money, pass, hp, sex);
SetPlayerMoney(playerid, money);
SetPlayerHealth(playerid, hp);
<i> or <d> - number
<s> - string, text
<f> - float value
<c> - one char

pawn Code:
new x = fKeyExist("test.txt", "Money,Score,sex,Money");
if(x & 1) // if Money exist
    print("Money exist");

if(x & 2) // if Score exist
    print("Score exist");

if(x & 4) // if sex exist
    print("sex exist");

if(x & 8) // if Money exist
    print("Money exist");
pawn Code:
fDeleteData("test.txt", "Money,sex");
after that file looks:
Quote:

Pass=mama
HP=100.0

pawn Code:
new str[64];
format(str, sizeof str, "Money=%d\nScore=%d\nVIP=1\n", GetPlayerMoney(playerid), GetPlayerScore(playerid));
fAddData("test.txt", str);
Download:
tfile3.inc; Mirror
tfile.dll; Mirror
tfile.so; Mirror

Source Code; Mirror


Re: [REL]tfile 3.0 Best file system! - zgintasz - 25.06.2012

Nice ! I want to see some speed test results.
EDIT: hehe, first post


Re: [REL]tfile 3.0 Best file system! - Littlehelper - 25.06.2012

Looks nice, gonna test it.


Re: [REL]tfile 3.0 Best file system! - TheArcher - 25.06.2012

Looks a nice one, can you do some tests please. I'm so curious.


Re: [REL]tfile 3.0 Best file system! - Face9000 - 25.06.2012

Nice job.


Re : [REL]tfile 3.0 Best file system! - Vukilore - 25.06.2012

I'm waiting for a response of ******, to be sure


Re: Re : [REL]tfile 3.0 Best file system! - Terminator3 - 25.06.2012

Quote:
Originally Posted by Vukilore
View Post
I'm waiting for a response of ******, to be sure
Everybody loves professionals


Quote:
Originally Posted by TheArcher
View Post
Looks a nice one, can you do some tests please. I'm so curious.
Tests?


Re: [REL]tfile 3.0 Best file system! - rVar - 25.06.2012

Awesome! Waiting for speed results comparing this with y_ini.


Re: [REL]tfile 3.0 Best file system! - Terminator3 - 25.06.2012

Quote:
Originally Posted by rVar
Посмотреть сообщение
Awesome! Waiting for speed results comparing this with y_ini.
It's hard to tell, in y_ini you uses one function to set one value to file, it's easy to test the speed, you just make big loop and count the time for example 10000 runs of function, then just divide time by 10000

Here you have one function and you can write big number of arguments but more time will take loop for all arguments in function then others things, and you will never set/get so many arguments to/from file, so if you divide by numbers of arguments you get more time for checking arguments, searching then, than normally run time of function


Re: Re : [REL]tfile 3.0 Best file system! - TheArcher - 25.06.2012

Quote:
Originally Posted by Terminator3
View Post
Tests?
Quote:
Originally Posted by rVar
View Post
Waiting for speed results comparing this with y_ini.
4 char


Re: [REL]tfile 3.0 Best file system! - Prumpuz - 01.07.2012

When trying to use this plugin I always get this:
Code:
Run time error 19: "File or function is not found"
I even tried something simple and small in a bare gamemode:
pawn Code:
fCreate("test.txt", "Testing");
And it still gives me the error, I've tried both on Windows and Linux. I have tfile3 included, the plugin is in the plugins folder and "tfile" is in the plugins line in server.cfg

Am I missing something?


Re: [REL]tfile 3.0 Best file system! - KingHual - 01.07.2012

I'll do a few tests myself in an hour and post the results here.


Re: [REL]tfile 3.0 Best file system! - Terminator3 - 01.07.2012

Quote:
Originally Posted by Prumpuz
View Post
When trying to use this plugin I always get this:
Code:
Run time error 19: "File or function is not found"
I even tried something simple and small in a bare gamemode:
pawn Code:
fCreate("test.txt", "Testing");
And it still gives me the error, I've tried both on Windows and Linux. I have tfile3 included, the plugin is in the plugins folder and "tfile" is in the plugins line in server.cfg

Am I missing something?
Any error in server_log.txt with loading plugin ?


Re: [REL]tfile 3.0 Best file system! - Terminator3 - 01.07.2012

Quote:
Originally Posted by ******
Посмотреть сообщение
Will it read the data? Will it detect that every key exists? Will it overwrite correctly? I've not tested this so I don't know.
Yes, order does not matter.

Quote:
Originally Posted by ******
Посмотреть сообщение
Finally, the name is misleading - this isn't a FILE plugin, it's an INI plugin. Files can contain many different types of data in many different formats, this will only handle one of those types. Speaking of which, how does it handle INI sections and comments, something most of the INI parsers here don't deal with well?
Sorry, i always used the name 'file system' because in SA: MP rather, no one uses files for other things as storing data in this way. But i can always change the name of 'topic'

Quote:
Originally Posted by ******
Посмотреть сообщение
There are so many mistakes in that code it's not even funny - and the compiler will catch NONE of them. In other systems:
Similar like in sscanf


I was thinking about doing a function to open and close the file, but ultimately I made the argument file name because even if I make this function the fGet/SaveData will still read whole file line by line


Re: [REL]tfile 3.0 Best file system! - KingHual - 01.07.2012

Quote:
Originally Posted by ******
Посмотреть сообщение
Touchй!
Though, you were comparing the file system to other file systems, not to sscanf (since they obviously have nothing in common).


Re: [REL]tfile 3.0 Best file system! - Kaperstone - 02.07.2012

Looks intersting...
will test it out.
Can you provide test results ?


Re: [REL]tfile 3.0 Best file system! - Niko_boy - 02.07.2012

oh great , a ini system based on plugin , really rox


Re: [REL]tfile 3.0 Best file system! - Edvin - 03.07.2012

Nice release.

Good work.


Re: [REL]tfile 3.0 Best file system! - Terminator3 - 10.07.2012

Big update of optimality and improvement of several errors


Re: [REL]tfile 3.0 Best file system! - NeyMar96 - 16.07.2012

If the server shutdown it not save the data