29.11.2014, 03:58
(
Последний раз редактировалось Neufox; 15.12.2014 в 06:10.
)
INI - File Manager
IncludЙ by Neufox
#2 Release
Version: 3 | Last Update: 04/12/2014IncludЙ by Neufox
#2 Release
Hello friends! I made my mind releasing this old include of mine today, I know its late and nower days people recommend SQLITE or MYSQL. But still i want to release this. Its an edited version of SII. This is quiet simple and easy and CLEAN. So i hope you like it! I also want to aware you all that this don't support multiple file opening, yea it does close previous one and open up the new file in the case of dini conversion, but that can't be called multiple file opening. I have also performed some speed tests and the result is quiet good. You can checkout that down the thread.
Well I want to thank [DRuG]Slick for base SII code and SAMP Team. And Neufox(indirectly, me) for this include and creating it.
NOTE: Script distributed under no agreement or conditions. Free for all, People have no permission to remove credits, re-release script until permission is granted from the real owner(s).
* You can also download Basic Login & Register system, test: initest.pwn
Version 3 (04/12/2014)
- Fixed closing issue in "INI_Rename & INI_Copy".
- Fixed conversion system (mainly UDB)
Version 2 (30/11/2014)
- Removed "INI_WriteFloat" limit
- Fixed minor bug in "INI_Rename" & "INI_Copy"
- Fixed minor issue in "INI_WriteBool"
- Updated UDB system
Version 1 (29/11/2014)
The basic demonstration of the script.
- Fast, faster than dini, dudb, and some other file/ini managers.
- Easy, as [DRUG]Slick said, "Even your mother can use it!".
- Many new features, like "Renaming, Copying..." files.
- Multi write and read from a file.
- Accepts comments in the file. (Use ";" to start a comment)
- A dynamic convertor which helps you to convert other ini manager functions.
- DINI
- DUDB
- SFM(Southclaw's File Manager)
- FINI
- SII
- SF(Simple File)
- dFile
- Cache based file saving system.
- The script is crash free, so no worry.
- Inbuilt UDB system, allows you to create USER-DATABASE easily.
- New multiple writing and reading function, Write all your stuff in one GO!
- AUTO_SAVE feature, if set to "true", you don't need to use "INI_Save" before closing, just "INI_Close". Its integrated in INI_Close itself.
Stocks
Here are some stock functions or natives, these are also available in the script. Here, just to display the functions.
pawn Код:
//Creates an ini file(only if not existing).
//"bool:open" when true automatically opens the file after creating it.
native INI_Create(const filename[], bool:open = false);
//Removing an already existing file
native INI_Remove(const filename[]);
//Advance function in some cases. Actually opens the file specified so that we can start experiments.
//NOTE: If the file does not кxists, this auto creates and open it.
native INI_Open(const filename[]);
//Close the opened file.
//NOTE: If enabled "INI_AUTO_SAVE", this automatically writes the data from cache.
native INI_Close();
//Write cache data to file.
native INI_Save();
//Rename the opened file. The data remains the same and saved.
native INI_Rename(const newname[]);
//Duplicate the whole file with the data saved.
native INI_Copy(const copyname[]);
//Writing stuff to a file. Includes "strings, float, boolean, & integer".
native INI_WriteString(const key[], const value[]);
native INI_WriteInt(const key[], value);
native INI_WriteFloat(const key[], Float: value);
native INI_WriteBool(const key[], bool:value);
//Reading stuff froam a file.
native INI_ReadString(const key[]);
native INI_ReadInt(const key[]);
native Float:INI_ReadFloat(const key[]);
native bool:INI_ReadBool(const key[]);
//Advance feature, write stuff of all type in one go.
//TIP:
//'s' - string
//'b' - bool
//'f' - float
//'i' or 'd' - integer
//EXAMPLE: INI_MultiWrite("db", "kills", 0, "killed", true);
native INI_MultiWrite(format[], {Float,_}:...);
//Advance feature, read all stuff in one go.
//EXAMPLE:
/*
new kills, bool:killed;
INI_MultiRead("db", "kills", kills, "killed", killed);
*/
native INI_MultiRead(format[],{Float,_}:...);
//Remove an existing key froam a file.
native INI_RemoveKey(const key[]);
//Check if the key exists.
native INI_KeyExist(const key[]);
//Return "true" if any file is opened.
native INI_ReturnFile();
//Returns the file name which is opened(if any).
native INI_ReturnFilename();
Also given the code, so that users can make out their own tests.
Writing to a file!
- Writing String 50 times: 14ms
- Writing Integer 50 times: 6ms
- Writing Float 50 times: 10ms
- Writing Bool 50 times: 12ms
- Reading String 50 times: 20ms
- Reading Integer 50 times: 8ms
- Reading Float 50 times: 13ms
- Reading Bool 50 times: 15ms
pawn Код:
/*
n_ini.inc include by Neufox
n_ini (INI-File) test by Neufox, reading and writing speed tests!
*/
#include <a_samp>
#include <n_ini>
#define INI_TESTS 50//the number of times to write and read each category or type
#if(!INI_AUTO_SAVE)
#undef INI_AUTO_SAVE
#define INI_AUTO_SAVE true
#endif
public OnFilterScriptInit()
{
print("READING & WRITTING INI FILE SPEED Tests loaded with (n_ini.inc)");
print("Credits: Neufox, ENJOY!");
new tick, string[17];
tick=GetTickCount();
INI_Open("test.ini");//opening the file
//writing
for(new i;i<INI_TESTS;i++)
{
format(string, sizeof(string), "Test_String_%d", i);
INI_WriteString(string, "blah blah blah blah blah blah blah blah blah blah blah blah");
}
printf("Takes %d ms to Write Strings "#INI_TESTS" times\n", GetTickCount()-tick);
tick=GetTickCount();
for(new i;i<INI_TESTS;i++)
{
format(string, sizeof(string), "Test_int_%d", i);
INI_WriteInt(string, 1234567890);
}
printf("Takes %d ms to Write Integers "#INI_TESTS" times\n", GetTickCount()-tick);
tick=GetTickCount();
for(new i;i<INI_TESTS;i++)
{
format(string, sizeof(string), "Test_float_%d", i);
INI_WriteFloat(string, 1234567890.0000);
}
printf("Takes %d ms to Write Floats "#INI_TESTS" times\n", GetTickCount()-tick);
tick=GetTickCount();
for(new i;i<INI_TESTS;i++)
{
format(string, sizeof(string), "Test_bool_%d", i);
INI_WriteBool(string, true);
}
printf("Takes %d ms to Write Bools "#INI_TESTS" times\n", GetTickCount()-tick);
//reading
for(new i;i<INI_TESTS;i++)
{
format(string, sizeof(string), "Test_String_%d", i);
INI_ReadString(string);
}
printf("Takes %d ms to Read Strings "#INI_TESTS" times\n", GetTickCount()-tick);
tick=GetTickCount();
for(new i;i<INI_TESTS;i++)
{
format(string, sizeof(string), "Test_int_%d", i);
INI_ReadInt(string);
}
printf("Takes %d ms to Read Integers "#INI_TESTS" times\n", GetTickCount()-tick);
tick=GetTickCount();
for(new i;i<INI_TESTS;i++)
{
format(string, sizeof(string), "Test_float_%d", i);
INI_ReadFloat(string);
}
printf("Takes %d ms to Read Floats "#INI_TESTS" times\n", GetTickCount()-tick);
tick=GetTickCount();
for(new i;i<INI_TESTS;i++)
{
format(string, sizeof(string), "Test_bool_%d", i);
INI_ReadBool(string);
}
printf("Takes %d ms to Read Bools "#INI_TESTS" times\n", GetTickCount()-tick);
INI_Close();//closeing the file
return 1;
}
public OnFilterScriptExit()
{
return 1;
}