Remove warnings about conflicts with the stable version.
[platform/upstream/glib.git] / gfileutils.c
index ce80242..86b33bc 100644 (file)
@@ -27,6 +27,7 @@
 #include <unistd.h>
 #endif
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <errno.h>
 #include <sys/types.h>
@@ -61,7 +62,7 @@
 #define O_BINARY 0
 #endif
 
-#define _(x) x
+#include "glibintl.h"
 
 /**
  * g_file_test:
@@ -116,10 +117,25 @@ g_file_error_quark (void)
   return q;
 }
 
+/**
+ * g_file_error_from_errno:
+ * @err_no: an "errno" value
+ * 
+ * Gets a #GFileError constant based on the passed-in errno.
+ * For example, if you pass in EEXIST this function returns
+ * #G_FILE_ERROR_EXIST. Unlike errno values, you can portably
+ * assume that all #GFileError values will exist.
+ *
+ * Normally a #GFileError value goes into a #GError returned
+ * from a function that manipulates files. So you would use
+ * g_file_error_from_errno() when constructing a #GError.
+ * 
+ * Return value: #GFileError corresponding to the given errno
+ **/
 GFileError
-g_file_error_from_errno (gint en)
+g_file_error_from_errno (gint err_no)
 {
-  switch (en)
+  switch (err_no)
     {
 #ifdef EEXIST
     case EEXIST:
@@ -377,7 +393,8 @@ get_contents_posix (const gchar *filename,
   struct stat stat_buf;
   gint fd;
   
-  fd = open (filename, O_RDONLY);
+  /* O_BINARY useful on Cygwin */
+  fd = open (filename, O_RDONLY|O_BINARY);
 
   if (fd < 0)
     {
@@ -617,14 +634,18 @@ g_file_open_tmp (const char *tmpl,
                 GError    **error)
 {
   int retval;
-  char *tmpdir;
+  const char *tmpdir;
   char *sep;
   char *fulltemplate;
 
   if (tmpl == NULL)
     tmpl = ".XXXXXX";
 
-  if (strchr (tmpl, G_DIR_SEPARATOR))
+  if (strchr (tmpl, G_DIR_SEPARATOR)
+#ifdef G_OS_WIN32
+      || strchr (tmpl, '/')
+#endif
+                                   )
     {
       g_set_error (error,
                   G_FILE_ERROR,
@@ -641,7 +662,7 @@ g_file_open_tmp (const char *tmpl,
       g_set_error (error,
                   G_FILE_ERROR,
                   G_FILE_ERROR_FAILED,
-                  _("Template '%s' doesn end with XXXXXX"),
+                  _("Template '%s' doesn't end with XXXXXX"),
                   tmpl);
       return -1;
     }