• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TFileStream类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: vector3

void Global::LoadIniFile(AnsiString asFileName)
{
    int i;
    for (i = 0; i < 10; ++i)
    { // zerowanie pozycji kamer
        pFreeCameraInit[i] = vector3(0, 0, 0); // wspó³rzêdne w scenerii
        pFreeCameraInitAngle[i] = vector3(0, 0, 0); // k¹ty obrotu w radianach
    }
    TFileStream *fs;
    fs = new TFileStream(asFileName, fmOpenRead | fmShareCompat);
    if (!fs)
        return;
    AnsiString str = "";
    int size = fs->Size;
    str.SetLength(size);
    fs->Read(str.c_str(), size);
    // str+="";
    delete fs;
    TQueryParserComp *Parser;
    Parser = new TQueryParserComp(NULL);
    Parser->TextToParse = str;
    // Parser->LoadStringToParse(asFile);
    Parser->First();
    ConfigParse(Parser);
    delete Parser; // Ra: tego jak zwykle nie by³o wczeœniej :]
};
开发者ID:kononowicz24,项目名称:maszyna,代码行数:26,代码来源:Globals.cpp


示例2: TFileStream

//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
 AnsiString s;
 TFileStream* fs;
 int i;

 s = "";
 if (lbTables->SelCount > 0)
  for (i = 0; i < lbTables->Items->Count; i++)
   if (lbTables->Selected[i])
    {
     ACRTable1->TableName = lbTables->Items->Strings[i];
     s = s + ACRTable1->ExportTableToSQL(
      cbExportStructure->Checked,
      cbAddDROPTable->Checked,
      cbExportIndexes->Checked,
      cbAddDROPIndex->Checked,
      cbExportData->Checked,
      cbExportBLOBFields->Checked,
      cbUseBrackets->Checked);
    };
 Memo1->Text = s;
 fs = new TFileStream("test.sql",fmCreate);
 fs->WriteBuffer(&s[1],s.Length());
 delete fs;
}
开发者ID:vagabond1132,项目名称:Code,代码行数:27,代码来源:Unit1.cpp


示例3: 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


示例4: memset

//---------------------------------------------------------------------------
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


示例5: UserData_PKG_SaveToSEQ

//---------------------------------------------------------------------------
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


示例6: TFileStream

// ---------------------------------------------------------------------------
//
void __fastcall TForm1::DisplayFromFile(TGdViewer *gv, String sFilePath) {
	FullPath = sFilePath;
	TFileStream *fs = new TFileStream(sFilePath, fmShareDenyNone);
	char *buf = new char[fs->Size];
	fs->Read(buf, fs->Size);
	long g = fs->Size;
	gv->DisplayFromMemory((long) buf, &g);
	delete fs;
	delete[]buf;
}
开发者ID:leiqunni,项目名称:v2iewx,代码行数:12,代码来源:main.cpp


示例7: StringFromFile

AnsiString StringFromFile(const AnsiString FileName, __int64& FileSize)
{
  TFileStream* fs = new TFileStream(FileName, fmOpenRead);
  AnsiString Result;
  try
  {
    FileSize = fs->Size;
    Result.SetLength(FileSize);
    if (fs->Size > 0)
      fs->Read(Result.c_str(), FileSize);
  }
  __finally
  {
    delete fs;
  }
  return Result;
}
开发者ID:kaan3434,项目名称:gvindelen,代码行数:17,代码来源:MainSpeedForm.cpp


示例8: TFileStream

