[vlc-devel] [PATCH] WinCE: work-around inexistant functions

Pierre Ynard linkfanel at yahoo.fr
Thu May 7 17:58:11 CEST 2009


getpid() and remove() don't exist on WinCE. Use GetCurrentProcessId()
and unlink() here instead


diff --git a/src/config/file.c b/src/config/file.c
index 24d881c..8d509c5 100644
--- a/src/config/file.c
+++ b/src/config/file.c
@@ -512,7 +512,13 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
         goto error;
     }
 
-    if (asprintf (&temporary, "%s.%u", permanent, getpid ()) == -1)
+    if (asprintf (&temporary, "%s.%u", permanent,
+#ifdef UNDER_CE
+                  GetCurrentProcessId ()
+#else
+                  getpid ()
+#endif
+                 ) == -1)
     {
         temporary = NULL;
         module_list_free (list);
@@ -682,7 +688,7 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
     fclose (file);
 #ifdef WIN32
     /* Windows cannot remove open files nor overwrite existing ones */
-    remove (permanent);
+    unlink (permanent);
     rename (temporary, permanent);
     vlc_mutex_unlock (&lock);
 #endif
diff --git a/src/modules/cache.c b/src/modules/cache.c
index 6fa84ea..16e111d 100644
--- a/src/modules/cache.c
+++ b/src/modules/cache.c
@@ -508,7 +508,12 @@ void CacheSave( vlc_object_t *p_this, module_bank_t *p_bank )
 
     char psz_tmpname[sizeof (psz_filename) + 12];
     snprintf (psz_tmpname, sizeof (psz_tmpname), "%s.%"PRIu32, psz_filename,
-              (uint32_t)getpid ());
+#ifdef UNDER_CE
+              (uint32_t)GetCurrentProcessId ()
+#else
+              (uint32_t)getpid ()
+#endif
+             );
     file = utf8_fopen( psz_tmpname, "wb" );
     if (file == NULL)
         goto error;
@@ -608,7 +613,7 @@ void CacheSave( vlc_object_t *p_this, module_bank_t *p_bank )
     rename (psz_tmpname, psz_filename); /* atomically replace old cache */
     fclose (file);
 #else
-    remove (psz_filename);
+    unlink (psz_filename);
     fclose (file);
     rename (psz_tmpname, psz_filename);
 #endif


Regards,

-- 
Pierre Ynard
"Une âme dans un corps, c'est comme un dessin sur une feuille de papier."



More information about the vlc-devel mailing list