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