mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: file format mangled by collated format (fixes #1587)
- incorrectly set BINARY format in the construction of the received data (a side-effect of the parameter ordering). Now use the same default parameters as IFstream and set the correct filename subsequent to construction.
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2018 OpenFOAM Foundation
|
Copyright (C) 2017-2018 OpenFOAM Foundation
|
||||||
Copyright (C) 2019 OpenCFD Ltd.
|
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -723,17 +723,15 @@ Foam::fileOperations::masterUncollatedFileOperation::read
|
|||||||
Pout<< "masterUncollatedFileOperation::readStream :"
|
Pout<< "masterUncollatedFileOperation::readStream :"
|
||||||
<< " Done reading " << buf.size() << " bytes" << endl;
|
<< " Done reading " << buf.size() << " bytes" << endl;
|
||||||
}
|
}
|
||||||
const fileName& fName = filePaths[Pstream::myProcNo(comm)];
|
|
||||||
isPtr.reset
|
// A local character buffer copy of the Pstream contents.
|
||||||
(
|
// Construct with same parameters (ASCII, current version)
|
||||||
new IListStream
|
// as the IFstream so that it has the same characteristics.
|
||||||
(
|
|
||||||
std::move(buf),
|
isPtr.reset(new IListStream(std::move(buf)));
|
||||||
IOstream::BINARY,
|
|
||||||
IOstream::currentVersion,
|
// With the proper file name
|
||||||
fName
|
isPtr->name() = filePaths[Pstream::myProcNo(comm)];
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!io.readHeader(isPtr()))
|
if (!io.readHeader(isPtr()))
|
||||||
{
|
{
|
||||||
@ -2415,6 +2413,8 @@ Foam::fileOperations::masterUncollatedFileOperation::NewIFstream
|
|||||||
const fileName& filePath
|
const fileName& filePath
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
|
autoPtr<ISstream> isPtr;
|
||||||
|
|
||||||
if (Pstream::parRun())
|
if (Pstream::parRun())
|
||||||
{
|
{
|
||||||
// Insert logic of filePath. We assume that if a file is absolute
|
// Insert logic of filePath. We assume that if a file is absolute
|
||||||
@ -2497,10 +2497,7 @@ Foam::fileOperations::masterUncollatedFileOperation::NewIFstream
|
|||||||
if (Pstream::master(Pstream::worldComm))
|
if (Pstream::master(Pstream::worldComm))
|
||||||
{
|
{
|
||||||
// Read myself
|
// Read myself
|
||||||
return autoPtr<ISstream>
|
isPtr.reset(new IFstream(filePaths[Pstream::masterNo()]));
|
||||||
(
|
|
||||||
new IFstream(filePaths[Pstream::masterNo()])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2522,26 +2519,23 @@ Foam::fileOperations::masterUncollatedFileOperation::NewIFstream
|
|||||||
<< " Done reading " << buf.size() << " bytes" << endl;
|
<< " Done reading " << buf.size() << " bytes" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: IPstream is not an IStream so use a IStringStream to
|
// A local character buffer copy of the Pstream contents.
|
||||||
// convert the buffer. Note that we construct with a string
|
// Construct with same parameters (ASCII, current version)
|
||||||
// so it holds a copy of the buffer.
|
// as the IFstream so that it has the same characteristics.
|
||||||
return autoPtr<ISstream>
|
|
||||||
(
|
isPtr.reset(new IListStream(std::move(buf)));
|
||||||
new IListStream
|
|
||||||
(
|
// With the proper file name
|
||||||
std::move(buf),
|
isPtr->name() = filePath;
|
||||||
IOstream::BINARY,
|
|
||||||
IOstream::currentVersion,
|
|
||||||
filePath
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Read myself
|
// Read myself
|
||||||
return autoPtr<ISstream>(new IFstream(filePath));
|
isPtr.reset(new IFstream(filePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return isPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user