//---------------------------------------------------------------------------
//Carga una lista de funciones desde archivo
bool TFunciones::LoadFromFile(AnsiString FileName)
{
  int InfoSize;
  TInfoFuncion F;
  TInfoInt I;
  TFCabecera FCabecera;
  TFFuncion FFuncion;
  TFIntervalo FIntervalo;
  TFileStream *Archivo;
  try{
    if( !FileExists(FileName) )
      return false;
    else{
      Archivo = new TFileStream(FileName, fmOpenRead|fmShareExclusive);
      Archivo->Seek(0, soFromBeginning);
      InfoSize = sizeof(TFCabecera);
      Archivo->Read(&FCabecera, InfoSize);
      if(strcmp(FCabecera.ID, ID) != 0)
        throw Exception("Archivo desconocido");
      //FCabecera.Version; Contiene la versión del archivo
      for( int i = 0; i < FCabecera.NFunciones; i++){
        InfoSize = sizeof(TFFuncion);
        Archivo->Read(&FFuncion, InfoSize);
        strcpy(F.Nombre, FFuncion.Nombre);
        F.Graficar = FFuncion.Graficar;
        F.Intervalo = NULL;
        InfoSize = sizeof(TFIntervalo);
        for( int j = 0; j < FFuncion.NIntervalos; j++){
          Archivo->Read(&FIntervalo, InfoSize);
          I.Min = FIntervalo.Min;
          I.Max = FIntervalo.Max;
          strcpy(I.Expresion, FIntervalo.Expresion);
          I.TipoGrafico = FIntervalo.TipoGrafico;
          I.Color = FIntervalo.Color;
          I.Grosor = FIntervalo.Grosor;
          uIntervaloH::Add(F.Intervalo, I);}
        Add(F);
      }
      FModificado = false;
      delete Archivo;
      return true;}
    }
  catch(...){
    return false;}
}
开发者ID:clubdesarrolladores,项目名称:maxmath,代码行数:47,代码来源:uFuncion.cpp


示例9: TFileStream

void TUserIniFile::RecreateSections()
{
  const String CR = "\n";
  String* S;
  TFileStream* FileStream = new TFileStream(FileName, fmCreate);
  try {
    for(int i=0; i < SectionCount(); i++) {
      FileStream->Seek(0, soFromEnd);
      S = new String();
      *S = Format((String)"%s[%s]%s", ARRAYOFCONST((CR, SectionNames[i], CR)));
      FileStream->WriteBuffer((const void *)S, S->Length());
      delete S;
    }
  }
  __finally {
    delete FileStream;
  }
}
开发者ID:chinnyannieb,项目名称:Meus-Projetos,代码行数:18,代码来源:UnboundExternalDataDemoClasses.cpp


示例10: TFileStream

bool TCurve::LoadFromFile(AnsiString asName)
{
    DecimalSeparator = '.';
    TFileStream *fs;
    fs = new TFileStream(asName, fmOpenRead | fmShareCompat);
    AnsiString str = "xxx";
    int size = fs->Size;
    str.SetLength(size);
    fs->Read(str.c_str(), size);
    str += "";
    delete fs;
    TQueryParserComp *Parser;
    Parser = new TQueryParserComp(NULL);
    Parser->TextToParse = str;
    Parser->First();
    Load(Parser);

    delete Parser;
    DecimalSeparator = ',';
}
开发者ID:shaxbee,项目名称:maszyna,代码行数:20,代码来源:Curve.cpp


示例11: Load_Base

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AnsiString Load_Base(AnsiString aFileName, TTreeView *tv1, TTreeView *tv2, TTreeView *tv3, TTreeView *tv4)
{
     TDateTime t1= Now();
 // -------------
     TFileStream* FileStream;
     try {
        FileStream = new TFileStream(aFileName, fmOpenRead);
     } catch ( ... ) {
        MessageBox(NULL, " Невозможно открыть файл 'Estimate.dat' \n\n Данные файла не будут загружены", " Ошибка открытия файла ...", MB_ICONERROR);
        return FloatToStrF((Now().Val - t1.Val)*3600.0*24.0, ffFixed, 15, 3) + "c.";
     }
 // -------------
      ShortString tempString;
      int FileVersion = 0;
      FileStream->Read(&tempString[0], 1);   FileStream->Read(&tempString[1], tempString[0]);
      FileStream->Read(&tempString[0], 1);   FileStream->Read(&tempString[1], tempString[0]);
      FileStream->Read(&tempString[0], 1);   FileStream->Read(&tempString[1], tempString[0]);
      FileStream->Read(&tempString[0], 1);   FileStream->Read(&tempString[1], tempString[0]);
      FileStream->Read(&tempString[0], 1);   FileStream->Read(&tempString[1], tempString[0]);

      FileStream->Read(&FileVersion, sizeof(FileVersion));
      Load_(FileStream, tv1, &GlobalElementCounter );
      Load_(FileStream, tv2, &GlobalMaterialCounter);
      Load_(FileStream, tv3, &GlobalMashineCounter );
      Load_(FileStream, tv4, &GlobalEnergoCounter  );


   // ----------- Создаю список материалов и другой фиговины ---------
         PrepareSpecificallArrays();

         CreateMaterialList (tv1);
         CreateRashodnikList(tv1);
         CreateMashineList  (tv1);
         CreateEnergoList   (tv1);
         CreateServiseList  (tv1);

      
/*      Load_2004_07_14(FileStream, tv1, &GlobalElementCounter);
      Load_2004_07_14(FileStream, tv2, &GlobalMaterialCounter);
      Load_2004_07_14(FileStream, tv3, &GlobalMashineCounter);
      Load_2004_07_14(FileStream, tv4, &GlobalEnergoCounter);*/

 // -------------

  delete FileStream;
  return FloatToStrF((Now().Val - t1.Val)*3600.0*24.0, ffFixed, 15, 3) + "c.";
}
开发者ID:Medcheg,项目名称:sources_old,代码行数:51,代码来源:mpiLibrary.cpp


