Path: utzoo!attcan!uunet!lll-winken!ames!mailrus!tut.cis.ohio-state.edu!bloom-beacon!earth.cray.COM!jlf From: jlf@earth.cray.COM (John Freeman) Newsgroups: comp.windows.x Subject: Re: AsciiDiskWidgets Message-ID: <8902231648.AA23639@thelake.cray.com> Date: 23 Feb 89 16:48:15 GMT Sender: daemon@bloom-beacon.MIT.EDU Organization: The Internet Lines: 62 > still, the DiskWidget wants a valid > file name at widget creation time - something I don't > want to specify. if the file name is null, > XtDiskSourceCreate constructs a temp file name and > proceeds to try to open it read only, which of course > fails, and then exits via XtError. do you know any > way around this? i hacked lib/Xaw/DiskSrc.c to create > and close the temp file name, which produces spurious > files, but at least it doesn't exit. You are entirely correct about temporary file names in the Disk Widget. I did exactly as you - modified DiskSrc.c to creat() the file, then unlink() in immediately. This works just fine. I also submitted a bug report to MIT about it. Context diffs for DiskSrc.c: *** DiskSrc.c Tue Oct 18 11:29:58 1988 --- DiskSrc.c.new Tue Feb 14 11:08:36 1989 *************** *** 389,394 **** --- 394,400 ---- if (data->fileName == NULL) { data->fileName = tmpnam (XtMalloc((unsigned)TMPSIZ)); data->is_tempfile = TRUE; + creat(data->fileName, 0600); } else data->is_tempfile = FALSE; *************** *** 408,413 **** --- 414,422 ---- XtError("Cannot open source file in XtDiskSourceCreate"); src->Replace = DummyReplaceText; } + if (data->is_tempfile) { + unlink(data->fileName); /* temp file won't be left around */ + } (void) fseek(data->file, topPosition, 2); data->length = ftell (data->file); data->buffer = (char *) XtMalloc((unsigned)bufSize); *************** *** 421,431 **** { DiskSourcePtr data; data = (DiskSourcePtr) src->data; XtFree((char *) data->buffer); - if (data->is_tempfile) { - unlink(data->fileName); - XtFree((char *) data->fileName); - } XtFree((char *) src->data); XtFree((char *) src); } --- 430,437 ---- { DiskSourcePtr data; data = (DiskSourcePtr) src->data; + XtFree((char *) data->fileName); XtFree((char *) data->buffer); XtFree((char *) src->data); XtFree((char *) src); }