[Include] dFile
#1

dFile
The fastest file and directory management.
What is this?

This is a new file management system, which not only the files but the directories can handle!
Anywhere able to save a file.

Warning: The system will save the file next to the server startup!

Why is this?

The system is very simple and straightforward, similar to features in the file manager but it does not contain any other unnecessary things!
There is still a big advantage: It is the fastest file management system! Why? Cause It's based on plugin.

Who made it?

The plugin created JaTochNietDan.

/*
* Dfile 1.0.4
* All rights reserved! © By: Drake
*
* Owner: Drake
* Time: 01/27/2011
*
* This function may be freely distributed.
* And of course, free to use: D
* Thanks to:
* ChuckNorris - Testing, Help
* Fade - Testing, Help
* ****** - boolstr function
* JaTochNietDan - FileManager
*
* Special thanks to:
* Thiadmer - Pawn.
* SA: MP Team Past, Present, Future - SA: MP.
*/


Compare with y_ini:


Features:

dfile_Create - Create a file. Keys:
Код:
 (file [])
File [] parameter is the string name of the file.

dfile_Delete - Delete file.
Код:
 (file [])
File [] to delete the file name.

dfile_Open - Open File.
Код:
 (file [])
File [] file name / location.

dfile_CreateDirectory - Create a directory.
Код:
 (folder [])
Folder [] the name of the directory location.

dfile_DeleteDirectory - Remove a directory.
Код:
 (folder [])
Folder [] the name of the directory location.

dfile_DirectoryExists - Verify that the folder exists
Код:
 Folder []
Folder [] control of the folder.

dfile_WriteString - Write a string to a file.
Код:
 (parameter [], value [])
parameter [] key, which write
val [] something.
Example:
Код:
 key = value
dfile_WriteInt - Write an integer to a file.
Код:
 (parameter [], value [])
parameter [] key, which write
val [] something.
Example:
Код:
 key = value
dfile_WriteBool - Boolean (true = false) Writing a bool value into the file.
Код:
 (parameter [], bool: value)
parameter [] key, which write
bool: You know what. (False / true)
Example:
Код:
 key = true
dfile_WriteFloat - Write a floating point number to a file.
Код:
 (parameter [], value [])
parameter [] key, which write
val [] something.
Example:
Код:
 key = value
dfile_ReadString - Read a string from a file.
Код:
 (parameter[])
parameter [] what the key value.

dfile_ReadInt - Integer read from a file.
Код:
 (parameter [])
parameter [] what the key value.

dfile_ReadFloat - Read a floating point number from a file.
Код:
 (parameter [])
parameter [] what the key value.

dfile_ReadBool - Read a bool value from a file.
Код:
 (parameter [])
parameter [] what the key value.

dfile_MoveFile - Move a file folder. It is important for the extension and that the destination folder exists!
Код:
 (file [], cel [])
File [] file in which to move,
End [] to.

dfile_RenameFile - Rename a file name. The extension is important!
Код:
 (oldname [], newname[])
oldname [] The file you want to rename,
newname [] The file new name.

dfile_SaveFile - Values to save the file.
Код:
 file []
File [] data file, which mentődjenek.

dfile_FileExists - Verify that the file exists
Код:
 file []
File [] control of the file.

dfile_ParseString - Compares the parameters and the input string.
Код:
 (file [] parameter [], value [])
File [] file in which the data is
parameter [] is the key name
val [] value, which compares the key value.

dfile_ParseInt - Compares the input parameter and an integer value.
Код:
 (file [] parameter [], value [])
File [] file in which the data is
parameter [] is the key name
val [] value, which compares the key value.

dfile_ParseFloat - Compares the argument and entered a float value.
Код:
 (file [] parameter [], value [])
File [] file in which the data is
parameter [] is the key name
val [] value, which compares the key value.

dfile_ParseBool - Compares the input parameter and the Boolean value.
Код:
 (file [] parameter [], value [])
