os/ossrv/genericopenlibs/cstdlib/LSTDIO/TMPFILE.C
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:
    15 * FUNCTION
    16 * <<tmpfile>>---create a temporary file
    17 * INDEX
    18 * tmpfile
    19 * INDEX
    20 * _tmpfile_r
    21 * ANSI_SYNOPSIS
    22 * #include <stdio.h>
    23 * FILE *tmpfile(void);
    24 * FILE *_tmpfile_r(void *<[reent]>);
    25 * TRAD_SYNOPSIS
    26 * #include <stdio.h>
    27 * FILE *tmpfile();
    28 * FILE *_tmpfile_r(<[reent]>)
    29 * char *<[reent]>;
    30 * Create a temporary file (a file which will be deleted automatically),
    31 * using a name generated by <<tmpnam>>.  The temporary file is opened with
    32 * the mode <<"wb+">>, permitting you to read and write anywhere in it
    33 * as a binary file (without any data transformations the host system may
    34 * perform for text files).
    35 * The alternate function <<_tmpfile_r>> is a reentrant version.  The
    36 * argument <[reent]> is a pointer to a reentrancy structure.
    37 * RETURNS
    38 * <<tmpfile>> normally returns a pointer to the temporary file.  If no
    39 * temporary file could be created, the result is NULL, and <<errno>>
    40 * records the reason for failure.
    41 * PORTABILITY
    42 * Both ANSI C and the System V Interface Definition (Issue 2) require
    43 * <<tmpfile>>.
    44 * Supporting OS subroutines required: <<close>>, <<fstat>>, <<getpid>>,
    45 * <<isatty>>, <<lseek>>, <<open>>, <<read>>, <<sbrk>>, <<write>>.
    46 * <<tmpfile>> also requires the global pointer <<environ>>.
    47 * 
    48 *
    49 */
    50 
    51 
    52 
    53 #include <stdio_r.h>
    54 
    55 /**
    56 Open a temporary file.
    57 Creates a temporary binary file for update.
    58 The filename is unique to avoid any conflict with existing files.
    59 @return  file pointer (stream) to the temporary file created.
    60 If the file can not be created a NULL pointer is returned.
    61 */
    62 EXPORT_C FILE *tmpfile (void)
    63 	{
    64 	return _tmpfile_r (_REENT);
    65 	}
    66 
    67 /**
    68 Open a temporary file.
    69 Creates a temporary binary file for update. 
    70 The filename is unique to avoid any conflict with existing files.
    71 @return FILE
    72 */
    73 EXPORT_C FILE *_tmpfile_r (struct _reent *r)
    74 	{
    75 	return _wfopen_r(r, (wchar_t*)L"TMP:", (wchar_t*)L"wb+");
    76 	}