Re: g_mkstmp() replacement for tempfile.c
Fergus Henderson <[email protected]> Fri, 8 Jun 2012 12:23:30 -0400
| Newsgroups | gmane.comp.compilers.distcc |
|---|---|
| Message-ID | <CAPXkjd_XGojBepcR_AyDYQaj1ENjoe5VpJm+zLm+mK+kQt559w@mail.gmail.com> |
I don't think it is worth adding a dependency on glib and dragging in the whole glib library. That is likely to cause more problems than it solves. On Jun 6, 2012 4:46 AM, "Shawn" <[email protected]> wrote: > > > On Mon, Jun 4, 2012 at 10:42 PM, bjcheny <[email protected]> wrote: > >> hi shawn, >> >> This function exists in glib, other than glibc. >> Glib is not necessarily existing on every platforms, I guss. >> At least, it's missing from my Mac. >> Although it may work as desired, we need to ask for additional lib. >> > > yes it is a new lib > > however, it does exist on OSX > > http://www.gtk.org/download/macos.php > > to only install glib you would probably use macports or something. I don't > use mac. We would just ship with the source perhaps. > >> >> 2012/6/5 shawn <[email protected]> >> >>> >>> from tempfile.c >>> == >>> >>> * It would be nice if we could use a standard function, but I don't >>> * think any of them are adequate: we need to control the extension >>> * and know the filename. tmpfile() does not give back the filename. >>> * tmpnam() is insecure. mkstemp() does not allow us to set the >>> * extension. >>> * >>> * It sucks that there is no standard function. The implementation >>> * below is inspired by the __gen_tempname() code in glibc; hopefully >>> * it will be secure on all platforms. >>> >>> === >>> well, such a thing DOES exist, in glib: >>> >>> http://developer.gnome.org/glib/2.33/glib-File-Utilities.html#g-mkstemp >>> >>> interested in switching? >>> == >>> >>> >>> gint g_mkstemp (gchar *tmpl); >>> >>> Opens a temporary file. See the mkstemp() documentation on most >>> UNIX-like systems. >>> >>> The parameter is a string that should follow the rules for mkstemp() >>> templates, i.e. contain the string "XXXXXX". g_mkstemp() is slightly >>> more flexible than mkstemp() in that the sequence does not have to occur >>> at the very end of the template. The X string will be modified to form >>> the name of a file that didn't exist. The string should be in the GLib >>> file name encoding. Most importantly, on Windows it should be in UTF-8. >>> >>> tmpl : >>> template filename. [type filename] >>> >>> Returns : >>> A file handle (as from open()) to the file opened for reading and >>> writing. The file is opened in binary mode on platforms where there is a >>> difference. The file handle should be closed with close(). In case of >>> errors, -1 is returned and errno will be set. >>> >>> __ >>> distcc mailing list http://distcc.samba.org/ >>> To unsubscribe or change options: >>> https://lists.samba.org/mailman/listinfo/distcc >>> >> >> > > > -- > > --- > Shawn Landden > > > __ > distcc mailing list http://distcc.samba.org/ > To unsubscribe or change options: > https://lists.samba.org/mailman/listinfo/distcc > __ distcc mailing list http://distcc.samba.org/ To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/distcc