File [] file in which the data is
parameter [] is the key name
val [] value, which compares the key value.

dfile_IsSet - Check if the key have value.
Код:
 (parameter[])
parameter [] is the key name

dfile_UnSet - Delete the key value.
Код:
 (parameter [])
parameter [] is the key name

dfile_MultiSet - Tцbb йrtйk нrбsa fбjlba.
Код:
(tipusok[], {Float,_}:...)
tipusok[] - parameter types.
Possible types:
  • "s" - string
  • "d" - integer
  • "b" - boolean
  • "f" - float
dfile_MultiGet - Tцbb йlrtйk lekйrdezйse egy fбjlbуl.
Код:
(tipusok[], {Float,_}:...)
tipusok[] - parameter types.
Possible types:
  • "s" - string
  • "d" - integer
  • "b" - boolean
  • "f" - float
Test script:
Код:
#include <a_samp>
#include <dfile>
#include <YSI\y_ini>

#define FILTERSCRIPT

new gInt, formalas[128];

#define fDFILE "DFILE_Test.txt"
#define fYINI "YINI_Test.txt"

#define WRITES 1000
#define READS 100000

public OnFilterScriptInit()
{
    print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
    print("---------------------");
    print("Writing Tests Started");
    new
        initialTick,
        DFILE_tick,
        YINI_tick;

    print("-Testing dFile");
    //dFile Write
    {
        dfile_Create(fDFILE);
        dfile_Open(fDFILE);
        initialTick=GetTickCount();
        for(new i;i<WRITES;i++)format(formalas, sizeof(formalas), "%d", i), dfile_WriteInt(formalas, i);
        dfile_SaveFile();
        dfile_CloseFile();
        DFILE_tick=GetTickCount()-initialTick;
    }

    print("-Testing Yini\n");
    //Yini Write
    {
        new
            INI:file = INI_Open(fYINI);
        initialTick=GetTickCount();
        for(new i;i<WRITES;i++)format(formalas, sizeof(formalas), "%d", i), INI_WriteInt(file, formalas, i);
        INI_Close(file);
        YINI_tick=GetTickCount()-initialTick;
    }
    printf("\n-nTest Results %d Writes\n", WRITES);
    printf(" - dFile:\t%d", DFILE_tick);
    printf(" - Yini:\t%d", YINI_tick);
	print("---------------------\n\n");
	print("---------------------");
    print("Reading Tests Started");
    print("-Testing dFile");
    {
        dfile_Create(fDFILE);
        dfile_Open(fDFILE);
        initialTick=GetTickCount();
        for(new i;i<READS;i++)dfile_ReadInt("0");
        DFILE_tick=GetTickCount()-initialTick;
    }

    print("-Testing Yini\n");
    {
        new
            INI:file = INI_Open(fYINI);
        initialTick=GetTickCount();
        for(new i;i<READS;i++)
        {
            INI_Load(fYINI);
        }
        INI_Close(file);
        YINI_tick=GetTickCount()-initialTick;
    }
    printf("\n- Test Results %d Reads\n", READS);
    printf(" - dFile:\t%d", DFILE_tick);
    printf(" - Yini:\t%d\n\n", YINI_tick);
    print("---------------------");
}

INI:filename[](name[], value[])
{
    INI_Int("TEST_TAG", gInt);
    return 0;
}
Usage:
Код:
#include <a_samp>
#include <dfile>

