Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: How to use a temporary file in a portable way |
| Date | 2015-04-09 11:00 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <87twwp39lp.fsf@bsb.me.uk> (permalink) |
| References | <mg527d$f4p$1@dont-email.me> |
pozz <pozzugno@gmail.com> writes:
> I understand the more portable and secure method to change the content
> of a file is through creating a temporary file.
You might also consider just reading the whole thing into memory.
<snip>
> [...] Now the main question of this
> post: how to use (mainly create) the temporary file in a portable way?
Quoting from the C standard:
FILE *tmpfile(void);
The tmpfile function creates a temporary binary file that is different
from any other existing file and that will automatically be removed
when it is closed or at program termination. If the program terminates
abnormally, whether an open temporary file is removed is
implementation-defined. The file is opened for update with "wb+" mode.
<snip>
> How to choose the temporary file name? How to face the situation when
> the temporary file name already exist?
char *tmpnam(char *s);
The tmpnam function generates a string that is a valid file name and
that is not the same as the name of an existing file.
(again, a quote from the standard).
--
Ben.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to use a temporary file in a portable way pozz <pozzugno@gmail.com> - 2015-04-09 07:22 +0200
Re: How to use a temporary file in a portable way Robert Wessel <robertwessel2@yahoo.com> - 2015-04-09 02:15 -0500
Re: How to use a temporary file in a portable way Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-04-09 11:00 +0100
Re: How to use a temporary file in a portable way James Kuyper <jameskuyper@verizon.net> - 2015-04-09 08:42 -0400
Re: How to use a temporary file in a portable way Greg Martin <greg.at.softsprocket@dot.com> - 2015-04-09 15:47 +0000
Re: How to use a temporary file in a portable way Michael Angelo Ravera <maravera@prodigy.net> - 2015-04-09 14:52 -0700
Re: How to use a temporary file in a portable way Richard Damon <Richard@Damon-Family.org> - 2015-04-09 23:43 -0400
Re: How to use a temporary file in a portable way Keith Thompson <kst-u@mib.org> - 2015-04-10 08:29 -0700
Re: How to use a temporary file in a portable way Richard Damon <Richard@Damon-Family.org> - 2015-04-10 22:31 -0400
Re: How to use a temporary file in a portable way Nobody <nobody@nowhere.invalid> - 2015-04-10 14:48 +0100
csiph-web