当前位置: 首页>>代码示例>>C++>>正文


C++ TFile::Read方法代码示例

本文整理汇总了C++中TFile::Read方法的典型用法代码示例。如果您正苦于以下问题:C++ TFile::Read方法的具体用法?C++ TFile::Read怎么用?C++ TFile::Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TFile的用法示例。


在下文中一共展示了TFile::Read方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LoadDomainsNacionales

//-----------------------------------------------------------------------------
void TAdministradora :: LoadDomainsNacionales(AnsiString pDomainNacional)
{
  TFile* TreeFile = new TFile(pDomainNacional);
  TreeFile->Open("rb+");
  TreeFile->SeekTo(0);

  if(TreeFile->IsOpen())
  {
    TSDomainInfo SDominio;
    TreeFile->Read(&SDominio,sizeof(TSServerInfo));

    while(!TreeFile->Eof())
    {
      TPreOrderNode* node = new  TPreOrderNode();
      TDomain* domain = new TDomain();
      node->End(SDominio.End);
      node->RightLink(SDominio.LinkedRight);
      domain->NameDomain(SDominio.Name);
      node->Info(domain);
      aDomainsPreOrderList->Insert(node);
      TreeFile->Read(&SDominio,sizeof(TSDomainInfo));
    }
  }
  TreeFile->Close();
  delete TreeFile;
}
开发者ID:sharstream,项目名称:MailServer-C,代码行数:27,代码来源:Administradora.cpp

示例2: PrechargeImpl

// maybe we should move this function to another .cpp file to avoid unwanted optimization?
static int PrechargeImpl(TFile f, void* data, size_t dataSize, size_t off, size_t size) {
    if (off > dataSize) {
        assert(false);
        return 0;
    }
    size_t endOff = (size == (size_t)-1 ? dataSize : off + size);
    if (endOff > dataSize) {
        assert(false);
        endOff = dataSize;
    }
    size = endOff - off;
    if (dataSize == 0 || size == 0)
        return 0;

    const char *c = (char*)data + off, *e = c + size;
    int n = 0;
#ifdef _freebsd_
    if (off % PAGE_SIZE) {
        off = off / PAGE_SIZE * PAGE_SIZE; // align on PAGE_SIZE
        size = endOff - off;
        c = (char*)data + off;
    }

    madvise((void*)c, e - c, MADV_WILLNEED);
    f.Seek(0, sSet);
    const size_t rdSize1 = 64 << 20, rdSize2 = 4 << 20;
    const size_t rdSize = size > rdSize2 * 32? rdSize1 : rdSize2;
    TArrayHolder<char> pages(new char[(rdSize1 + PAGE_SIZE - 1) / PAGE_SIZE]);
    TBuffer buf(Min(rdSize, size));
    ui32 nbufs = 0, nread = 0;
    for (size_t r = 0; r < size; r += rdSize) {
        bool needRead = true;
        size_t toRead = Min(rdSize, size - r);
        if (mincore(c + r, toRead, pages.Get()) != -1)
            needRead = memchr(pages.Get(), 0, (toRead + PAGE_SIZE - 1) / PAGE_SIZE) != 0;
        if (needRead)
            f.Read(buf.Data(), toRead);
        madvise((void*)(c + r), toRead, MADV_WILLNEED);
        for (const char *d = c; d < c + r; d += 512)
            n += *d;
        nbufs++;
        nread += needRead;
    }
    //warnx("precharge: read %u/%u (blk %"PRISZT")", nread, nbufs, rdSize);
    return 0;
#else
    UNUSED(f);
#endif
    for (; c < e; c += 512)
        n += *c;
    return n; // prevent loop optimization
}
开发者ID:Mirocow,项目名称:balancer,代码行数:53,代码来源:filemap.cpp

示例3: LoadServersInternacional

//-----------------------------------------------------------------------------
void TAdministradora::LoadServersInternacional(AnsiString pNameFile)
{
  TFile* internacional = new TFile(pNameFile);
  internacional->Open("rb+");
  internacional->SeekTo(0);

  if(internacional->IsOpen())
  {
    TSServerInfo server;
    internacional->Read(&server,sizeof(TSServerInfo));

    while(!internacional->Eof())
    {
      TServidor* Servidor = new TServidor();
      Servidor->Tope(server.Tope);
      Servidor->Max(server.MaxMail);
      Servidor->NameDomain(server.Name);
      aInternacionales->Insert(Servidor);
      internacional->Read(&server,sizeof(TSServerInfo));
    }
  }
  internacional->Close();
  delete internacional;
}
开发者ID:sharstream,项目名称:MailServer-C,代码行数:25,代码来源:Administradora.cpp

