Skip to content

Commit 6814b65

Browse files
committed
Added check of "writeMode" to write() method.
Added check of "writeMode" parameter to DcmFileFormat::write() method, so that only a dataset (without meta header) is written if its value is EWM_dataset, i.e. if requested by the caller. This behavior is now consistent with the DcmFileFormat::saveFile() method. Thanks to Mathieu Malaterre <mathieu.malaterre@gmail.com> for the original report on this issue.
1 parent b950427 commit 6814b65

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

dcmdata/libsrc/dcdatset.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -471,11 +471,10 @@ OFCondition DcmDataset::readUntilTag(DcmInputStream &inStream,
471471
// ********************************
472472

473473

474-
OFCondition DcmDataset::write(
475-
DcmOutputStream &outStream,
476-
const E_TransferSyntax oxfer,
477-
const E_EncodingType enctype /* = EET_UndefinedLength */,
478-
DcmWriteCache *wcache)
474+
OFCondition DcmDataset::write(DcmOutputStream &outStream,
475+
const E_TransferSyntax oxfer,
476+
const E_EncodingType enctype /* = EET_UndefinedLength */,
477+
DcmWriteCache *wcache)
479478
{
480479
return write(outStream, oxfer, enctype, wcache, EGL_recalcGL);
481480
}

dcmdata/libsrc/dcfilefo.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,12 @@ OFCondition DcmFileFormat::write(DcmOutputStream &outStream,
843843
* in the file meta information header.
844844
*/
845845
{
846+
/* write as dataset (without meta header) */
847+
if (writeMode == EWM_dataset)
848+
{
849+
return getDataset()->write(outStream, oxfer, enctype, wcache, glenc,
850+
padenc, padlen, subPadlen, instanceLength);
851+
}
846852
/* if the transfer state of this is not initialized, this is an illegal call */
847853
if (getTransferState() == ERW_notInitialized)
848854
errorFlag = EC_IllegalCall;
@@ -1001,6 +1007,7 @@ OFCondition DcmFileFormat::saveFile(const OFFilename &fileName,
10011007
const Uint32 subPadLength,
10021008
const E_FileWriteMode writeMode)
10031009
{
1010+
/* save as dataset (without meta header) */
10041011
if (writeMode == EWM_dataset)
10051012
{
10061013
return getDataset()->saveFile(fileName, writeXfer, encodingType, groupLength,

0 commit comments

Comments
 (0)