[Bf-committers] Re: another dumb question

Douglas Toltzman bf-committers@blender.org
Fri, 20 Dec 2002 11:33:36 -0500 (EST)


On Fri, 20 Dec 2002, Rob Haarsma wrote:

--snip--
> #ifdef WIN32   //_DISABLED
> 	file= open("C:\\windows\\temp\\cutbuf.txt", O_BINARY|O_RDONLY);
> #else
> 	file= open("/tmp/.cutbuffer", O_BINARY|O_RDONLY);
> #endif
--snip--

In the interest of completeness and compatibility, while you are making
changes here, it would be best to generate the temporary file name in a
way the is more likely to work on all Win32 installations.

e.g. 
char tempFileName[MAX_PATH];
DWORD pathlen;
static const char cutbufname[]="cutbuf.txt";

if ((pathlen=GetTempPath(sizeof(tempFileName),tempFileName)) > 0 &&
pathlen + sizeof(cutbufname) <= sizeof(tempFileName))
{
  strcat(tempFileName,cutbufname);
  ...
}

Regards,
Doug Toltzman