Make use of the libc wrappers
authorLuca Bacci <luca.bacci982@gmail.com>
Thu, 29 Dec 2022 14:24:34 +0000 (15:24 +0100)
committerØyvind "pippin" Kolås <pippin@gimp.org>
Tue, 3 Jan 2023 10:33:37 +0000 (10:33 +0000)
babl/babl-cache.c
babl/babl-util.c

index a3bd8e094c77f0f335b13dea032dd9d2a76560af..ece47d341950436d51062e604d64742dcfc0b55e 100644 (file)
@@ -43,15 +43,15 @@ mk_ancestry_iter (const char *path)
       *strrchr (copy, '/') = '\0';
       if (copy[0])
         {
-          struct stat stat_buf;
-          if ( ! (stat (copy, &stat_buf)==0 && S_ISDIR(stat_buf.st_mode)))
+          BablStat stat_buf;
+          if ( ! (_babl_stat (copy, &stat_buf)==0 && S_ISDIR(stat_buf.st_mode)))
             {
               if (mk_ancestry_iter (copy) != 0)
                 return -1;
 #ifndef _WIN32
-              return mkdir (copy, S_IRWXU);
+              return _babl_mkdir (copy, S_IRWXU);
 #else
-              return mkdir (copy);
+              return _babl_mkdir (copy);
 #endif
             }
         }
@@ -76,7 +76,7 @@ mk_ancestry (const char *path)
 static const char *
 fish_cache_path (void)
 {
-  struct stat stat_buf;
+  BablStat stat_buf;
   static char path[4096];
 
   strncpy (path, FALLBACK_CACHE_PATH, 4096);
@@ -96,7 +96,7 @@ fish_cache_path (void)
 }
 #endif
 
-  if (stat (path, &stat_buf)==0 && S_ISREG(stat_buf.st_mode))
+  if (_babl_stat (path, &stat_buf)==0 && S_ISREG(stat_buf.st_mode))
     return path;
 
   if (mk_ancestry (path) != 0)
@@ -188,7 +188,7 @@ babl_store_db (void)
   if (!tmpp)
     return;
   snprintf (tmpp, 8000, "%s~", fish_cache_path ());
-  dbfile  = fopen (tmpp, "w");
+  dbfile  = _babl_fopen (tmpp, "w");
   if (!dbfile)
   {
     free (tmpp);
@@ -212,9 +212,9 @@ babl_store_db (void)
   fclose (dbfile);
 
 #ifdef _WIN32
-  remove (fish_cache_path ());
+  _babl_remove (fish_cache_path ());
 #endif
-  rename (tmpp, fish_cache_path());
+  _babl_rename (tmpp, fish_cache_path());
   free (tmpp);
 }
 
index cc7765430afc945b3d544e03f977738f17b39194..a4f482f5d4e923b5c628ccca67492a6279c866a2 100644 (file)
@@ -288,7 +288,7 @@ _babl_file_get_contents (const char  *path,
   long  size;
   char *buffer;
 
-  file = fopen (path,"rb");
+  file = _babl_fopen (path, "rb");
 
   if (!file)
     return -1;