main()
{
	new variable1[3][128], variable2[2], float:variable3, bool:variable4;
	dfile_Create("test.ini");
	dfile_Open("test.ini");
	dfile_WriteString("parameter0", "test1234234");
	dfile_WriteInt("parameter1", 999999999);
	dfile_WriteFloat("parameter2", 0.97398457987);
	dfile_WriteBool("parameter3", true);
	dfile_MultiSet("ssddfbs",
		"test", "something",
		"test2", "testhere",
		"test3", 30,
		"test4", 50,
		"test5", 36.23425,
		"test6", true,
		"test7", "anothersomething"
	);
	dfile_MultiGet("ssddfbs",
		"test", variable1[0],
		"test2", variable1[1],
		"test3", variable2[0],
		"test4", variable2[1],
		"test5", variable3,
		"test6", variable4,
		"test7", variable1[2]
	);
	dfile_SaveFile();
	printf("%s|%s|%d|%d|%f|%b|%s", variable1[0], variable1[1], variable2[0], variable2[1], variable3, variable4, variable1[2]);
	dfile_Open("test.ini");
	printf("%s", dfile_ReadString("parameter0"));
	printf("%d", dfile_ReadInt("parameter1"));
	printf("%f", dfile_ReadFloat("parameter2"));
	printf("%d s", dfile_ReadBool("parameter3"));
	printf("%d", dfile_ParseString("parameter0", "test1234234"));
	printf("%d", dfile_ParseInt("parameter1", 345));
	printf("%d", dfile_ParseFloat("parameter2", 0.973984));
	printf("%d", dfile_ParseBool("parameter3", true));
	printf("%d a", dfile_IsSet("parameter3"));
	dfile_CloseFile();
}
Download:
v1.0.5: Download
v1.0.9: Download
v1.1.0: Download
v1.1.1: Download

Updates:
Updated function:
  • dfile_WriteString - The function don't rewrite the key value if that exist
New functions have been added:
  • dfile_FileExists
  • dfile_DirectoryExists
  • dfile_RenameFile
  • dfile_IsSet
  • dfile_UnSet
Some functions are changed!
  • dfile_Open - Now read the file contents
  • dfile_ReadString - Now only the key needed
Description by ChuckNorris.
Reply


Messages In This Thread
dFile - by Drake1994 - 29.01.2011, 11:43
Re: dFile - by SlashPT - 29.01.2011, 11:51
Re: dFile - by Fool - 29.01.2011, 12:03
Re: dFile - by Zh3r0 - 29.01.2011, 12:15
Re: dFile - by Drake1994 - 29.01.2011, 12:18
Re: dFile - by Zh3r0 - 29.01.2011, 12:20
Re: dFile - by iMonk3y - 29.01.2011, 12:22
Re: dFile - by SlashPT - 29.01.2011, 12:26
Re: dFile - by [03]Garsino - 29.01.2011, 13:12
Respuesta: dFile - by ipsBruno - 29.01.2011, 13:14
Re: dFile - by iMonk3y - 29.01.2011, 13:27
Re: dFile - by Drake1994 - 29.01.2011, 13:31
Respuesta: dFile - by ipsBruno - 29.01.2011, 13:35
Re: dFile - by [03]Garsino - 29.01.2011, 13:36
Respuesta: dFile - by ipsBruno - 29.01.2011, 13:50
Re: dFile - by Drake1994 - 29.01.2011, 14:03
Respuesta: dFile - by luis_lpv_22 - 29.01.2011, 14:09
Respuesta: dFile - by ipsBruno - 29.01.2011, 14:15
Re: dFile - by [03]Garsino - 29.01.2011, 14:27
Re: dFile - by Drake1994 - 29.01.2011, 14:35
Respuesta: dFile - by ipsBruno - 29.01.2011, 14:41
Re: dFile - by [03]Garsino - 29.01.2011, 14:44
Re: dFile - by Drake1994 - 29.01.2011, 14:45
Re: dFile - by [03]Garsino - 29.01.2011, 14:50
Respuesta: dFile - by ipsBruno - 29.01.2011, 14:50
Re: dFile - by Lorenc_ - 29.01.2011, 14:53
Re: dFile - by Drake1994 - 29.01.2011, 14:59
Re: dFile - by Hal - 29.01.2011, 15:12
Re: dFile - by Drake1994 - 29.01.2011, 15:15
Respuesta: dFile - by ipsBruno - 29.01.2011, 15:57

Forum Jump:


Users browsing this thread: 6 Guest(s)