Exemplo n.º 1
0
void TOrdEntryForm::SaveToFile(TFileName OrderFile)
{
  ofstream DataFile;
  DataFile.open(OrderFile.c_str());
  TRec Temp;

  for (int i=0;i<DataList->Count;i++) {
    TransferFromDataList(i, Temp);
	  DataFile.write((char*)&Temp, sizeof(TR));
  }
  DataFile.close();
}
Exemplo n.º 2
0
void TOrdEntryForm::ReadFile(TFileName OrderFile)
{
  ifstream DataFile(OrderFile.c_str());
  if (!DataFile) return;

  // avoid painting while file is loaded
  LockWindowUpdate(Handle);
  while (!DataFile.read((char *)&TR, sizeof(TR)).eof()) {
    AddRecord();
  }
  LockWindowUpdate(0);
  DataFile.close();
  OvcVirtualListbox1->Repaint();
  OvcVirtualListbox1->ItemIndex = 0;
}
Exemplo n.º 3
0
bool CCachedLogInfo::CCacheFileManager::ShouldDrop
    ( const TFileName& name
    , int maxFailures)
{
    // no mark -> no crash -> no drop here

    if (!IsMarked (name))
    {
        failureCount = NO_FAILURE;
        return false;
    }

    // can we open it?
    // If not, somebody else owns the lock -> don't touch it.

    HANDLE tempHandle = CreateFile ( name.c_str()
                                   , GENERIC_READ
                                   , 0
                                   , 0
                                   , OPEN_ALWAYS
                                   , FILE_ATTRIBUTE_NORMAL|FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
                                   , NULL);
    if (tempHandle == INVALID_HANDLE_VALUE)
        return false;

    try
    {
        // any failure count so far?

        CFile file (tempHandle);
        if (file.GetLength() != 0)
        {
            CArchive stream (&file, CArchive::load);
            stream >> failureCount;
        }
        else
        {
            failureCount = 0;
        }

        // too many of them?

        CloseHandle (tempHandle);
        return failureCount >= maxFailures;
    }