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


C++ TFileStream::Write方法代码示例

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


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

示例1: if

//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
    memset(file_buf, 0xFF, sizeof(file_buf));
    Hex2Bin(edtWorkFilename->Text, false);

    if (ComboBox1->ItemIndex == 0)
    {
        TFileStream * file = new TFileStream(ExtractFilePath(Application->ExeName)+"csp850aupdate.bin", fmCreate);
        file->Write(file_buf+0x4000, max_address-0x4000);
        delete file;
        ShowMessage("生成升级文件");
    }
    else if (ComboBox1->ItemIndex == 1)
    {
        TFileStream * file = new TFileStream(ExtractFilePath(Application->ExeName)+"smartpower_update.bin", fmCreate);
        //xor 0x87
        for (int i=0x4000;i<max_address;i++)
        {
            file_buf[i] ^= 0x87;
        }
        file->Write(file_buf+0x4000, max_address-0x4000);
        delete file;
        ShowMessage("生成升级文件");
    }
}
开发者ID:kongwei,项目名称:CSP_850_A,代码行数:26,代码来源:main.cpp

示例2: Save_Base

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
void Save_Base(TProgType aProgType, AnsiString aFileName, TTreeView *tv1, TTreeView *tv2, TTreeView *tv3, TTreeView *tv4)
{
      TFileStream* FileStream;
 // -------------
      try {
          FileStream = new TFileStream(aFileName, fmCreate);
      } catch ( ... ) {
          MessageBox(NULL, " Невозможно записать файл 'Estimate.dat' \n\n Данные на диск не будут записаны", " Ошибка записи файла ...", MB_ICONERROR);
          return;
      }
 // -------------

      int FileVersion = 21;
      FileStream->Write(&DataFileDescription1, DataFileDescription1[0] + 1);
      FileStream->Write(&DataFileDescription2, DataFileDescription2[0] + 1);
      FileStream->Write(&DataFileDescription3, DataFileDescription3[0] + 1);
      FileStream->Write(&DataFileDescription4, DataFileDescription4[0] + 1);
      FileStream->Write(&DataFileDescription5, DataFileDescription5[0] + 1);
      FileStream->Write(&FileVersion         , sizeof(FileVersion));
 // -------------
      Save_(FileStream, aProgType, tv1, &GlobalElementCounter);
      Save_(FileStream, aProgType, tv2, &GlobalMaterialCounter);
      Save_(FileStream, aProgType, tv3, &GlobalMashineCounter);
      Save_(FileStream, aProgType, tv4, &GlobalEnergoCounter);
 // -------------
      delete FileStream;
}
开发者ID:Medcheg,项目名称:sources_old,代码行数:31,代码来源:mpiLibrary.cpp

示例3: BtnSavePKGDataClick

//---------------------------------------------------------------------------
void __fastcall TFrmUserDataView::BtnSavePKGDataClick(TObject *Sender)
{
	BtnSavePKGData->Enabled = false;
	BtnInputPKGData->Enabled = true;

	UserData_PKG_SaveToSEQ();
	UserData_PKG_SaveToDB();

	UserData_PKG_ReadFromDB();
    UserData_PKG_ReadFromSEQ();

	TFileStream *File;
	TDateTime dt = Now();
	String FolderName = dt.FormatString("yyyy-mm-dd");
	String FileName = dt.FormatString("yyyy-mm-dd hh-nn-ss");
	ForceDirectories("C:\\KOSES\\History\\PKGParamLog\\"+ FolderName);

	String FullPath  =  "C:\\KOSES\\History\\PKGParamLog\\"+ FolderName+"\\"+FileName+".txt";

	File = new TFileStream(FullPath, fmCreate | fmOpenReadWrite);
	File->Position = 0;
	String Strtemp = "PKGParamLog \r\n";
	for(int i=0; i<PkgParamGrid->RowCount; i++)
	{
		Strtemp += " No:"+IntToStr(i)+ ":"+ PkgParamGrid->Cells[3][i+1] +"\r\n";
	}
	File->Write(Strtemp.c_str(),Strtemp.Length());
	delete File;
}
开发者ID:japgo,项目名称:mygithub,代码行数:30,代码来源:FrmUserDataViewScrn.cpp

示例4: SaveToFile

