bool MeshLoaderB3D::Load(const char* file) { _file = new lfFile; if( !_file->Open(file) ) return false; _mesh = new Mesh; lfStr head = ReadChunk(); int nB3DVersion = _file->ReadInt(); Sys_Printf("load b3d file %s, version %s %d\n", file, head.c_str(), nB3DVersion); while( CheckSize() ) { lfStr t = ReadChunk(); if (t == "TEXS") ReadTexs(); else if (t == "BRUS") ReadBrus(); else if (t == "NODE") _mesh->SetJoint(ReadNode()); ExitChunk(); } delete _file; _file = NULL; // The MESH chunk describes a mesh. // A mesh only has one VRTS chunk, but potentially many TRIS chunks. srfTriangles_t* tri = _mesh->GetGeometries(0); tri->numIndices = _indices.size(); _indices.set_free_when_destroyed(false); tri->indices = _indices.pointer(); return true; }
void MeshLoaderB3D::ReadBrus() { int n_texs; _file->ReadInt(n_texs); if( n_texs<0 || n_texs>8 ){ printf( "Bad texture count" ); } while( CheckSize() ){ idStr name; readString(_file, name); PrintTree(name.c_str()); idVec3 color; _file->ReadVec3(color); float alpha; _file->ReadFloat(alpha); float shiny; _file->ReadFloat(shiny); int blend; /*int blend=**/_file->ReadInt(blend); int fx; _file->ReadInt(fx); //Textures for( int i=0;i<n_texs;++i ){ int texid; _file->ReadInt(texid); } } }
// ------------------------------------------------ // LogLit // ------------------------------------------------ // void CMdSLogger::LogLit( const TDesC8& aText ) { if (!iValid) { return; } TInt offset = 0; TInt linecount = 0; TInt length = aText.Length(); while( offset < length ) { TInt partLength = Min( length-offset, KLineLength ); #ifdef MDE_FILE_LOGGING iLog.Write( aText.Mid( offset, partLength ) ); #else TBuf<KLineLength> buffer; buffer.Copy( aText.Mid( offset, partLength ) ); RDebug::Print( buffer ); #endif ++linecount; offset += partLength; } CheckSize( linecount ); }
static BOOL CopySections(const unsigned char *data, size_t size, PIMAGE_NT_HEADERS old_headers, PMEMORYMODULE module) { int i, section_size; unsigned char *codeBase = module->codeBase; unsigned char *dest; PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION(module->headers); for (i=0; i<module->headers->FileHeader.NumberOfSections; i++, section++) { if (section->SizeOfRawData == 0) { // section doesn't contain data in the dll itself, but may define // uninitialized data section_size = old_headers->OptionalHeader.SectionAlignment; if (section_size > 0) { dest = (unsigned char *)module->alloc(codeBase + section->VirtualAddress, section_size, MEM_COMMIT, PAGE_READWRITE, module->userdata); if (dest == NULL) { return FALSE; } // Always use position from file to support alignments smaller // than page size (allocation above will align to page size). dest = codeBase + section->VirtualAddress; // NOTE: On 64bit systems we truncate to 32bit here but expand // again later when "PhysicalAddress" is used. section->Misc.PhysicalAddress = (DWORD) ((uintptr_t) dest & 0xffffffff); memset(dest, 0, section_size); } // section is empty continue; } if (!CheckSize(size, section->PointerToRawData + section->SizeOfRawData)) { return FALSE; } // commit memory block and copy data from dll dest = (unsigned char *)module->alloc(codeBase + section->VirtualAddress, section->SizeOfRawData, MEM_COMMIT, PAGE_READWRITE, module->userdata); if (dest == NULL) { return FALSE; } // Always use position from file to support alignments smaller // than page size (allocation above will align to page size). dest = codeBase + section->VirtualAddress; memcpy(dest, data + section->PointerToRawData, section->SizeOfRawData); // NOTE: On 64bit systems we truncate to 32bit here but expand // again later when "PhysicalAddress" is used. section->Misc.PhysicalAddress = (DWORD) ((uintptr_t) dest & 0xffffffff); } return TRUE; }
void ff::Dict::SetValue(ff::StringRef name, ff::Value *value) { if (value) { if (_propsLarge != nullptr) { hash_t hash = GetAtomizer().CacheString(name); _propsLarge->SetKey(hash, value); } else { _propsSmall.Set(name, value); CheckSize(); } } else if (_propsLarge != nullptr) { hash_t hash = GetAtomizer().CacheString(name); _propsLarge->DeleteKey(hash); } else { _propsSmall.Remove(name); } }
void MeshLoaderB3D::ReadKey(Joint* joint) { int flags = _file->ReadInt(); while( CheckSize() ){ int frame = _file->ReadInt(); if (flags & 1){ PositionKey k; k.position = _file->ReadVec3(); k.frame = frame; joint->positionKeys.push_back(k); } if( flags & 2 ){ ScaleKey k; k.position = _file->ReadVec3(); k.frame = frame; joint->scaleKeys.push_back(k); } if( flags & 4 ){ Quat r = _file->ReadQuat(); r.w = -r.w; // fix bug RotationKey k; k.rotation = r; k.frame = frame; joint->rotationKeys.push_back(k); } } }
static void test_misc(HWND parent_wnd, INT nTabs) { HWND hTab; RECT rTab; INT nTabsRetrieved; INT rowCount; INT dpi; HDC hdc; ok(parent_wnd != NULL, "no parent window!\n"); flush_sequences(sequences, NUM_MSG_SEQUENCES); hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, nTabs); ok(hTab != NULL, "Failed to create tab control\n"); if(!winetest_interactive) ok_sequence(sequences, TAB_SEQ_INDEX, add_tab_to_parent, "Tab sequence, after adding tab control to parent", TRUE); else ok_sequence(sequences, TAB_SEQ_INDEX, add_tab_to_parent_interactive, "Tab sequence, after adding tab control to parent", TRUE); if(!winetest_interactive) ok_sequence(sequences, PARENT_SEQ_INDEX, add_tab_control_parent_seq, "Parent after sequence, adding tab control to parent", TRUE); else ok_sequence(sequences, PARENT_SEQ_INDEX, add_tab_control_parent_seq_interactive, "Parent after sequence, adding tab control to parent", TRUE); flush_sequences(sequences, NUM_MSG_SEQUENCES); ok(SendMessage(hTab, TCM_SETMINTABWIDTH, 0, -1) > 0,"TCM_SETMINTABWIDTH returned < 0\n"); ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Set minTabWidth test parent sequence", FALSE); /* Testing GetItemCount */ flush_sequences(sequences, NUM_MSG_SEQUENCES); nTabsRetrieved = SendMessage(hTab, TCM_GETITEMCOUNT, 0, 0); expect(nTabs, nTabsRetrieved); ok_sequence(sequences, TAB_SEQ_INDEX, get_item_count_seq, "Get itemCount test sequence", FALSE); ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Getset itemCount test parent sequence", FALSE); /* Testing GetRowCount */ flush_sequences(sequences, NUM_MSG_SEQUENCES); rowCount = SendMessage(hTab, TCM_GETROWCOUNT, 0, 0); expect(1, rowCount); ok_sequence(sequences, TAB_SEQ_INDEX, get_row_count_seq, "Get rowCount test sequence", FALSE); ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Get rowCount test parent sequence", FALSE); /* Testing GetItemRect */ flush_sequences(sequences, NUM_MSG_SEQUENCES); ok(SendMessage(hTab, TCM_GETITEMRECT, 0, (LPARAM) &rTab), "GetItemRect failed.\n"); hdc = GetDC(hTab); dpi = GetDeviceCaps(hdc, LOGPIXELSX); ReleaseDC(hTab, hdc); CheckSize(hTab, dpi, -1 , "Default Width"); ok_sequence(sequences, TAB_SEQ_INDEX, get_item_rect_seq, "Get itemRect test sequence", FALSE); ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Get itemRect test parent sequence", FALSE); DestroyWindow(hTab); }
void TSessionLog::DoAddToSelf(TLogLineType Type, UnicodeString ALine) { if (LogToFile()) { try { if (FLogger == nullptr) { OpenLogFile(); } if (FLogger != nullptr) { UnicodeString Timestamp = FormatDateTime(L" yyyy-mm-dd hh:nn:ss.zzz ", Now()); UTF8String UtfLine = UTF8String(UnicodeString(LogLineMarks[Type]) + Timestamp + TrimRight(ALine)) + "\r\n"; #if 0 for (intptr_t Index = 1; Index <= UtfLine.Length(); Index++) { if ((UtfLine[Index] == '\n') && (UtfLine[Index - 1] != '\r')) { UtfLine.Insert(L'\r', Index); } } #endif // #if 0 intptr_t ToWrite = UtfLine.Length(); CheckSize(ToWrite); FCurrentFileSize += FLogger->Write(UtfLine.c_str(), ToWrite); }} catch (...) { // TODO: log error DEBUG_PRINTF("TSessionLog::DoAddToSelf: error"); } } }
void Auddrv_UL_Interrupt_Handler(void) // irq1 ISR handler { unsigned long flags; kal_uint32 Afe_Dac_Con0 = Afe_Get_Reg(AFE_DAC_CON0); AFE_MEM_CONTROL_T *Mem_Block = &VUL_Control_context; AFE_BLOCK_T *Vul_Block = &(VUL_Control_context.rBlock); //printk("Auddrv_UL_Interrupt_Handler \n "); kal_uint32 HW_Cur_ReadIdx = 0; kal_int32 Hw_Get_bytes = 0; AFE_BLOCK_T *mBlock = NULL; if (Mem_Block == NULL) { printk("Mem_Block == NULL \n "); return; } mBlock = &Mem_Block->rBlock; HW_Cur_ReadIdx = Afe_Get_Reg(AFE_VUL_CUR); //printk("Auddrv_UL_Interrupt_Handler HW_Cur_ReadIdx = 0x%x\n ", HW_Cur_ReadIdx); if (CheckSize(HW_Cur_ReadIdx)) { return; } if (mBlock->pucVirtBufAddr == NULL) { return; } // HW already fill in Hw_Get_bytes = (HW_Cur_ReadIdx - mBlock->pucPhysBufAddr) - mBlock->u4WriteIdx; if (Hw_Get_bytes < 0) { Hw_Get_bytes += mBlock->u4BufferSize; } /* printk("Auddrv_Handle_Mem_context Hw_Get_bytes:%x, HW_Cur_ReadIdx:%x, u4DMAReadIdx:%x, u4WriteIdx:0x%x, pucPhysBufAddr:%x Mem_Block->MemIfNum = %d \n", Hw_Get_bytes, HW_Cur_ReadIdx, mBlock->u4DMAReadIdx, mBlock->u4WriteIdx, mBlock->pucPhysBufAddr, Mem_Block->MemIfNum);*/ mBlock->u4WriteIdx += Hw_Get_bytes; mBlock->u4WriteIdx %= mBlock->u4BufferSize; mBlock->u4DataRemained += Hw_Get_bytes; // buffer overflow if (mBlock->u4DataRemained > mBlock->u4BufferSize) { printk("Auddrv_Handle_Mem_context buffer overflow u4DMAReadIdx:%x, u4WriteIdx:%x, u4DataRemained:%x, u4BufferSize:%x \n", mBlock->u4DMAReadIdx, mBlock->u4WriteIdx, mBlock->u4DataRemained, mBlock->u4BufferSize); mBlock->u4DataRemained = mBlock->u4BufferSize / 2; mBlock->u4DMAReadIdx = mBlock->u4WriteIdx - mBlock->u4BufferSize / 2; if (mBlock->u4DMAReadIdx < 0) { mBlock->u4DMAReadIdx += mBlock->u4BufferSize; } } snd_pcm_period_elapsed(prtdtemp->substream); InterruptTrigger = 1; }
MemStream::MemStream( size_t sz0 ) { pos = 0; len = 0; maxLen = len; data = NULL; CheckSize(sz0); }
void ListedTextItems::Insert(const Text& text) { __Item item; item._caption = text; item._state = 0; _items.Insert(item); CheckSize(text); }
static void TabCheckSetSize(HWND hwnd, INT set_width, INT set_height, INT exp_width, INT exp_height, const char *msg, int line) { SendMessage(hwnd, TCM_SETITEMSIZE, 0, (LPARAM) MAKELPARAM((set_width >= 0) ? set_width : 0, (set_height >= 0) ? set_height : 0)); if (winetest_interactive) RedrawWindow (hwnd, NULL, 0, RDW_UPDATENOW); CheckSize(hwnd, exp_width, exp_height, msg, line); }
void ListedTextItems::SetText( int item_no, const Text &text ) { if ( item_no >=0 && item_no<GetNumItems() ) { GetItem(item_no)._caption=text; CheckSize(text); } }
int CTextureManager::LoadTextureFromMemory (UBYTE *pData, int nWidth, int nHeight, int nBPP, int nTextureID) { // First we do ALOT of error checking on the data... if (!CheckSize (nWidth) || !CheckSize (nHeight)) { sprintf (m_Singleton->szErrorMessage, "ERROR : Improper Dimension"); return -1; } if (nBPP != 3 && nBPP != 4) { sprintf (m_Singleton->szErrorMessage, "ERROR : Unsuported Color Depth"); return -1; } // I guess were good to go... // --------------------------------------------------------------------- int nNewTextureID = GetNewTextureID (nTextureID); // Also increases nNumTextures! // Register and upload the texture in OpenGL glBindTexture (GL_TEXTURE_2D, nNewTextureID); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); //Method1 //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, nWidth, nHeight, 0, nBPP == 3 ? GL_BGR_EXT : GL_BGRA_EXT, GL_UNSIGNED_BYTE, pData); //Method2 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, nWidth, nHeight, 0, nBPP == 3 ? GL_BGR_EXT : GL_BGRA_EXT, GL_UNSIGNED_BYTE, NULL); glTexSubImage2D(GL_TEXTURE_2D, 0, 0,0,nWidth, nHeight, nBPP == 3 ? GL_BGR_EXT : GL_BGRA_EXT,GL_UNSIGNED_BYTE, pData); //Method3 //gluBuild2DMipmaps (GL_TEXTURE_2D, // nBPP, nWidth, nHeight, // (nBPP == 3 ? GL_RGB : GL_RGBA), // GL_UNSIGNED_BYTE, // pData); // --------------------------------------------------------------------- // delete [] pData; // Leave memory clearing upto the caller... sprintf (m_Singleton->szErrorMessage, "Loaded Some Memory Perfectly!"); return nNewTextureID; }
kexStr &kexStr::operator=(const char *str) { int len = strlen(str); CheckSize(len+1, false); strncpy(charPtr, str, len); length = len; charPtr[length] = '\0'; return *this; }
void* TRI_AllocateZ (TRI_memory_zone_t* zone, uint64_t n, bool set, char const* file, int line) { #else void* TRI_Allocate (TRI_memory_zone_t* zone, uint64_t n, bool set) { #endif char* m; #ifdef TRI_ENABLE_MAINTAINER_MODE CheckSize(n, file, line); m = MALLOC_WRAPPER(zone, (size_t) n + sizeof(uintptr_t)); #else m = MALLOC_WRAPPER(zone, (size_t) n); #endif if (m == NULL) { if (zone->_failable) { TRI_set_errno(TRI_ERROR_OUT_OF_MEMORY); return NULL; } if (CoreReserve == NULL) { fprintf(stderr, "FATAL: failed to allocate %llu bytes for memory zone %d" ZONE_DEBUG_LOCATION ", giving up!\n", (unsigned long long) n, (int) zone->_zid ZONE_DEBUG_PARAMS); TRI_EXIT_FUNCTION(EXIT_FAILURE, NULL); } free(CoreReserve); CoreReserve = NULL; fprintf(stderr, "failed to allocate %llu bytes for memory zone %d" ZONE_DEBUG_LOCATION ", retrying!\n", (unsigned long long) n, (int) zone->_zid ZONE_DEBUG_PARAMS); #ifdef TRI_ENABLE_MAINTAINER_MODE return TRI_AllocateZ(zone, n, set, file, line); #else return TRI_Allocate(zone, n, set); #endif } #ifdef TRI_ENABLE_MAINTAINER_MODE else if (set) { memset(m, 0, (size_t) n + sizeof(uintptr_t)); } else { // prefill with 0xA5 (magic value, same as Valgrind will use) memset(m, 0xA5, (size_t) n + sizeof(uintptr_t)); } #else else if (set) {
static BOOL CopySections(const unsigned char *data, size_t size, PIMAGE_NT_HEADERS old_headers, PMEMORYMODULE module) { int i, section_size; unsigned char *codeBase = module->codeBase; unsigned char *dest; PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION(module->headers); for (i=0; i<module->headers->FileHeader.NumberOfSections; i++, section++) { if (section->SizeOfRawData == 0) { // section doesn't contain data in the dll itself, but may define // uninitialized data section_size = old_headers->OptionalHeader.SectionAlignment; if (section_size > 0) { dest = (unsigned char *)VirtualAlloc(codeBase + section->VirtualAddress, section_size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); if (dest == NULL) { return FALSE; } // Always use position from file to support alignments smaller // than page size. dest = codeBase + section->VirtualAddress; section->Misc.PhysicalAddress = (DWORD) (uintptr_t) dest; memset(dest, 0, section_size); } // section is empty continue; } if (size && !CheckSize(size, section->PointerToRawData + section->SizeOfRawData)) { return FALSE; } // commit memory block and copy data from dll dest = (unsigned char *)VirtualAlloc(codeBase + section->VirtualAddress, section->SizeOfRawData, MEM_COMMIT, PAGE_EXECUTE_READWRITE); if (dest == NULL) { return FALSE; } // Always use position from file to support alignments smaller // than page size. dest = codeBase + section->VirtualAddress; memcpy(dest, data + section->PointerToRawData, section->SizeOfRawData); section->Misc.PhysicalAddress = ((DWORD)(((POINTER_TYPE)(dest)) & 0xffffffff)); } return TRUE; }
kexStr &kexStr::Concat(const char *string, int len) { CheckSize((length + len)+1, true); for(int i = 0; i < len; i++) { charPtr[length+i] = string[i]; } length += len; charPtr[length] = '\0'; return *this; }
kexStr &kexStr::Copy(const kexStr &src, int len) { int i = 0; const char *p = src; CheckSize((length + len)+1, true); while((len--) >= 0) { charPtr[i] = p[i]; i++; } return *this; }
void MeshLoaderB3D::ReadBone( Joint* joint ) { int i = 0; while( CheckSize() ){ int vertex = _file->ReadInt(); float weight = _file->ReadFloat(); joint->vertexIndices.push_back(vertex); joint->vertexWeights.push_back(weight); i++; } PrintTree("vertex count: %d", i); }
kexStr &kexStr::StripExtension(void) { int pos = IndexOf("."); if(pos == -1) return *this; length = pos; CheckSize(length, true); charPtr[length] = '\0'; return *this; }
void* TRI_AllocateZ(TRI_memory_zone_t* zone, uint64_t n, bool set, char const* file, int line) { #else void* TRI_Allocate(TRI_memory_zone_t* zone, uint64_t n, bool set) { #endif #ifdef ARANGODB_ENABLE_MAINTAINER_MODE CheckSize(n, file, line); #endif char* m = static_cast<char*>(MALLOC_WRAPPER(zone, (size_t)n)); if (m == nullptr) { if (zone->_failable) { TRI_set_errno(TRI_ERROR_OUT_OF_MEMORY); return nullptr; } if (CoreReserve == nullptr) { fprintf(stderr, "FATAL: failed to allocate %llu bytes for core mem zone " ZONE_DEBUG_LOCATION ", giving up!\n", (unsigned long long)n ZONE_DEBUG_PARAMS); TRI_EXIT_FUNCTION(EXIT_FAILURE, nullptr); } free(CoreReserve); CoreReserve = nullptr; fprintf( stderr, "failed to allocate %llu bytes for core mem zone" ZONE_DEBUG_LOCATION ", retrying!\n", (unsigned long long)n ZONE_DEBUG_PARAMS); #ifdef ARANGODB_ENABLE_MAINTAINER_MODE return TRI_AllocateZ(zone, n, set, file, line); #else return TRI_Allocate(zone, n, set); #endif } if (set) { memset(m, 0, (size_t)n); } #ifdef ARANGODB_ENABLE_MAINTAINER_MODE else { // prefill with 0xA5 (magic value, same as Valgrind will use) memset(m, 0xA5, (size_t)n); } #endif return m; }
void MeshLoaderB3D::ReadMesh() { /*int matid=*/_file->ReadInt(); //printTree("mesh"); while( CheckSize() ){ lfStr t = ReadChunk(); if( t=="VRTS" ){ ReadVrts(); }else if( t=="TRIS" ){ ReadTris(); } ExitChunk(); } }
void CRehldsFlightRecorder::WriteBuffer(const void* data, unsigned int len) { if (m_pRecorderState->curMessage == 0) { rehlds_syserror("%s: Could not write, invalid state", __FUNCTION__); } CheckSize(len); unsigned int freeSz = DATA_REGION_MAIN_SIZE - m_pRecorderState->wpos; if (freeSz < len) { MoveToStart(); } memcpy(m_DataRegionPtr + m_pRecorderState->wpos, data, len); m_pRecorderState->wpos += len; }
void CDataPack::PackCell(cell cells) { CheckSize(sizeof(char) + sizeof(size_t) + sizeof(cell)); *(char *)m_curptr = DataPackType::Cell; m_curptr += sizeof(char); *(size_t *)m_curptr = sizeof(cell); m_curptr += sizeof(size_t); *(cell *)m_curptr = cells; m_curptr += sizeof(cell); m_size += sizeof(char) + sizeof(size_t) + sizeof(cell); }
void CDataPack::PackFloat(float val) { CheckSize(sizeof(char) + sizeof(size_t) + sizeof(float)); *(char *)m_curptr = DataPackType::Float; m_curptr += sizeof(char); *(size_t *)m_curptr = sizeof(float); m_curptr += sizeof(size_t); *(float *)m_curptr = val; m_curptr += sizeof(float); m_size += sizeof(char) + sizeof(size_t) + sizeof(float); }
void MeshLoaderB3D::ReadTexs() { while (CheckSize()) { PrintTree("read texs \n"); SB3dTexture tex; tex.TextureName = _file->ReadString(); tex.Flags = _file->ReadInt(); tex.Blend = _file->ReadInt(); tex.Xpos = _file->ReadFloat(); tex.Ypos = _file->ReadFloat(); tex.Xscale = _file->ReadFloat(); tex.Yscale = _file->ReadFloat(); tex.Angle = _file->ReadFloat(); _textures.push_back(tex); } }
BOOL FixSize(int *cy, int displayHeight) { int nCy = *cy; int checkResult = CheckSize(nCy, displayHeight); if (checkResult == CHECKRESULT_NORMALSIZE) { *cy = displayHeight - sizeSoftkeyBar - sizeStatusBar; return TRUE; } else if (checkResult == CHECKRESULT_FULLSCREEN) { *cy = displayHeight - sizeStatusBar; return TRUE; } return FALSE; };
void MeshLoaderB3D::ReadTexs() { while (CheckSize()) { PrintTree("read texs \n"); SB3dTexture tex; readString(_file, tex.TextureName); _file->ReadInt(tex.Flags); _file->ReadInt(tex.Blend); _file->ReadFloat(tex.Xpos); _file->ReadFloat(tex.Ypos); _file->ReadFloat(tex.Xscale); _file->ReadFloat(tex.Yscale); _file->ReadFloat(tex.Angle); _textures.Insert(tex); } }
void TSessionLog::OpenLogFile() { DebugAssert(FConfiguration != nullptr); if (!FConfiguration) return; try { DebugAssert(FLogger == nullptr); FCurrentLogFileName = FConfiguration->GetLogFileName(); FILE *file = LocalOpenLogFile(FCurrentLogFileName, FStarted, FSessionData, FConfiguration->GetLogFileAppend(), FCurrentFileName); FLogger = new tinylog::TinyLog(file); TSearchRec SearchRec; if (FileSearchRec(FCurrentFileName, SearchRec)) { FCurrentFileSize = SearchRec.Size; } else { FCurrentFileSize = 0; } } catch (Exception &E) { // We failed logging to file, turn it off and notify user. FCurrentLogFileName.Clear(); FCurrentFileName.Clear(); FConfiguration->SetLogFileName(UnicodeString()); try { throw ExtException(&E, LoadStr(LOG_GEN_ERROR)); } catch (Exception &E2) { AddException(&E2); // not to deadlock with TSessionLog::ReflectSettings invoked by FConfiguration->LogFileName setter above TUnguard Unguard(FCriticalSection); FUI->HandleExtendedException(&E2); } } // in case we are appending and the existing log file is already too large if (FLogger != nullptr) { CheckSize(0); } }