failed to create dicomdir
Moderator: Moderator Team
failed to create dicomdir
Hi i'm trying to create a dicomdir and having a problem
I'm working with DCMTK 3.5.4 ,VC6.0
here what i'm doing :
{
DicomDirInterface dcmDir;
dcmDir.createNewDicomDir(DicomDirInterface::Ap_Default, "d:\\Temp\\DICOMDIR");
dcmDir.addDicomFile("Image\\Img0001","d:\\Temp");
dcmDir.writeDicomDir()
}
i try to debug ,but an error is found.
I follow up and find that the error is in this function
OFCondition DcmDicomDir::write(const E_TransferSyntax oxfer,
const E_EncodingType enctype,
const E_GrpLenEncoding glenc)
where:
#ifdef HAVE_MKTEMP
mktemp( tempfile );
#endif
DcmOutputFileStream *outStream = new DcmOutputFileStream(tempfile);
the error is the mktemp , do with the tempfile .
what i'm doing wrong ??
I'm working with DCMTK 3.5.4 ,VC6.0
here what i'm doing :
{
DicomDirInterface dcmDir;
dcmDir.createNewDicomDir(DicomDirInterface::Ap_Default, "d:\\Temp\\DICOMDIR");
dcmDir.addDicomFile("Image\\Img0001","d:\\Temp");
dcmDir.writeDicomDir()
}
i try to debug ,but an error is found.
I follow up and find that the error is in this function
OFCondition DcmDicomDir::write(const E_TransferSyntax oxfer,
const E_EncodingType enctype,
const E_GrpLenEncoding glenc)
where:
#ifdef HAVE_MKTEMP
mktemp( tempfile );
#endif
DcmOutputFileStream *outStream = new DcmOutputFileStream(tempfile);
the error is the mktemp , do with the tempfile .
what i'm doing wrong ??
-
- DCMTK Developer
- Posts: 2051
- Joined: Fri, 2004-11-05, 13:47
- Location: Oldenburg, Germany
- Contact:
Hi,
which operating system does the resulting program run on? As we have heard, mktemp is making problems under Vista (maybe also Windows 7) because there mktemp is usually returning a filename in the root directory which then cannot be written (no rights) from the process. Maybe also the working directory (on XP, not sure about that) is also choosen for the temporary filename, be sure it is writeable.
Best regards,
Michael
which operating system does the resulting program run on? As we have heard, mktemp is making problems under Vista (maybe also Windows 7) because there mktemp is usually returning a filename in the root directory which then cannot be written (no rights) from the process. Maybe also the working directory (on XP, not sure about that) is also choosen for the temporary filename, be sure it is writeable.
Best regards,
Michael
-
- DCMTK Developer
- Posts: 2051
- Joined: Fri, 2004-11-05, 13:47
- Location: Oldenburg, Germany
- Contact:
before the mktemp call, tempfile = d:\\Temp\\DDXXXXXX,
then the mktemp call(system func):
then the mktemp call(system func):
Code: Select all
_TSCHAR * __cdecl _tmktemp (
_TSCHAR *template
)
{
_TSCHAR *string = template;
unsigned number;
int letter = _T('a');
int xcount = 0;
int olderrno;
_ASSERTE(template != NULL);
_ASSERTE(*template != _T('\0'));
/*
* The Process ID is not a good choice in multi-threaded programs
* because of the likelihood that two threads might call mktemp()
* almost simultaneously, thus getting the same temporary name.
* Instead, the Win32 Thread ID is used, because it is unique across
* all threads in all processes currently running.
*
* Note, however, that unlike *NIX process IDs, which are not re-used
* until all values up to 32K have been used, Win32 process IDs are
* re-used and tend to always be relatively small numbers. Same for
* thread IDs.
*/
#ifdef _MT
number = __threadid();
#else /* _MT */
number = _getpid();
#endif /* _MT */
while (*string)
string++; // here , string=' ';
/* replace last five X's */
#ifdef _MBCS
while ((--string>=template) && (!_ismbstrail(template,string))
&& (*string == 'X') && xcount < 5) // here , error come out
#else /* _MBCS */
while (*--string == _T('X') && xcount < 5)
#endif /* _MBCS */
{
xcount++;
*string = (_TSCHAR)((number % 10) + '0');
number /= 10;
}
/* too few X's ? */
if (*string != _T('X') || xcount < 5)
return(NULL);
/* set first X */
*string = letter++;
olderrno = errno; /* save current errno */
errno = 0; /* make sure errno isn't EACCESS */
/* check all the files 'a'-'z' */
while ((_taccess(template,0) == 0) || (errno == EACCES))
/* while file exists */
{
errno = 0;
if (letter == _T('z') + 1) {
errno = olderrno;
return(NULL);
}
*string = (_TSCHAR)letter++;
}
errno = olderrno;
return(template);
}
-
- DCMTK Developer
- Posts: 2051
- Joined: Fri, 2004-11-05, 13:47
- Location: Oldenburg, Germany
- Contact:
Who is online
Users browsing this forum: Bing [Bot] and 1 guest