bCini6_Open - fopen
bCini6_Exists - fexist
bCini6_Write - fwrite
bCini6_Read - fread
bCini6_Close - fclose
bCini6_Delete - fremove
main()
{
   bCini8_SetText("Biel_COP.ini","Olб","Como vocк vai ?");
}
main()
{
   bCini8_SetInt("Biel_COP.ini","Olб",1000);
}
main()
{
   bCini8_SetFloat("Biel_COP.ini","Olб",50.0);
}
main()
{
   printf("%s",bCini8_ReadText("Biel_COP.ini","Olб"));
}
main()
{
   printf("%d",bCini8_ReadInt("Biel_COP.ini","Olб"));
}
main()
{
   printf("%f",bCini8_ReadFloat("Biel_COP.ini","Olб"));
}
main()
{
   printf("%s",bCini8_ReadLineName("Biel_COP.ini",0));
}
main()
{
   bCini8_DeleteSet("Biel_COP.ini","Olб");
}
main()
{
   bCini8_Copy("Biel_COP.ini","Biel.ini",1); // Deletar o arquivo 1 apуs copiб-lo para o arquivo 2
}
main()
{
   bCini8_ChangeLine("Biel_COP.ini","Olб","Olб 2");
}
main()
{
   if(bCini8_IsSet("Biel_COP.ini","Olб"))
   {
     print("A linha 'Olб' do arquivo 'Biel_COP.ini' existe!");
   }
   return 1;
}
#define bCini8.inc
// Include bCini8
#define bCini8_Open fopen
#define bCini8_Exists fexist
#define bCini8_Write fwrite
#define bCini8_Read fread
#define bCini8_Close fclose
#define bCini8_Create(%0) if(!bCini8_Exists(%0)) bCini8_Close(bCini8_Open(%0,io_write)) && bCini8_OpenArchive(%0)
#define bCini8_Delete(%0) if(bCini8_Exists(%0)) fremove(%0)
// Include definitions
#define bCini8_Lines 100
#define bCini8_Capacity 256
#define bCini8_Separator "="
#define bCini8_Null_Text "null"
// Variables
stock bCini8_Archive_Line[bCini8_Lines][bCini8_Capacity/4],bCini8_Archive_Value[bCini8_Lines][bCini8_Capacity],bCini8_Archive_Name[64] = bCini8_Null_Text,bCini8_Archive_Lines = 1,bool:bCini8_Archive_Has_Been_Used,Include_bCini8[bCini8_Capacity];
// Functions
#define bCini8_SetInt(%0,%1,%2) format(Include_bCini8,bCini8_Capacity,"%d",%2) && bCini8_SetText(%0,%1,Include_bCini8)
#define bCini8_SetFloat(%0,%1,%2) format(Include_bCini8,bCini8_Capacity,"%.2f",%2) && bCini8_SetText(%0,%1,Include_bCini8)
#define bCini8_ReadText(%0,%1) bCini8_Archive_Value[bCini8_IsSet(%0,%1)]
#define bCini8_ReadInt(%0,%1) strval(bCini8_Archive_Value[bCini8_IsSet(%0,%1)])
#define bCini8_ReadFloat(%0,%1) floatstr(bCini8_Archive_Value[bCini8_IsSet(%0,%1)])
#define bCini8_CleanArchive(%0) if(bCini8_Exists(%0)) bCini8_OpenArchive(%0); for(new i = 1; i < bCini8_Archive_Lines; ++i) bCini8_DeleteSet(%0,bCini8_Archive_Line[i])
#define bCini8_Log(%0,%1) new File:bCini8_Archive = bCini8_Open(%0,io_append); bCini8_Write(bCini8_Archive,%1) && bCini8_Close(bCini8_Archive)
stock bCini8_SetText(archive[],line[],value[])
{
  if(bCini8_Archive_Lines < bCini8_Lines)
  {
    bCini8_Create(archive);
    if(!bCini8_IsSet(archive,line))
    {
      // Line
      strunpack(bCini8_Archive_Line[bCini8_Archive_Lines],line);
      if(!strlen(bCini8_Archive_Line[bCini8_Archive_Lines]))
      {
        strunpack(bCini8_Archive_Line[bCini8_Archive_Lines],bCini8_Null_Text);
      }
      // Value
      strunpack(bCini8_Archive_Value[bCini8_Archive_Lines],value);
      if(!strlen(bCini8_Archive_Value[bCini8_Archive_Lines]))
      {
        strunpack(bCini8_Archive_Value[bCini8_Archive_Lines],bCini8_Null_Text);
      }
      ++bCini8_Archive_Lines;
    }
    else
    {
      new bCini8_Line_ID = bCini8_IsSet(archive,line);
      strunpack(bCini8_Archive_Value[bCini8_Line_ID],value);
      if(!strlen(bCini8_Archive_Value[bCini8_Line_ID]))
      {
        strunpack(bCini8_Archive_Value[bCini8_Line_ID],bCini8_Null_Text);
      }
    }
    bCini8_Archive_Has_Been_Used = true;
  }
  return 1;
}
stock bCini8_ReadLineName(archive[],line)
{
  bCini8_OpenArchive(archive);
  return bCini8_Archive_Line[line];
}
stock bCini8_DeleteSet(archive[],line[])
{
  new bCini8_Line_ID = bCini8_IsSet(archive,line);
  if(bCini8_Line_ID)
  {
    bCini8_Archive_Line[bCini8_Line_ID][0] = 0;
    bCini8_Archive_Value[bCini8_Line_ID][0] = 0;
    bCini8_Archive_Has_Been_Used = true;
  }
  return 1;
}
stock bCini8_Copy(archive[],archive2[],bool:delete_archive)
{
  if(bCini8_Exists(archive))
  {
    if(!bCini8_Exists(archive2))
    {
      bCini8_OpenArchive(archive);
      new File:bCini8_Archive_Used = bCini8_Open(archive2,io_write),bCini8_Format[bCini8_Capacity];
      for(new i = 1; i < bCini8_Archive_Lines; ++i)
      {
        if(bCini8_Archive_Line[i][0])
        {
          format(bCini8_Format,bCini8_Capacity,"%s=%s\r\n",bCini8_Archive_Line[i],bCini8_Archive_Value[i]);
          bCini8_Write(bCini8_Archive_Used,bCini8_Format);
        }
      }
      bCini8_Close(bCini8_Archive_Used);
      if(delete_archive)
      {
        bCini8_Delete(archive);
      }
    }
  }
  return 1;
}
stock bCini8_ChangeLine(archive[],line[],new_line[])
{
  if(bCini8_Exists(archive))
  {
    new bCini8_Line_ID = bCini8_IsSet(archive,line);
    if(bCini8_Line_ID)
    {
      strunpack(bCini8_Archive_Line[bCini8_Line_ID],new_line);
      bCini8_Archive_Has_Been_Used = true;
    }
  }
  return 1;
}
// Open & Close
stock bCini8_OpenArchive(archive[])
{
  if(strcmp(bCini8_Archive_Name,archive,false))
  {
    bCini8_CloseArchive();
    strunpack(bCini8_Archive_Name,archive);
    if(bCini8_Exists(archive))
    {
      new bCini8_i[2],bCini8_Archive[bCini8_Capacity],File:bCini8_Archive_Used = bCini8_Open(archive,io_read);
      while(bCini8_Read(bCini8_Archive_Used,bCini8_Archive))
      {
        if(bCini8_Archive[0])
        {
          if(bCini8_Archive_Lines < bCini8_Lines)
          {
            if(bCini8_Archive[0] >= 256)
            {
              strdel(bCini8_Archive,0,1);
            }
            bCini8_i[0] = strlen(bCini8_Archive);
            if(bCini8_Archive[bCini8_i[0]-1] == '\r' || bCini8_Archive[bCini8_i[0]-1] == '\n')
            {
              bCini8_Archive[bCini8_i[0]-1] = 0;
            }
            if(bCini8_Archive[bCini8_i[0]-2] == '\r' || bCini8_Archive[bCini8_i[0]-2] == '\n')
            {
              bCini8_Archive[bCini8_i[0]-2] = 0;
            }
            bCini8_i[1] = strfind(bCini8_Archive,bCini8_Separator);
            strmid(bCini8_Archive_Line[bCini8_Archive_Lines],bCini8_Archive,0,bCini8_i[1],bCini8_i[1]+1);
            strmid(bCini8_Archive_Value[bCini8_Archive_Lines],bCini8_Archive,bCini8_i[1]+1,bCini8_i[0]);
            ++bCini8_Archive_Lines;
          }
        }
      }
      bCini8_Close(bCini8_Archive_Used);
    }
  }
  return 1;
}
stock bCini8_CloseArchive()
{
  if(bCini8_Exists(bCini8_Archive_Name))
  {
    if(bCini8_Archive_Has_Been_Used)
    {
      new File:bCini8_Archive_Used = bCini8_Open(bCini8_Archive_Name,io_write),bCini8_Format[bCini8_Capacity];
      for(new i = 1; i < bCini8_Archive_Lines; ++i)
      {
        if(bCini8_Archive_Line[i][0])
        {
          format(bCini8_Format,bCini8_Capacity,"%s=%s\r\n",bCini8_Archive_Line[i],bCini8_Archive_Value[i]);
          bCini8_Write(bCini8_Archive_Used,bCini8_Format);
        }
      }
      bCini8_Close(bCini8_Archive_Used);
    }
  }
  for(new i = 1; i < bCini8_Archive_Lines; ++i)
  {
    if(bCini8_Archive_Line[i][0])
    {
      bCini8_Archive_Line[i][0] = 0;
      bCini8_Archive_Value[i][0] = 0;
    }
  }
  bCini8_Archive_Name = bCini8_Null_Text;
  bCini8_Archive_Lines = 1;
  bCini8_Archive_Has_Been_Used = false;
  return 1;
}
stock bCini8_IsSet(archive[],line[])
{
  bCini8_OpenArchive(archive);
  for(new i = 1; i < bCini8_Archive_Lines; ++i)
  {
    if(bCini8_Archive_Line[i][0])
    {
      if(strcmp(bCini8_Archive_Line[i],line,true) == 0)
      {
        return i;
      }
    }
  }
  return 0;
}
// End of the include
Boa include, conseguiu superar o tгo famoso dof2, parabйns amigo. +rep
|
#include <a_samp>
// Set the stack/heap size to 1mb
#pragma dynamic 262144
#define MAX_ENTRIES (300)
#define bCini8_Lines (300)
// Elimine a linha bCini8_Lines dentro do include ja que, nгo aceita configuraзхes externas.
#include <bcini8>
#include <dof2>
main()
{
    new
        tempo,
        value[25],
        key[10],
        file[16],
        t[13] = "[value 1192]"
    ;
    new NUMERO = 4;
    for(new p = 0; p <= 10; p ++)
    {
        tempo = GetTickCount();
        format(file, 16, "DOF2_%d.txt", p);
        if(!DOF2_FileExists(file))
            DOF2_CreateFile(file);
        for(new i; i < 300; i++)
        {
            format(value, 25, "[value %d]", i * NUMERO);
            format(key, 10, "[%d]", i);
            DOF2_SetString(file, key, value);
        }
        DOF2_SaveFile();
        if(strcmp(DOF2_GetString(file, "298"), t))
            print("bcini8 assertion failed");
        printf("Teste DOF2 %dms",GetTickCount() - tempo);
        tempo = GetTickCount();
        format(file, 16, "BCINI_%d.txt", p);
        if(!bCini8_Exists(file))
            bCini8_Create(file);
        for(new i; i < 300; i++)
        {
            format(value, 25, "[value %d]", i * NUMERO);
            format(key, 10, "[%d]", i);
            bCini8_SetText(file, key, value);
        }
        bCini8_CloseArchive();
        if(strcmp(bCini8_ReadText(file, "298"), t))
            print("bcini8 assertion failed");
        printf("Teste BCINI %dms\n", GetTickCount() - tempo);
        if(p == 5)
        {
            NUMERO = 3;
            t = "[value 894]";
        }
    }
}Â
Com arquivos inexistentes Escrita Teste DOF2 32ms Teste BCINI 341ms Teste DOF2 26ms Teste BCINI 351ms Teste DOF2 26ms Teste BCINI 325ms Teste DOF2 26ms Teste BCINI 311ms Teste DOF2 59ms Teste BCINI 328ms Teste DOF2 28ms Teste BCINI 295ms Teste DOF2 27ms Teste BCINI 303ms Teste DOF2 24ms Teste BCINI 298ms Teste DOF2 26ms Teste BCINI 286ms Teste DOF2 24ms Teste BCINI 281ms Teste DOF2 28ms Teste BCINI 285ms Leitura Teste DOF2 15ms Teste BCINI 145ms Teste DOF2 10ms Teste BCINI 162ms Teste DOF2 13ms Teste BCINI 158ms Teste DOF2 11ms Teste BCINI 135ms Teste DOF2 11ms Teste BCINI 134ms Teste DOF2 16ms Teste BCINI 133ms Teste DOF2 12ms Teste BCINI 159ms Teste DOF2 12ms Teste BCINI 151ms Teste DOF2 12ms Teste BCINI 157ms Teste DOF2 13ms Teste BCINI 126ms Teste DOF2 10ms Teste BCINI 116ms Com arquivos existentes, e valores jб colocados Escrita Teste DOF2 15ms Teste BCINI 29ms Teste DOF2 19ms Teste BCINI 11ms Teste DOF2 19ms Teste BCINI 11ms Teste DOF2 21ms Teste BCINI 10ms Teste DOF2 22ms Teste BCINI 9ms Teste DOF2 21ms Teste BCINI 10ms Teste DOF2 21ms Teste BCINI 9ms Teste DOF2 25ms Teste BCINI 8ms Teste DOF2 19ms Teste BCINI 7ms Teste DOF2 20ms Teste BCINI 8ms Teste DOF2 21ms Teste BCINI 8ms Leitura Teste DOF2 14ms Teste BCINI 139ms Teste DOF2 9ms Teste BCINI 136ms Teste DOF2 14ms Teste BCINI 173ms Teste DOF2 11ms Teste BCINI 142ms Teste DOF2 12ms Teste BCINI 121ms Teste DOF2 10ms Teste BCINI 125ms Teste DOF2 9ms Teste BCINI 120ms Teste DOF2 9ms Teste BCINI 116ms Teste DOF2 10ms Teste BCINI 123ms Teste DOF2 9ms Teste BCINI 110ms Teste DOF2 10ms Teste BCINI 120ms
Teste:
PHP Code:
Code:
Com arquivos inexistentes Escrita Teste DOF2 32ms Teste BCINI 341ms Teste DOF2 26ms Teste BCINI 351ms Teste DOF2 26ms Teste BCINI 325ms Teste DOF2 26ms Teste BCINI 311ms Teste DOF2 59ms Teste BCINI 328ms Teste DOF2 28ms Teste BCINI 295ms Teste DOF2 27ms Teste BCINI 303ms Teste DOF2 24ms Teste BCINI 298ms Teste DOF2 26ms Teste BCINI 286ms Teste DOF2 24ms Teste BCINI 281ms Teste DOF2 28ms Teste BCINI 285ms Leitura Teste DOF2 15ms Teste BCINI 145ms Teste DOF2 10ms Teste BCINI 162ms Teste DOF2 13ms Teste BCINI 158ms Teste DOF2 11ms Teste BCINI 135ms Teste DOF2 11ms Teste BCINI 134ms Teste DOF2 16ms Teste BCINI 133ms Teste DOF2 12ms Teste BCINI 159ms Teste DOF2 12ms Teste BCINI 151ms Teste DOF2 12ms Teste BCINI 157ms Teste DOF2 13ms Teste BCINI 126ms Teste DOF2 10ms Teste BCINI 116ms Com arquivos existentes, e valores jб colocados Escrita Teste DOF2 15ms Teste BCINI 29ms Teste DOF2 19ms Teste BCINI 11ms Teste DOF2 19ms Teste BCINI 11ms Teste DOF2 21ms Teste BCINI 10ms Teste DOF2 22ms Teste BCINI 9ms Teste DOF2 21ms Teste BCINI 10ms Teste DOF2 21ms Teste BCINI 9ms Teste DOF2 25ms Teste BCINI 8ms Teste DOF2 19ms Teste BCINI 7ms Teste DOF2 20ms Teste BCINI 8ms Teste DOF2 21ms Teste BCINI 8ms Leitura Teste DOF2 14ms Teste BCINI 139ms Teste DOF2 9ms Teste BCINI 136ms Teste DOF2 14ms Teste BCINI 173ms Teste DOF2 11ms Teste BCINI 142ms Teste DOF2 12ms Teste BCINI 121ms Teste DOF2 10ms Teste BCINI 125ms Teste DOF2 9ms Teste BCINI 120ms Teste DOF2 9ms Teste BCINI 116ms Teste DOF2 10ms Teste BCINI 123ms Teste DOF2 9ms Teste BCINI 110ms Teste DOF2 10ms Teste BCINI 120ms |