//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <fstream.h>
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
char buf[1024];
ifstream is("in.file", ios::binary);
ofstream os("kontener\\mapa.bin", ios::binary|ios::app);
while(is && is.read(buf, 1024).gcount() > 0)
{
os.write(buf, is.gcount());
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
if (!DirectoryExists("kontener")) {
if (!CreateDir("kontener"))
throw Exception("Nie można utworzyć folderu ' kontener'");
}
String fileName = ExtractFilePath(ParamStr(0)) + "kontener\\mapa.bin";
fstream outfile;
outfile.open(fileName.c_str(), ios::out | ios::binary);
outfile.write((char *)&"Naglowek ", 12); // Początek nagłowka pliku 12 bajtów
outfile.close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
String fileName = ExtractFilePath(ParamStr(0)) + "kontener\\mapa.bin";
fstream outfile;
outfile.open(fileName.c_str(), ios::out |ios::app |ios::binary);
outfile.write((char *)&"\0\0\0\0", 4); //koniec pliku
outfile.close();
}
//---------------------------------------------------------------------------