]> Pileus Git - ~andy/gtk/blobdiff - gtk/updateiconcache.c
Updated Slovenian translation
[~andy/gtk] / gtk / updateiconcache.c
index b239cc3029894de0f90a7fcb89ec003b8bae12ea..3b927011cccccc142363f35df8883ab0b1966dd9 100644 (file)
@@ -1201,7 +1201,7 @@ write_bucket (FILE *cache, HashNode *node, int *offset)
            }
          else
            {
-             if (!write_card32 (cache, (guint32) image->image_data ? image->image_data->offset : 0))
+             if (!write_card32 (cache, (guint32) (image->image_data ? image->image_data->offset : 0)))
                return FALSE;
            }
 
@@ -1415,11 +1415,11 @@ validate_file (const gchar *file)
 
   if (!_gtk_icon_cache_validate (&info)) 
     {
-      g_mapped_file_free (map);
+      g_mapped_file_unref (map);
       return FALSE;
     }
   
-  g_mapped_file_free (map);
+  g_mapped_file_unref (map);
 
   return TRUE;
 }
@@ -1438,6 +1438,7 @@ build_cache (const gchar *path)
   struct utimbuf utime_buf;
   GList *directories = NULL;
   int fd;
+  int retry_count = 0;
 #ifndef G_OS_WIN32
   mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
 #else
@@ -1448,9 +1449,17 @@ build_cache (const gchar *path)
 #endif
 
   tmp_cache_path = g_build_filename (path, "."CACHE_NAME, NULL);
+  cache_path = g_build_filename (path, CACHE_NAME, NULL);
 
+opentmp:
   if ((fd = g_open (tmp_cache_path, O_WRONLY | O_CREAT | O_EXCL | O_TRUNC | _O_BINARY, mode)) == -1)
     {
+      if (force_update && retry_count == 0)
+        {
+          retry_count++;
+          g_remove (tmp_cache_path);
+          goto opentmp;
+        }
       g_printerr (_("Failed to open file %s : %s\n"), tmp_cache_path, g_strerror (errno));
       exit (1);
     }
@@ -1476,6 +1485,7 @@ build_cache (const gchar *path)
 
       fclose (cache);
       g_unlink (tmp_cache_path);
+      g_unlink (cache_path);
       exit (0);
     }
     
@@ -1495,12 +1505,10 @@ build_cache (const gchar *path)
   if (!validate_file (tmp_cache_path))
     {
       g_printerr (_("The generated cache was invalid.\n"));
-      //g_unlink (tmp_cache_path);
+      /*g_unlink (tmp_cache_path);*/
       exit (1);
     }
 
-  cache_path = g_build_filename (path, CACHE_NAME, NULL);
-
 #ifdef G_OS_WIN32
   if (g_file_test (cache_path, G_FILE_TEST_EXISTS))
     {
@@ -1508,9 +1516,11 @@ build_cache (const gchar *path)
       g_unlink (bak_cache_path);
       if (g_rename (cache_path, bak_cache_path) == -1)
        {
+          int errsv = errno;
+
          g_printerr (_("Could not rename %s to %s: %s, removing %s then.\n"),
                      cache_path, bak_cache_path,
-                     g_strerror (errno),
+                     g_strerror (errsv),
                      cache_path);
          g_unlink (cache_path);
          bak_cache_path = NULL;
@@ -1520,16 +1530,22 @@ build_cache (const gchar *path)
 
   if (g_rename (tmp_cache_path, cache_path) == -1)
     {
+      int errsv = errno;
+
       g_printerr (_("Could not rename %s to %s: %s\n"),
                  tmp_cache_path, cache_path,
-                 g_strerror (errno));
+                 g_strerror (errsv));
       g_unlink (tmp_cache_path);
 #ifdef G_OS_WIN32
       if (bak_cache_path != NULL)
        if (g_rename (bak_cache_path, cache_path) == -1)
-         g_printerr (_("Could not rename %s back to %s: %s.\n"),
-                     bak_cache_path, cache_path,
-                     g_strerror (errno));
+          {
+            errsv = errno;
+
+            g_printerr (_("Could not rename %s back to %s: %s.\n"),
+                        bak_cache_path, cache_path,
+                        g_strerror (errsv));
+          }
 #endif
       exit (1);
     }
@@ -1640,8 +1656,12 @@ main (int argc, char **argv)
   
   setlocale (LC_ALL, "");
 
+#ifdef ENABLE_NLS
   bindtextdomain (GETTEXT_PACKAGE, GTK_LOCALEDIR);
+#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
   bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif
+#endif
 
   context = g_option_context_new ("ICONPATH");
   g_option_context_add_main_entries (context, args, GETTEXT_PACKAGE);
@@ -1679,7 +1699,7 @@ main (int argc, char **argv)
     {
       if (path)
        {
-         g_printerr (_("No theme index file."));
+         g_printerr (_("No theme index file.\n"));
        }
       else
        {