[vlc-devel] [PATCH] WinCE: work-around inexistant functions
Pierre Ynard
linkfanel at yahoo.fr
Thu May 7 14:03:22 CEST 2009
getpid() and remove() don't exist on WinCE. Use rand() and unlink() here
instead
diff --git a/src/config/file.c b/src/config/file.c
index 482f629..ab63346 100644
--- a/src/config/file.c
+++ b/src/config/file.c
@@ -510,7 +510,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
+ rand ()
+#else
+ getpid ()
+#endif
+ ) == -1)
{
temporary = NULL;
module_list_free (list);
@@ -680,7 +686,11 @@ 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 */
+# ifdef UNDER_CE
+ unlink (permanent);
+# else
remove (permanent);
+# endif
rename (temporary, permanent);
vlc_mutex_unlock (&lock);
#endif
diff --git a/src/modules/cache.c b/src/modules/cache.c
index 6fa84ea..c5d0ef2 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)rand ()
+#else
+ (uint32_t)getpid ()
+#endif
+ );
file = utf8_fopen( psz_tmpname, "wb" );
if (file == NULL)
goto error;
@@ -608,7 +613,11 @@ void CacheSave( vlc_object_t *p_this, module_bank_t *p_bank )
rename (psz_tmpname, psz_filename); /* atomically replace old cache */
fclose (file);
#else
+# ifdef UNDER_CE
+ unlink (psz_filename);
+# else
remove (psz_filename);
+# endif
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