@@ -536,14 +536,15 @@ namespace Isis {
536536 core.addGroup (ptype);
537537 }
538538 else if (labelsAttached () == LabelAttachment::ExternalLabel) {
539+ imageFile = imageFile.addExtension (" ecub" );
539540 if (!m_dataFileName) {
540541 if (format () == Bsq || format () == Tile) {
541- imageFile = imageFile.addExtension (" cub" );
542+ imageFile = imageFile.setExtension (" cub" );
542543
543544 Pvl dnLabel;
544545 PvlObject isiscube (" IsisCube" );
545546 PvlObject dnCore (core);
546- PvlKeyword fileFormat (" Format" , toString (format ()));
547+ PvlKeyword fileFormat (" Format" , CubeAttributeOutput:: toString (format ()));
547548
548549 dnCore.addKeyword (fileFormat);
549550 dnCore.addGroup (dims);
@@ -555,13 +556,11 @@ namespace Isis {
555556 Cube dnCube;
556557 dnCube.fromLabel (imageFile, dnLabel, " rw" );
557558 dnCube.close ();
558-
559- m_dataFileName = new FileName (imageFile);
560559 }
561560 else if (format () == Format::GTiff) {
562- imageFile = imageFile.setExtension (" tiff" );
563- m_dataFileName = new FileName (imageFile);
561+ imageFile = imageFile.setExtension (" tif" );
564562 }
563+ m_dataFileName = new FileName (imageFile);
565564
566565 imageFile = imageFile.setExtension (" ecub" );
567566 FileName labelFileName (imageFile);
@@ -815,9 +814,9 @@ namespace Isis {
815814 GDALDriverH hDriver = GDALIdentifyDriver (FileName (cubeFileName).expanded ().toStdString ().c_str (), nullptr );
816815 bool openWithGdal = false ;
817816 if (hDriver != nullptr ) {
818- GDALDriver* poDriver = (GDALDriver*)hDriver;
819- QString driverDescription = poDriver->GetDescription ();
820- openWithGdal = driverDescription == QString (" GTiff" );
817+ GDALDriver* poDriver = (GDALDriver*)hDriver;
818+ QString driverDescription = poDriver->GetDescription ();
819+ openWithGdal = driverDescription == QString (" GTiff" );
821820 }
822821
823822 try {
@@ -1241,7 +1240,9 @@ namespace Isis {
12411240 // maxbyte = position after the cube DN data and labels
12421241 streampos maxbyte = (streampos) m_labelBytes;
12431242
1244- maxbyte += (streampos) m_ioHandler->getDataSize ();
1243+ if (labelsAttached () != ExternalLabel) {
1244+ maxbyte += (streampos) m_ioHandler->getDataSize ();
1245+ }
12451246
12461247 // If EOF is too early, allocate space up to where we want the blob
12471248 if (endByte < maxbyte) {
0 commit comments