/** Opens an input file, trying multiple times if necessary. */ FArchive* OpenInputFile() { FArchive* InputFile = nullptr; bool bFirstOpenTry = true; while(!InputFile && !GIsRequestingExit) { // Try to open the input file that we are going to process if (CommunicationMode == ThroughFile) { InputFile = IFileManager::Get().CreateFileReader(*InputFilePath,FILEREAD_Silent); } else { #if PLATFORM_SUPPORTS_NAMED_PIPES check(IsUsingNamedPipes()); //UE_LOG(LogShaders, Log, TEXT("Opening Pipe %s\n"), *InputFilePath); //FPlatformMisc::LowLevelOutputDebugStringf(TEXT("*** Trying to open pipe %s\n"), *InputFilePath); if (Pipe.Create(InputFilePath, false, false)) { //FPlatformMisc::LowLevelOutputDebugStringf(TEXT("\tOpened!!!\n")); // Read the total number of bytes int32 TransferSize = 0; VerifyResult(Pipe.ReadInt32(TransferSize)); // Prealloc and read the full buffer TransferBufferIn.Empty(TransferSize); TransferBufferIn.AddUninitialized(TransferSize); //UE_LOG(LogShaders, Log, TEXT("Reading Buffer\n")); VerifyResult(Pipe.ReadBytes(TransferSize, TransferBufferIn.GetData())); return new FMemoryReader(TransferBufferIn); } double DeltaTime = FPlatformTime::Seconds(); if (DeltaTime - LastConnectionTime > 20.0f) { // If can't connect for more than 20 seconds, let's exit FPlatformMisc::RequestExit(false); } #endif // PLATFORM_SUPPORTS_NAMED_PIPES } if(!InputFile && !bFirstOpenTry) { CheckExitConditions(); // Give up CPU time while we are waiting FPlatformProcess::Sleep(0.01f); } bFirstOpenTry = false; } return InputFile; }
/** Opens an input file, trying multiple times if necessary. */ FArchive* OpenInputFile() { FArchive* InputFile = nullptr; bool bFirstOpenTry = true; while(!InputFile && !GIsRequestingExit) { // Try to open the input file that we are going to process if (CommunicationMode == ThroughFile) { InputFile = IFileManager::Get().CreateFileReader(*InputFilePath,FILEREAD_Silent); } if(!InputFile && !bFirstOpenTry) { CheckExitConditions(); // Give up CPU time while we are waiting FPlatformProcess::Sleep(0.01f); } bFirstOpenTry = false; } return InputFile; }