X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmDicomDir.cxx;h=6f80dfce2b7d19b98e1c92d63edf93ca73365ad9;hb=c5618e6b8276e1b21bbea354fe8bcba3c78eb4bd;hp=44214cbbabed77204625747e3d4144cb705e8df6;hpb=81e328d78c2028a7c2ecb86e6cee04839f4d56b2;p=gdcm.git diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index 44214cbb..6f80dfce 100644 --- a/src/gdcmDicomDir.cxx +++ b/src/gdcmDicomDir.cxx @@ -74,10 +74,10 @@ gdcmDicomDir::gdcmDicomDir(const char *FileName, bool parseDir, if(strlen(FileName)==1 && FileName[0]=='.') { // user passed '.' as Name // we get current directory name - char*dummy=(char*) malloc(1000); - getcwd(dummy,(size_t)1000); + char* dummy= new char[1000]; + getcwd(dummy, (size_t)1000); SetFileName(dummy); // will be converted into a string - free(dummy); // no longer needed + delete[] dummy; // no longer needed } if(parseDir) @@ -307,29 +307,26 @@ bool gdcmDicomDir::Write(std::string fileName) return(false); } - char * filePreamble; - filePreamble=(char*)calloc(128,1); + char * filePreamble = new char[128]; fwrite(filePreamble,128,1,fp1); fwrite("DICM",4,1,fp1); - free(filePreamble); + delete[] filePreamble; UpdateDirectoryRecordSequenceLength(); - WriteDicomDirEntries(fp1); + WriteEntries(fp1); fclose(fp1); return true; } /** - * \ingroup gdcmParser - * \brief writes on disc according to the DICOMDIR format - * using the tree-like structure + * \brief Writes in a file using the tree-like structure. * @param _fp already open file pointer */ -void gdcmDicomDir::WriteDicomDirEntries(FILE *_fp) +void gdcmDicomDir::WriteEntries(FILE *_fp) { - // TODO (?) tester les echecs en ecriture - // (apres chaque fwrite, dans le WriteEntry) + /// \todo (?) tester les echecs en ecriture + /// (apres chaque fwrite, dans le WriteEntry) gdcmDicomDirMeta *ptrMeta; ListDicomDirPatient::iterator itPatient; @@ -448,13 +445,13 @@ void gdcmDicomDir::CheckBoundaries() itImage = ((*itSerie)->GetDicomDirImages()).begin(); while (itImage != (*itSerie)->GetDicomDirImages().end() ) { (*itImage)->ResetBoundaries(1); - ++itImage; - } - ++itSerie; - } - ++itStudy; - } - ++itPatient; + ++itImage; + } + ++itSerie; + } + ++itStudy; + } + ++itPatient; } } @@ -644,6 +641,9 @@ void gdcmDicomDir::AddObjectToEnd(gdcmDicomDirType type,ListTag::iterator begin, case gdcmDicomDir::GDCM_DICOMDIR_IMAGE: AddDicomDirImageToEnd(begin,end); break; + case gdcmDicomDir::GDCM_DICOMDIR_NONE: + AddDicomDirImageToEnd(begin,end); //FIXME + break; } } @@ -931,7 +931,8 @@ void gdcmDicomDir::UpdateDirectoryRecordSequenceLength() { offset += 4; // delimiters don't have a value. } } - bool res=SetEntryLengthByNumber(offset, 0x0004, 0x1220); // Hope there is no dupps. + //bool res=SetEntryLengthByNumber(offset, 0x0004, 0x1220); // Hope there is no dupps. + SetEntryLengthByNumber(offset, 0x0004, 0x1220); // Hope there is no dupps. return; }