Ejemplo n.º 1
0
//---------------------------------------------------------------------------
void __fastcall TOrdEntryForm::Save1Click(TObject *Sender)
{
  if (CurFile == "NONAME")
    SaveAs1Click(Sender);
  else
    SaveToFile(CurFile);
}
void __fastcall TfrmMain::Save1Click(TObject *Sender)
{
    if (!havesFilename)
    {
        SaveAs1Click(this);
        return;
    }

    OptimizeFilterList();

    int handle;

    if ((handle = open(textureFilename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IWRITE)) == -1)
    {
        Application->MessageBoxA("Error creating file", "Error", MB_OK);
        return;
    }

    write(handle, TEXGEN_HEADER2, 4);

    write(handle, &nrFilters, 2);

    write(handle, &textureWidth, 2);
    write(handle, &textureHeight, 2);

    for (int i = 0; i < nrFilters; i++)
    {
        int size = GetSizeOfFilter(filters[i]->command);
        if (size != -1)
        {
            write(handle, filters[i], size);
        }
        else
        {
            Application->MessageBoxA("Wrong filter found :(", "Error", MB_OK);
            break;
        }
    }

    close(handle);
}