//---------------------------------------------------------------------------
//Guarda la lista de funciones a archivo
bool TFunciones::SaveToFile(AnsiString FileName)
{
  int InfoSize;
  TInfoFuncion F;
  TInfoInt I;
  TFCabecera FCabecera;
  TFFuncion FFuncion;
  TFIntervalo FIntervalo;
  TFileStream *Archivo;
  try{
    if( FileExists(FileName) )
      Archivo = new TFileStream(FileName, fmOpenWrite|fmShareExclusive);
    else
      Archivo = new TFileStream(FileName, fmOpenWrite|fmShareExclusive|fmCreate);
    Archivo->Seek(0, soFromBeginning);
    InfoSize = sizeof(TFCabecera);
    strcpy(FCabecera.ID, ID);
    FCabecera.Version = Version;
    FCabecera.NFunciones = FCount;
    Archivo->Write(&FCabecera,InfoSize);
    for( int i = 0; i < FCabecera.NFunciones; i++){
      F = GetFuncion(i);
      strcpy(FFuncion.Nombre, F.Nombre);
      FFuncion.Graficar = F.Graficar;
      FFuncion.NIntervalos = uIntervaloH::Count(F.Intervalo);
      InfoSize = sizeof(TFFuncion);
      Archivo->Write(&FFuncion,InfoSize);
      InfoSize = sizeof(TFIntervalo);
      for( int j = 0; j < FFuncion.NIntervalos; j++){
        I = Find(F.Intervalo, j)->Info;
        FIntervalo.Min = I.Min;
        FIntervalo.Max = I.Max;
        strcpy(FIntervalo.Expresion, I.Expresion);
        FIntervalo.TipoGrafico = I.TipoGrafico;
        FIntervalo.Color = I.Color;
        FIntervalo.Grosor = I.Grosor;
        Archivo->Write(&FIntervalo,InfoSize);}
      }
    delete Archivo;
    FModificado = false;
    return true;
  }
  catch(...){
    return false;}
}
开发者ID:clubdesarrolladores,项目名称:maxmath,代码行数:47,代码来源:uFuncion.cpp

示例5: ExportFunction

//---------------------------------------------------------------------------
//Exporta una funcion definida a archivo
bool TFunciones::ExportFunction(int Index, AnsiString FileName)
{
  int InfoSize;
  TInfoFuncion F;
  TInfoInt I;
  TFFuncion FFuncion;
  TFIntervalo FIntervalo;
  TFileStream *Archivo;
  try{
    if( FileExists(FileName) )
      Archivo = new TFileStream(FileName, fmOpenWrite|fmShareExclusive);
    else
      Archivo = new TFileStream(FileName, fmOpenWrite|fmShareExclusive|fmCreate);
    Archivo->Seek(0, soFromBeginning);
    InfoSize = sizeof(TFFuncion);
    F = GetFuncion(Index);
    strcpy(FFuncion.Nombre, F.Nombre);
    FFuncion.Graficar = F.Graficar;
    FFuncion.NIntervalos = uIntervaloH::Count(F.Intervalo);
    Archivo->Write(&FFuncion,InfoSize);
    InfoSize = sizeof(TFIntervalo);
    for( int i = 0; i < FFuncion.NIntervalos; i++){
      I = Find(F.Intervalo, i)->Info;
      FIntervalo.Min = I.Min;
      FIntervalo.Max = I.Max;
      strcpy(FIntervalo.Expresion, I.Expresion);
      FIntervalo.TipoGrafico = I.TipoGrafico;
      FIntervalo.Color = I.Color;
      FIntervalo.Grosor = I.Grosor;
      Archivo->Write(&FIntervalo,InfoSize);}
    delete Archivo;
    return true;
  }
  catch(...){
    return false;}
}
开发者ID:clubdesarrolladores,项目名称:maxmath,代码行数:38,代码来源:uFuncion.cpp

示例6: Execute


//.........这里部分代码省略.........
//-----------------------------------
//'暗号化しています...'
ProgressStatusText = LoadResourceString(&Msgencrypt::_LABEL_STATUS_TITLE_ENCRYPTING);
ProgressMsgText = ExtractFileName(OutFilePath);

TotalSize = 0;

try{
	fsOut = new TFileStream(OutFilePath, fmCreate);
	fOpenOut = true;
}
catch(...){
	//'保存する先のファイルが開けません。他のアプリケーションが使用中の可能性があります。'
	MsgText = LoadResourceString(&Msgencrypt::_MSG_ERROR_OUT_FILE_OPEN) + "\n" + OutFilePath;
	MsgType = mtError;
	MsgButtons = TMsgDlgButtons() << mbOK;
	MsgDefaultButton = mbOK;
	Synchronize(&PostConfirmMessageForm);
	delete pms;
	goto LabelError;
}

