xHarbour Reference Documentation > Function Reference |
Creates and opens a temporary file.
HB_FTempCreate( [<cTempDir>] , ; [<cPrefix>] , ; [<nFileAttr>], ; [@<cFileName>] ) --> nFileHandle
The function returns a numeric value > 0 when the temporary file is successfully created. This is the file handle of the created temporary file.
Function HB_FTempCreate() creates a temporary file and opens it. The return value is the file handle of the temporary file. It can be used with low level file functions, such as FWrite() to store data in the file.
Temporary files are often required in an application. HB_FTempCreate() guarantees that the file name of the newly created file is unique, so that no existing file will be overwritten. To obtain the file name of the temporary file, parameter <cFileName> must be passed by reference. It can then later be passed to function FErase() in order to remove the temporary file from disk.
See also: | FCreate(), FErase(), FWrite(), GetEnv() |
Category: | File functions , Low level file functions , xHarbour extensions |
Source: | rtl\fstemp.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example implements a user defined function that creates // a temporary file and returns its file name. The temporary // file is then erased. PROCEDURE Main LOCAL cTempFile := TempFileName() ? cTempFile // result: C:\temp\xht93.tmp FErase( cTempFile ) RETURN FUNCTION TempFileName() LOCAL nFileHandle LOCAL cFileName nFileHandle := HB_FTempCreate( ,,, @cFileName ) IF nFileHandle > 0 FClose( nFileHandle ) ENDIF RETURN cFileName
http://www.xHarbour.com