Mercurial > pidgin
comparison src/util.c @ 10203:7ff9b8b22e7d
[gaim-migrate @ 11324]
gaim_mkstemp can now create binary files
committer: Tailor Script <tailor@pidgin.im>
author | Herman Bloggs <hermanator12002@yahoo.com> |
---|---|
date | Thu, 18 Nov 2004 17:05:40 +0000 |
parents | 1a91e814e9d8 |
children | 357d4fa1bfbe |
comparison
equal
deleted
inserted
replaced
10202:ddf002ce58b6 | 10203:7ff9b8b22e7d |
---|---|
1940 * Returns NULL on failure and cleans up after itself if so. | 1940 * Returns NULL on failure and cleans up after itself if so. |
1941 */ | 1941 */ |
1942 static const char *gaim_mkstemp_templ = {"gaimXXXXXX"}; | 1942 static const char *gaim_mkstemp_templ = {"gaimXXXXXX"}; |
1943 | 1943 |
1944 FILE * | 1944 FILE * |
1945 gaim_mkstemp(char **fpath) | 1945 gaim_mkstemp(char **fpath, gboolean binary) |
1946 { | 1946 { |
1947 const gchar *tmpdir; | 1947 const gchar *tmpdir; |
1948 #ifndef _WIN32 | 1948 #ifndef _WIN32 |
1949 int fd; | 1949 int fd; |
1950 #endif | 1950 #endif |
1959 if( result == NULL ) | 1959 if( result == NULL ) |
1960 gaim_debug(GAIM_DEBUG_ERROR, "gaim_mkstemp", | 1960 gaim_debug(GAIM_DEBUG_ERROR, "gaim_mkstemp", |
1961 "Problem creating the template\n"); | 1961 "Problem creating the template\n"); |
1962 else | 1962 else |
1963 { | 1963 { |
1964 if( (fp = fopen( result, "w+" )) == NULL ) { | 1964 if( (fp = fopen( result, binary?"wb+":"w+")) == NULL ) { |
1965 gaim_debug(GAIM_DEBUG_ERROR, "gaim_mkstemp", | 1965 gaim_debug(GAIM_DEBUG_ERROR, "gaim_mkstemp", |
1966 "Couldn't fopen() %s\n", result); | 1966 "Couldn't fopen() %s\n", result); |
1967 } | 1967 } |
1968 } | 1968 } |
1969 #else | 1969 #else |