//-----------------------------------
// 実行可能形式の出力
//-----------------------------------
if ( fExeOutputOption == true ){

	//-----------------------------------
	// 自分のお尻から実行データを抽出
	//-----------------------------------

	//自分自身の実行ファイルを開く
	try{
		fsExe = new TFileStream(Application->ExeName, fmOpenRead | fmShareDenyWrite);
	}
	catch(...){
		//'実行可能形式出力に失敗しました。暗号化処理を中止します。'
		MsgText = LoadResourceString(&Msgencrypt::_MSG_ERROR_EXEOUT_FAILED);
		MsgType = mtError;
		MsgButtons = TMsgDlgButtons() << mbOK;
		MsgDefaultButton = mbOK;
		Synchronize(&PostConfirmMessageForm);
		delete pms;
		goto LabelError;
	}

	//切り出すサイズを取得
	fsExe->Seek(-(__int64)sizeof(__int64), TSeekOrigin::soEnd);
	fsExe->Read(&ExeAllSize, sizeof(__int64));

	//処理する合計サイズに実行形式分を加える
	AllTotalSize += ExeAllSize;

	//自己実行可能形式データの境界へ
	fsExe->Seek(-(__int64)ExeAllSize-sizeof(__int64), TSeekOrigin::soEnd);

	while(fsExe->Read(read_buffer, BUF_SIZE) != 0 ){
		ExeSize+=BUF_SIZE;
		//書き込む
		if ( ExeSize < ExeAllSize ){
			fsOut->Write(read_buffer, BUF_SIZE);
			TotalSize += BUF_SIZE;
		}
		else{
			fsOut->Write(read_buffer, ExeSize-ExeAllSize);
			TotalSize += (ExeSize-ExeAllSize);
开发者ID:OnTheMagellanVoyage,项目名称:AttacheCase,代码行数:67,代码来源:TAttacheCaseFileEncrypt.cpp

示例7: TFileStream

//---------------------------------------------------------------------------
//暗号化ファイルを破壊する
//---------------------------------------------------------------------------
bool __fastcall TForm1::DestroyAtcFile(void)
{

int i;
int fh;

String MsgText;

char buffer[BUF_SIZE];

for ( i = 0; i < BUF_SIZE; i++ ){
	buffer[i]=NULL;
}

TFileStream *fsIn;

char token[16];
const char charTokenString[16] = "_AttacheCaseData";         //復号の正否に使う
const char charDestroyTokenString[16] = "_Atc_Broken_Data";  //破壊されているとき
String AtcFileTokenString;                                   //暗号化ファイルのトークン(文字列)
String AtcFileCreateDateString;                              //暗号化ファイルの生成日時(文字列)

__int64 AllTotalSize;
int PlaneHeaderSize;
int HeaderBufSize;

try {
	fsIn = new TFileStream(Application->ExeName, fmShareDenyNone);
}
catch(...) {
	//'ファイルを開けません。他のアプリケーションで使用中の可能性があります。'
	MsgText = LoadResourceString(&Msgexeout::_MSG_FILE_OPEN_ERROR);
	ShowConfirmMassageForm(MsgText, mtError, TMsgDlgButtons()<<mbOK, mbOK);
	return(false);
}

//総サイズ取得
AllTotalSize = fsIn->Seek((__int64)0, TSeekOrigin::soEnd);
fsIn->Seek((__int64)0, TSeekOrigin::soBeginning);

//-----------------------------------
//ヘッダ情報のチェック
//-----------------------------------

// サイズを取得
fsIn->Seek(-(__int64)sizeof(__int64), TSeekOrigin::soEnd);
fsIn->Read(&AllTotalSize, sizeof(__int64));
// 位置を戻す
fsIn->Seek(-(AllTotalSize + sizeof(__int64)), TSeekOrigin::soEnd);
// 平文ヘッダサイズを読み込む
fsIn->Read(&PlaneHeaderSize, sizeof(int));
// トークンを取得
fsIn->Read(token, 16);

// トークンを再チェック
if (memcmp(token, charTokenString, 16) != 0 ) {
	//すでに壊れている? サイレントに処理終了
	delete fsIn;
	return(true);
}
else{
	fsIn->Seek((__int64)-16, TSeekOrigin::soCurrent);
	//"_Atc_Broken_Data"を書き込む
	fsIn->Write(charDestroyTokenString, 16);
}

//「データバージョン」「アルゴリズムの種類」分だけ進める
fsIn->Seek((__int64)(sizeof(int)*2), TSeekOrigin::soCurrent);
//暗号部ヘッダサイズを取得する
fsIn->Read(&HeaderBufSize, sizeof(int));
//暗号部ヘッダのIVを書き換えて破壊する
fsIn->Write(buffer, BUF_SIZE);
//「暗号部ヘッダサイズ」分だけ進める
fsIn->Seek((__int64)(HeaderBufSize-BUF_SIZE), TSeekOrigin::soCurrent);

// IV部分を書き換えて破壊する
fsIn->Write(buffer, BUF_SIZE);

delete fsIn;

return(true);


}
开发者ID:Bootz,项目名称:AttacheCase,代码行数:87,代码来源:Unit1.cpp

示例8: saveProject

//---------------------------------------------------------------------------
//сохраняет текущий проект на диск
void ProjectManager::saveProject(UnicodeString fileName)
{
	//открываем файловым поток
	TFileStream *fs = new TFileStream(fileName, fmCreate);
	try {
		//заносим текущий проетк в JSON объект
		TJSONObject *js = new TJSONObject();
		TJSONArray *criteriaNamesJSON = new TJSONArray();
		TJSONArray *alternativeNamesJSON = new TJSONArray();

		//добавляем имена критериев
		const vector<UnicodeString> &criteriaNames = getCurrentProject().getCriteriaNames();
		vector<UnicodeString>::const_iterator iter;
		for (iter = criteriaNames.begin(); iter != criteriaNames.end(); ++iter) {
			criteriaNamesJSON->Add(*iter);
		}

		js->AddPair(L"criteriaNames", criteriaNamesJSON);

		//добавляем имена альтернатив
		const vector<UnicodeString> &alternativeNames = getCurrentProject().getAlternativeNames();
		for (iter = alternativeNames.begin(); iter != alternativeNames.end(); ++iter) {
			alternativeNamesJSON->Add(*iter);
		}

		js->AddPair(L"alternativeNames", alternativeNamesJSON);

		//добавляем оценки критериев (баллы и рассчитаныый рейтинг(приоритеты))
		Estimates &criteriaEstimates = currentProject->getCriteriaEstimates();
		vector< vector<int> > &rates = criteriaEstimates.getRates();
		vector<double> &priorities = criteriaEstimates.getPriorities();

		TJSONObject *crteriaEstimatesJSON = new TJSONObject();
		TJSONArray *crteriaEstimatesArray = new TJSONArray();
		for (int i = 0; i < priorities.size(); ++i) {
			crteriaEstimatesArray->Add(FloatToStr(priorities[i]));
		}

		crteriaEstimatesJSON->AddPair(L"priorities", crteriaEstimatesArray);

		TJSONArray *crteriaRatesTable = new TJSONArray();
		for (int i = 0; i < rates.size(); ++i) {
			vector<int> &v = rates[i];
			TJSONArray *crteriaRatesRow = new TJSONArray();
			for (int j = 0; j < v.size(); ++j) {
				crteriaRatesRow->Add(IntToStr(v[j]));
			}

			crteriaRatesTable->Add(crteriaRatesRow);
		}

		crteriaEstimatesJSON->AddPair(L"rates", crteriaRatesTable);
		js->AddPair(L"criteriaEstimates", crteriaEstimatesJSON);

		//добавляем оценки альтернатив
		vector<Estimates> alternativeEstimates = getCurrentProject().getAlternativeEstimates();
		TJSONArray *tableData = new TJSONArray();
		for (int i = 0; i < alternativeEstimates.size(); i++) {
			TJSONObject *alternativeEstimatesJSON = new TJSONObject();
			TJSONArray *prioritiesJSON = new TJSONArray();

			const vector<double> &priorities = alternativeEstimates[i].getPriorities();
			for (int j = 0; j < priorities.size(); j++) {
				prioritiesJSON->Add(FloatToStr(priorities[j]));
			}

			alternativeEstimatesJSON->AddPair("priorities", prioritiesJSON);

			vector< vector<int> > &rates = alternativeEstimates[i].getRates();
			TJSONArray *alternativeRatesTable = new TJSONArray();
			for (int j = 0; j < rates.size(); ++j) {
				vector<int> &v = rates[j];
				TJSONArray *alternativeRatesRow = new TJSONArray();
				for (int k = 0; k < v.size(); ++k) {
					alternativeRatesRow->Add(IntToStr(v[k]));
				}

			alternativeRatesTable->Add(alternativeRatesRow);
			}

			alternativeEstimatesJSON->AddPair(L"rates", alternativeRatesTable);
			tableData->AddElement(alternativeEstimatesJSON);
		}

		js->AddPair(L"alternativeEstimates", tableData);
		//сохраняем имя и метод
		js->AddPair(L"projectName", getCurrentProject().getName());
		js->AddPair(L"method", IntToStr(getCurrentProject().getMethod()));
        //сохраняем JSON объект в файл как строку
		UnicodeString projectJSON = js->ToString();

		fs->Write(projectJSON.BytesOf(), projectJSON.Length());
		js->Free();

		//устанавливаем, что проект сохранён
		setIsCurrentProjectSaved(true);

	} __finally {
//.........这里部分代码省略.........
开发者ID:Mu3AHTPOn,项目名称:diplom,代码行数:101,代码来源:ProjectManager.cpp


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