diff --git a/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C b/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C index 2796a2c3ca3e9a41b682732af83a788c7157119f..4100e51f12d30021380d14877846a00e47f84517 100644 --- a/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C +++ b/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017-2018 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -774,7 +774,7 @@ masterUncollatedFileOperation if (verbose) { - Info + DetailInfo << "I/O : " << typeName << " (maxMasterFileBufferSize " << maxMasterFileBufferSize << ')' << endl; @@ -820,7 +820,7 @@ masterUncollatedFileOperation if (verbose) { - Info + DetailInfo << "I/O : " << typeName << " (maxMasterFileBufferSize " << maxMasterFileBufferSize << ')' << endl; @@ -2415,6 +2415,8 @@ Foam::fileOperations::masterUncollatedFileOperation::NewIFstream const fileName& filePath ) const { + autoPtr<ISstream> isPtr; + if (Pstream::parRun()) { // Insert logic of filePath. We assume that if a file is absolute @@ -2497,10 +2499,7 @@ Foam::fileOperations::masterUncollatedFileOperation::NewIFstream if (Pstream::master(Pstream::worldComm)) { // Read myself - return autoPtr<ISstream> - ( - new IFstream(filePaths[Pstream::masterNo()]) - ); + isPtr.reset(new IFstream(filePaths[Pstream::masterNo()])); } else { @@ -2522,26 +2521,21 @@ Foam::fileOperations::masterUncollatedFileOperation::NewIFstream << " Done reading " << buf.size() << " bytes" << endl; } - // Note: IPstream is not an IStream so use a IStringStream to - // convert the buffer. Note that we construct with a string - // so it holds a copy of the buffer. - return autoPtr<ISstream> - ( - new IListStream - ( - std::move(buf), - IOstream::BINARY, - IOstream::currentVersion, - filePath - ) - ); + // A local character buffer copy of the Pstream contents. + // Construct with same parameters (ASCII, current version) + // as the IFstream so that it has the same characteristics. + + isPtr.reset(new IListStream(std::move(buf))); + isPtr->name() = filePath; // Assign the proper file name } } else { // Read myself - return autoPtr<ISstream>(new IFstream(filePath)); + isPtr.reset(new IFstream(filePath)); } + + return isPtr; }