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; }
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; }