1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/LSTDIO/TMPFILE.C Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,76 @@
1.4 +/*
1.5 +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +* FUNCTION
1.19 +* <<tmpfile>>---create a temporary file
1.20 +* INDEX
1.21 +* tmpfile
1.22 +* INDEX
1.23 +* _tmpfile_r
1.24 +* ANSI_SYNOPSIS
1.25 +* #include <stdio.h>
1.26 +* FILE *tmpfile(void);
1.27 +* FILE *_tmpfile_r(void *<[reent]>);
1.28 +* TRAD_SYNOPSIS
1.29 +* #include <stdio.h>
1.30 +* FILE *tmpfile();
1.31 +* FILE *_tmpfile_r(<[reent]>)
1.32 +* char *<[reent]>;
1.33 +* Create a temporary file (a file which will be deleted automatically),
1.34 +* using a name generated by <<tmpnam>>. The temporary file is opened with
1.35 +* the mode <<"wb+">>, permitting you to read and write anywhere in it
1.36 +* as a binary file (without any data transformations the host system may
1.37 +* perform for text files).
1.38 +* The alternate function <<_tmpfile_r>> is a reentrant version. The
1.39 +* argument <[reent]> is a pointer to a reentrancy structure.
1.40 +* RETURNS
1.41 +* <<tmpfile>> normally returns a pointer to the temporary file. If no
1.42 +* temporary file could be created, the result is NULL, and <<errno>>
1.43 +* records the reason for failure.
1.44 +* PORTABILITY
1.45 +* Both ANSI C and the System V Interface Definition (Issue 2) require
1.46 +* <<tmpfile>>.
1.47 +* Supporting OS subroutines required: <<close>>, <<fstat>>, <<getpid>>,
1.48 +* <<isatty>>, <<lseek>>, <<open>>, <<read>>, <<sbrk>>, <<write>>.
1.49 +* <<tmpfile>> also requires the global pointer <<environ>>.
1.50 +*
1.51 +*
1.52 +*/
1.53 +
1.54 +
1.55 +
1.56 +#include <stdio_r.h>
1.57 +
1.58 +/**
1.59 +Open a temporary file.
1.60 +Creates a temporary binary file for update.
1.61 +The filename is unique to avoid any conflict with existing files.
1.62 +@return file pointer (stream) to the temporary file created.
1.63 +If the file can not be created a NULL pointer is returned.
1.64 +*/
1.65 +EXPORT_C FILE *tmpfile (void)
1.66 + {
1.67 + return _tmpfile_r (_REENT);
1.68 + }
1.69 +
1.70 +/**
1.71 +Open a temporary file.
1.72 +Creates a temporary binary file for update.
1.73 +The filename is unique to avoid any conflict with existing files.
1.74 +@return FILE
1.75 +*/
1.76 +EXPORT_C FILE *_tmpfile_r (struct _reent *r)
1.77 + {
1.78 + return _wfopen_r(r, (wchar_t*)L"TMP:", (wchar_t*)L"wb+");
1.79 + }