示例4: LoadServersNacionales

//-----------------------------------------------------------------------------
void TAdministradora :: LoadServersNacionales(AnsiString pServerName)
{
  TFile* serverFile = new TFile(pServerName);
  serverFile->Open("rb+");
  serverFile->SeekTo(0);

  if(serverFile->IsOpen())
  {
    TSServerInfo server;
    serverFile->Read(&server,sizeof(TSServerInfo));

    while(!serverFile->Eof())
    {
      TServidor* Servidor = new TServidor();
      Servidor->Tope(server.Tope);
      Servidor->Max(server.MaxMail);
      Servidor->NameDomain(server.Name);
      aNacionalesServers->Insert(Servidor);
      serverFile->Read(&server,sizeof(TSServerInfo));
    }
  }
  serverFile->Close();
  delete serverFile;
}
开发者ID:sharstream,项目名称:MailServer-C,代码行数:25,代码来源:Administradora.cpp

示例5: LoadAdministradorCuenta

//-----------------------------------------------------------------------------
void TAdministradora :: LoadAdministradorCuenta(AnsiString pNameFile)
{
  TFile* administr = new TFile(pNameFile);
  administr->Open("rb");
  if(administr->IsOpen())
  {
    TSAdmin admin;
    administr->Read(&admin,sizeof(TSAdmin));
    strcpy(aUsuario.c_str(),admin.user);
    AnsiString User = aUsuario.c_str();
    Usuario(User);
    strcpy(aPassWord.c_str(),admin.pass);
    AnsiString Pass = aPassWord.c_str();
    PassWord(Pass);
  }
  administr->Close();
  delete administr;
}
开发者ID:sharstream,项目名称:MailServer-C,代码行数:19,代码来源:Administradora.cpp

示例6: LoadAccounts

//-----------------------------------------------------------------------------
void TAdministradora :: LoadAccounts(AnsiString pFileName)//ver lo del buffer cuando voy a escribir un parrafo
{                                                          //eso hay que arreglarlo
  TFile* AccountFile = new TFile(pFileName);
  AccountFile->Open("rb+");
  AccountFile->SeekTo(0);

  if(AccountFile->IsOpen())
  {
    TGLinkedList* Servers = new TGLinkedList();
    AllServers(Servers);
    if(Servers)
    {
      while(AccountFile->FilePos() < AccountFile->FileSize())
      {
        TSAccount account;
        AccountFile->Read(&account,sizeof(TSAccount)); //primera lectura
        AnsiString ServidorNombre = account.server;
        TServidor* Server = (TServidor*)Servers->FirstThat(Daemon::FindNameList,&ServidorNombre);
        if(Server)
        {
          TCuenta* cuenta = new TCuenta();
          cuenta->Usuario(account.usuario);
          cuenta->Password(account.password);
          cuenta->Address(account.address);

          TSPerson person;
          cuenta->Person()->Name(account.persona.name);
          cuenta->Person()->Apellidos(account.persona.apellidos);
          cuenta->Person()->Sexo(account.persona.sexo);
          cuenta->Person()->Ocupacion(account.persona.ocupation);
          cuenta->Person()->Age(account.persona.age);
          cuenta->Cuota(account.cuota);
          cuenta->Cuotafree(account.cuotafree);
          cuenta->Salida(account.internacional);
          Server->Cuentas()->Insert(cuenta);

          int i = 0;
          while(i < account.emails)
          {
            TSMail mail;

            AccountFile->Read(&mail,sizeof(TSMail)); //segunda lectura

            TMail* Mail = new TMail();
            Mail->Parrafo(mail.parrafo);
            Mail->Asunto(mail.asunto);
            Mail->Remitente(mail.remitente);
            Mail->Size(mail.size);
            cuenta->Correos()->Insert(Mail);
            i++;

            int j = 0;
            while(j < mail.adjunts)
            {
              TSAdjunt adjunt;
              AccountFile->Read(&adjunt,sizeof(TSAdjunt)); //tercera lectura
              TFichero* fichero = new TFichero();
              fichero->Adress(adjunt.adress);
              fichero->Tipo(adjunt.tipo);
              fichero->Size(adjunt.length);
              Mail->InsertAdjunt(fichero);
              j++;
            }
          }
          int c = 0;
          while(c < account.agendas)
          {
            char direccion[36];
            AccountFile->Read(&direccion,36);
            AnsiString nombre = direccion;
            cuenta->Agendas()->Insert(&nombre);
          }
        }
      }
    }
  }
  AccountFile->Close();
  delete AccountFile;
}
开发者ID:sharstream,项目名称:MailServer-C,代码行数:80,代码来源:Administradora.cpp


注:本文中的TFile::Read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。