示例12: IncludeTrailingPathDelimiter

//===========================================================================
//スレッド実行
//===========================================================================
void __fastcall TAttacheCaseFileDecrypt1::Execute()
{

int i, c, len;
float ProgressPercentNumF;  //進捗パーセンテージ(浮動小数点)

// バッファ
char buffer[BUF_SIZE];
char source_buffer[BUF_SIZE];
char temp_buffer[BUF_SIZE];
char output_buffer[LARGE_BUF_SIZE];
char *headerbuffer;

//パスワード
bool fPasswordOk;

String FilePath, FileName;

// ファイルストリーム
TFileStream *fsIn;
TFileStream *fsOut;
bool fInputFileOpen = false;
bool fOutputFileOpen = false;

float free_space_required;
__int64 CurrentPos, TotalSize;
__int64 CurrentDriveFreeSpaceSize;

//処理する合計サイズ
AllTotalSize = 0;

int ret;	//バッファ出力の返値
int FileIndex = 0;

//Blowfish
CBlowFish *bf;

char token[17] = {0, };
const String PrefixString      = "Fn_";
const char charTokenString[17] = "_AttacheCaseData";         //復号の正否に使う
String AtcFileTokenString;                                   //暗号化ファイルのトークン(文字列)
String AtcFileCreateDateString;                              //暗号化ファイルの生成日時(文字列)

//同名ファイル/フォルダーはすべて上書きして復号する
//(ユーザーがダイアログで「すべてはい」を選択したとき = true )
fOverwirteYesToAll = false;
//「復号したファイルを関連付けされたソフトで開く」一時的な設定
fTempOpenFile = fOpenFile;
//フォルダーを一度開いたか(深いフォルダーすべてを開かないように)
fOpenFolderOnce = false;

// 出力するディレクトリ
OutDirPath = IncludeTrailingPathDelimiter(OutDirPath);

String TempRelativePath;


// 暗号化部分のヘッダサイズ
int EncryptHeaderSize = 0;

int DataVersion;        // ver.2.00~は "5", ver.2.70~は "6"

int flush, status;      // zlib
z_stream z;             // zlibライブラリとやりとりするための構造体
bool fInputEnd = false; // 入力ストリームの終了

//ヘッダデータから必要情報を取り出すための
TMemoryStream *pms;     // メモリストリーム

int idx;
TStringList *DataList;
TStringList *tsv;

TStringList *FileList = new TStringList();  // 0: ファイル名
__int64 *FileSizeList = 0;                  // 1: ファイルサイズ(フォルダは-1)
int *FileAttrList     = 0;                  // 2: 属性
int *FileAgeList      = 0;                  // 3: タイムスタンプ

int rest;
int buf_size;

//----------------------------------------------------------------------
// 平文のヘッダ内容チェック
try {
	fsIn = new TFileStream(AtcFilePath, fmOpenRead | fmShareDenyNone);
}
catch(...) {
	//'復号するファイルを開けません。他のアプリケーションが使用中の可能性があります。'
	MsgText = LoadResourceString(&Msgdecrypt::_MSG_ERROR_FILE_OPEN);
	MsgType = mtError;
	MsgButtons = TMsgDlgButtons() << mbOK;
	MsgDefaultButton = mbOK;
	Synchronize(&PostConfirmMessageForm);
	goto LabelError;
}

fInputFileOpen = true;
//.........这里部分代码省略.........
开发者ID:hibara,项目名称:AttacheCase,代码行数:101,代码来源:TAttacheCaseFileDecrypt1.cpp


示例13: TFileStream

BOOL	TStripInfo::OpenInfo(CONST TCHAR* szFilePath)
{
    TFileStream* outStream = new TFileStream(szFilePath, fmOpenRead);

   	outStream->ReadBuffer(&_stripVisual->fPRSMarkX, sizeof(INT32));
    outStream->ReadBuffer(&_stripVisual->fPRSMarkY, sizeof(INT32));
    outStream->ReadBuffer(&_stripVisual->fDeviceSizeX, sizeof(FLOAT));
    outStream->ReadBuffer(&_stripVisual->fDeviceSizeY, sizeof(FLOAT));
    outStream->ReadBuffer(&_stripVisual->clSelectUnitSheet, sizeof(TColor));
    outStream->ReadBuffer(&_stripVisual->clSelectUnitOutline, sizeof(TColor));
    outStream->ReadBuffer(&_stripVisual->clDefaultUnitSheet, sizeof(TColor));
    outStream->ReadBuffer(&_stripVisual->clDefaultUnitOutline, sizeof(TColor));
    outStream->ReadBuffer(&_stripVisual->nAngle, sizeof(INT32));
    outStream->ReadBuffer(&_stripVisual->clIndicateLine, sizeof(TColor));
    outStream->ReadBuffer(&_stripVisual->nOriginLocation, sizeof(INT32));

    outStream->ReadBuffer(&_stripUnits->fUnitXSize, sizeof(FLOAT));
    outStream->ReadBuffer(&_stripUnits->fUnitYSize, sizeof(FLOAT));
    outStream->ReadBuffer(&_stripUnits->fUnitXPitch, sizeof(FLOAT));
    outStream->ReadBuffer(&_stripUnits->fUnitYPitch, sizeof(FLOAT));
    outStream->ReadBuffer(&_stripUnits->nUnitXCountPerBlock, sizeof(INT32));
    outStream->ReadBuffer(&_stripUnits->nUnitYCountPerBlock, sizeof(INT32));
    outStream->ReadBuffer(&_stripUnits->fFirstMarkToUnitCenterX, sizeof(FLOAT));
    outStream->ReadBuffer(&_stripUnits->fFirstMarkToUnitCenterY, sizeof(FLOAT));

    outStream->ReadBuffer(&_stripBlock->nBlockXCount, sizeof(INT32));
    outStream->ReadBuffer(&_stripBlock->nBlockYCount, sizeof(INT32));
    outStream->ReadBuffer(&_stripBlock->fBlockXPitch, sizeof(FLOAT));
    outStream->ReadBuffer(&_stripBlock->fBlockYPitch, sizeof(FLOAT));

    _stripVisual->SetAngle(_stripVisual->nAngle);

    delete outStream;
    return true;
}
开发者ID:japgo,项目名称:mygithub,代码行数:35,代码来源:stripinfo.cpp


示例14: ZeroMemory

//===========================================================================
// スレッド実行
//===========================================================================
void __fastcall TAttacheCaseFileEncrypt::Execute()
{

int i, c;
int res;

float ProgressPercentNumF;  //進捗パーセンテージ(浮動小数点)

z_stream z;                 // zlibライブラリとやりとりするための構造体
int flush, status;          // zlib

//出力する暗号化ファイルのタイムスタンプを元ファイルに合わせる
HANDLE hFile;
//_WIN32_FIND_DATAW first_fd;
ZeroMemory(&first_fd, sizeof(_WIN32_FIND_DATAW));

int len, pos;
int FileIndex;
String FilePath;

int HeaderSize;                          //ヘッダデータサイズ
__int64 CurrentDriveFreeSpaceSize = -1;  //保存するドライブの空き容量

//実行可能形式出力ファイルのデータサイズ
__int64 ExeAllSize = 0;
__int64 ExeSize    = 0;

//全体のファイルサイズ
AllTotalSize = 0;
__int64 TotalSize = 0;

//バッファ
char source_buffer[BUF_SIZE];
char read_buffer[BUF_SIZE];
char out_buffer[BUF_SIZE];
char chain_buffer[BUF_SIZE]; // IVなどを格納するチェインバッファ
char margin_buffer[BUF_SIZE];

//ファイルストリーム
TFileStream *fsIn;
TFileStream *fsOut;
TFileStream *fsExe;

//オープン中か
bool fOpenIn;
bool fOpenOut;
//メモリストリーム
TMemoryStream *pms = new TMemoryStream;

// マージンバッファサイズ
int MarginBufSize = MARGIN_BUF_SIZE;

// PKCS #7 Pading num.
unsigned char paddingNum = 0;

//---------------------------------------
// 同名ファイルがあるのでダイアログ表示
//---------------------------------------
if ( fConfirmOverwirte == true && fOverwirteYesToAll == false ) {

	if (FileExists(OutFilePath) == true) {
		//同名ファイルの上書き確認メッセージダイアログ
		MsgText = LoadResourceString(&Msgencrypt::_MSG_CONFIRM_OVER_WRITE_SAME_FILE)+"\n"+OutFilePath;
		Synchronize(&PostConfirmOverwriteMessageForm);
		if ( MsgReturnVal == mrYes ) {
			//上書きOKなのでFilePathはそのまま
		}
		else if ( MsgReturnVal == mrNo ) {
			//別名保存でFilePath文字列が書き換えられてきている
			OutFilePath = MsgReturnPath;
		}
		else if ( MsgReturnVal == mrYesToAll ) {
			//すべて上書き(YesToAll)
			fOverwirteYesToAll = true;
		}
		else if ( MsgReturnVal == mrCancel ) {
			//キャンセル
			delete pms;
			goto LabelStop;
		}
	}

}

//---------------------------------------
// ヘッダ情報の生成&ファイル総サイズ取得
//---------------------------------------

//'暗号化するファイルリストの生成中...'
ProgressStatusText = LoadResourceString(&Msgencrypt::_LABEL_STATUS_TITLE_LISTING);

if ( CreateHeaderData( pms, InputFileList, FilePathList, AllTotalSize) == false ){
	if (Terminated == true) {
		//ユーザーキャンセルで抜けてきた
		delete pms;
		goto LabelStop;
	}
//.........这里部分代码省略.........
开发者ID:OnTheMagellanVoyage,项目名称:AttacheCase,代码行数:101,代码来源:TAttacheCaseFileEncrypt.cpp


示例15: TFileStream

//---------------------------------------------------------------------------
//загрузка проекта из файла, действия аналогичные, что и в сохранении, только
//в обратном порядке(парсим JSON объект и заполняем пустой проект)
Project & ProjectManager::loadProject(UnicodeString fileName)
{
    TFileStream *fs = new TFileStream(fileName, fmOpenRead);
	try {
		int n = fs->Size;
		char *chars = new char[n+1];

		fs->Read(chars, n);
		chars[n] = '\0';
		UnicodeString str(chars);

		TJSONObject *js = (TJSONObject*) TJSONObject::ParseJSONValue(str);

		closeProject();
		currentProject = new Project();

		TJSONArray *criteriaNamesJSON = (TJSONArray*) js->Get(L"criteriaNames")->JsonValue;
		vector<UnicodeString> &criteriaNames= getCurrentProject().getCriteriaNames();
		for (int i = 0; i < criteriaNamesJSON->Size(); ++i) {
			criteriaNames.push_back(criteriaNamesJSON->Get(i)->Value());
		}

		TJSONArray *alternativeNamesJSON = (TJSONArray*) js->Get(L"alternativeNames")->JsonValue;
		vector<UnicodeString> &alternativeNames = getCurrentProject().getAlternativeNames();
		for (int i = 0; i < alternativeNamesJSON->Size(); ++i) {
			alternativeNames.push_back(alternativeNamesJSON->Get(i)->Value());
		}

		TJSONObject *crteriaEstimatesJSON = (TJSONObject*) js->Get(L"criteriaEstimates")->JsonValue;
		TJSONArray *crteriaEstimatesArray = (TJSONArray*) crteriaEstimatesJSON->Get(L"priorities")->JsonValue;
		Estimates &criteriaEstimates = currentProject->getCriteriaEstimates();
		vector<double> &priorities = criteriaEstimates.getPriorities();
		for (int i = 0; i < crteriaEstimatesArray->Size(); ++i) {
			priorities.push_back(StrToFloat(crteriaEstimatesArray->Get(i)->Value()));
		}

		TJSONArray *crteriaRatesTable = (TJSONArray*) crteriaEstimatesJSON->Get(L"rates")->JsonValue;
		vector< vector<int> > &rates = criteriaEstimates.getRates();
		for (int i = 0; i < crteriaRatesTable->Size(); ++i) {
			vector<int> v;
			TJSONArray *crteriaRatesRow = (TJSONArray*) crteriaRatesTable->Get(i);

			for (int j = 0; j < crteriaRatesRow->Size(); ++j) {
				v.push_back(StrToInt(crteriaRatesRow->Get(j)->Value()));
			}

			rates.push_back(v);
		}

		TJSONArray *alternativeEstimatesJSON = (TJSONArray*) js->Get(L"alternativeEstimates")->JsonValue;
		vector<Estimates> &alternativeEstimates = getCurrentProject().getAlternativeEstimates();
		for (int i = 0; i < alternativeEstimatesJSON->Size(); ++i) {
			TJSONObject *alternativeJSON = (TJSONObject*) alternativeEstimatesJSON->Get(i);
			alternativeEstimates.push_back(Estimates());

			TJSONArray *prioritiesJSON = (TJSONArray*) alternativeJSON->Get(L"priorities")->JsonValue;
			vector<double> &priorities = alternativeEstimates[i].getPriorities();
			for (int j = 0; j < prioritiesJSON->Size(); ++j) {
				UnicodeString str = prioritiesJSON->Get(j)->Value();
				priorities.push_back(StrToFloat(str));
			}

			TJSONArray *alternativeRatesTable = (TJSONArray*) alternativeJSON->Get(L"rates")->JsonValue;
			vector< vector<int> > &rates = alternativeEstimates[i].getRates();
			for (int j = 0; j < alternativeRatesTable->Size(); ++j) {
				vector<int> v;
				TJSONArray *alternativeRatesRow = (TJSONArray*) alternativeRatesTable->Get(j);

				for (int k = 0; k < alternativeRatesRow->Size(); ++k) {
					v.push_back(StrToInt(alternativeRatesRow->Get(k)->Value()));
				}

				rates.push_back(v);
			}
		}

		getCurrentProject().setName(js->Get(L"projectName")->JsonValue->Value());
		getCurrentProject().setMethod(StrToInt(js->Get(L"method")->JsonValue->Value()));

		delete [] chars;
		js->Free();

		setIsProjectOpen(true);
		setIsCurrentProjectSaved(true);
		return getCurrentProject();
	} __finally {
		fs->Free();
	}

	return getCurrentProject();
}
开发者ID:Mu3AHTPOn,项目名称:diplom,代码行数:94,代码来源:ProjectManager.cpp


示例16: IncludeTrailingPathDelimiter

//===========================================================================
//スレッド実行
//===========================================================================
void __fastcall TAttacheCaseFileDecrypt2::Execute()
{

int i, c, len;
float ProgressPercentNumF;  //進捗パーセンテージ(浮動小数点)

// バッファ
char source_buffer[BUF_SIZE];
char temp_buffer[BUF_SIZE];
char chain_buffer[BUF_SIZE];
char output_buffer[LARGE_BUF_SIZE];
char *headerbuffer;

//パスワード
bool fPasswordOk;
//const int KeyArrayNum = sizeof(key)/sizeof(key[0]);

String FilePath, FileName;

// ファイルストリーム
TFileStream *fsIn;
TFileStream *fsOut;

bool fInputFileOpen = false;
bool fOutputFileOpen = false;

float free_space_required;
__int64 CurrentPos, TotalSize;
__int64 CurrentDriveFreeSpaceSize;

//処理する合計サイズ
AllTotalSize = 0;

int ret;	//バッファ出力の返値
int FileIndex = 0;

char token[17] = {0, };
const char charTokenString[17] = "_AttacheCaseData";         //復号の正否に使う
const char charBrokenToken[17] = "_Atc_Broken_Data";         //ファイルが破壊されていることを示すトークン
String AtcFileTokenString;                                   //暗号化ファイルのトークン(文字列)
String AtcFileCreateDateString;                              //暗号化ファイルの生成日時(文字列)

//「復号したファイルを関連付けされたソフトで開く」一時的な設定
fTempOpenFile = fOpenFile;
//フォルダーを一度開いたか(深いフォルダーすべてを開かないように)
fOpenFolderOnce = false;

// 出力するディレクトリ
OutDirPath = IncludeTrailingPathDelimiter(OutDirPath);

String TempRelativePath;


// 平文ヘッダサイズ(データサブバージョン、破壊設定など)
int PlainHeaderSize = 0;
// 暗号化部分のヘッダサイズ
int EncryptHeaderSize = 0;

int DataVersion;        // ver.2.00~は "5", ver.2.70~は "6"
int AlgorismType;

char reserved;          // 0
//int TypeLimits;       // ミスタイプ回数 0~10  (グローバル:public宣言とした)
//bool fDestroy;        // 破壊するか否か 0 or 1 (グローバル:public宣言とした)

String PrefixString;	  //ファイルリストの接頭辞(Fn_*, U_*)

int flush, status;      // zlib
z_stream z;             // zlibライブラリとやりとりするための構造体
bool fInputEnd = false; // 入力ストリームの終了

//ヘッダデータから必要情報を取り出すための
TMemoryStream *pms;     // メモリストリーム

int idx;
TStringList *DataList;
TStringList *tsv;

TStringList *FileList = new TStringList();  // 0: ファイル名
__int64 *FileSizeList = 0;               // 1: ファイルサイズ(フォルダは-1)
int *FileAttrList     = 0;               // 2: 属性
int *FileDtChangeList = 0;               // 3: 更新日
int *FileTmChangeList = 0;               // 4: 更新時
int *FileDtCreateList = 0;               // 5: 作成日
int *FileTmCreateList = 0;               // 6: 作成時

int rest;
int buf_size;

//----------------------------------------------------------------------
// 平文のヘッダ内容チェック

try {
	fsIn = new TFileStream(AtcFilePath, fmOpenRead | fmShareDenyNone);
}
catch(...) {
	//'復号するファイルを開けません。他のアプリケーションが使用中の可能性があります。'
//.........这里部分代码省略.........
开发者ID:hibara,项目名称:AttacheCase,代码行数:101,代码来源:TAttacheCaseFileDecrypt2.cpp


示例17: SetStream

void IShortReader::SetStream( TFileStream& stream, const string& name )
{
    stream.reset( new CPackedFile( name ) ); // ifstream( name.c_str() ) );
    if( stream->SetStream().fail() )
        THROW( runtime_error, "Error: failed to open file " << name << " for reading" );
}
开发者ID:MedicineAndTheMicrobiome,项目名称:AnalysisTools,代码行数:6,代码来源:cshortreader.cpp


示例18: 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


示例19: TFileStream

bool TMainForm::PerformCtlFileTransfer(void)
{
   PCHAR buf;
   TFileStream *fStream;
   bool success;

   LONG bufLen;
   String tmp;

   fStream = new TFileStream(FileSpec,fmOpenRead | fmShareDenyWrite);

   if (fStream) {
     LONG fSize = fStream->Size;

     FX2Device->ControlEndPt->TimeOut = 25000;
     FX2Device->ControlEndPt->Index = 0;

     if (fSize <= MAX_CTLXFER_SIZE) {   // Small file

       FX2Device->ControlEndPt->Value = 0;  // The destination address

       buf = new UCHAR[fSize];
       fStream->Read(buf, fSize);
       success = FX2Device->ControlEndPt->Write(buf, fSize);

       if (!success)
         Application->MessageBox("File transfer failed.","Write to Device");

       delete[] buf;

     } else {                           // Big file
       LONG bufLen;

       buf = new UCHAR[MAX_CTLXFER_SIZE];

       success = true;
       do {
         FX2Device->ControlEndPt->Value = fStream->Position;  // Dest address

         bufLen = fSize - fStream->Position;
         if (bufLen > MAX_CTLXFER_SIZE) bufLen = MAX_CTLXFER_SIZE;

         fStream->Read(buf, bufLen);
         success &= FX2Device->ControlEndPt->Write(buf, bufLen);

       } while (success && (fStream->Position < fSize));

       if (!success)
         Application->MessageBox("File transfer failed.","Write to Device");

       delete[] buf;

     } // if (fSize <= 4096)

     FX2Device->ControlEndPt->TimeOut = 5000;
     delete fStream;

   } else // if (fStream)
     Application->MessageBox("Could not read from file.", "File Xfer Error");


   return success;

}
开发者ID:MarkN0,项目名称:HEXITEC-GSE,代码行数:64,代码来源:MainF.cpp


示例20: TFileStream

void __fastcall TFolderCheck::ReadingBinary(char *FilePath,char *FilePath2)
{
  replace=true;
  char *Buffer = NULL;
  char *Buffer2 = NULL;
  TFileStream *PktFile = NULL;
  TFileStream *PktFile2 = NULL;
        PktFile = new TFileStream( FilePath, fmOpenRead | fmShareDenyNone );
        PktFile2 = new TFileStream( FilePath2, fmOpenRead | fmShareDenyNone );
      if ( PktFile ){
	  Buffer = new char[ PktFile->Size ];
	  PktFile->ReadBuffer( Buffer, PktFile->Size );
          }
        if ( PktFile2 ){
	  Buffer2 = new char[ PktFile2->Size ];
	  PktFile2->ReadBuffer(Buffer2, PktFile2->Size );
          }

         if ( (int)(PktFile->Size)==(int)(PktFile2->Size) || (PktFile->Size ==0 && PktFile2->Size==0)){
         replace=false;
         int p=1000;
         if ( p >(int)(PktFile2->Size))
         {
         p=(int)(PktFile2->Size);
         }
        for (int i=0; i<p ;i++)
        {
          if (Buffer[i]==Buffer2[i])
                {
                 replace=false;
                }
          else  {
                 replace=true;
                 break;
                }

        }
}

      if ( PktFile ){
      delete PktFile;
      PktFile = NULL;}

    if ( PktFile2 ){
      delete PktFile2;
      PktFile = NULL;}

    if ( Buffer ){
      delete[] Buffer;
      Buffer = NULL;}

    if ( Buffer2 ){
      delete[] Buffer2;
      Buffer2 = NULL;}

    if (replace)
             {
             Log->Write("FilePath2 : "+AnsiString(FilePath2));
             Log->Write("FilePath  : "+AnsiString(FilePath));
             Log->Write("File old. Need to update ...");
          /*   string StrPath = FilePath;
             char str2[] = "C:\\DPSUpdate";
             StrPath.erase(0,strlen(str2));
             Log->Write(StrPath.c_str());
             char *mychar = new char[StrPath.length()+1];
             strcpy(mychar, StrPath.c_str());
             mychar[strlen(mychar)-strlen(strrchr(mychar,'\\'))]='\0';
             strcat(CurBackUp,mychar);
             Log->Write("Preready folder: "+AnsiString(CurBackUp));
             CheckFolder(CurBackUp,0,0);     */
             BUCopyFile(FilePath, CurBackUp);
             Log->Write("After folder: "+AnsiString(CurBackUp));
   //printf("pos: %d\n", strstr(str, "abc") - str);

             //Log->Write("Updating file ...");
             //DeleteFile(FilePath);

             CopyFile(FilePath2,FilePath,false);
             }
    else {
             Log->Write("FilePath  : "+AnsiString(FilePath));
             Log->Write("FilePath2 : "+AnsiString(FilePath2));
             Log->Write("Newest version of this file");
             }
replace = false;
}
开发者ID:unuservize,项目名称:Updater,代码行数:86,代码来源:TFolderCheck.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TFileText类代码示例发布时间:2022-05-31
下一篇:
C++ TFilePathSet类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap