[vlc-commits] skins2(Linux): replace tempnam() with mkdtemp()

2015-06-13 Thread Erwan Tulou
vlc/vlc-2.2 | branch: master | Erwan Tulou  | Sat Jun 13 
15:29:25 2015 +0200| [150ac49cf2a2904f4bf5783e4dac84a38e53626d] | committer: 
Erwan Tulou

skins2(Linux): replace tempnam() with mkdtemp()

Linux manual strongly advises against using tempnam().

(cherry picked from commit 27cb7a2eddae5bd4e730ca7fff5b05cffd1b691c)
Signed-off-by: Erwan Tulou 

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.2.git/?a=commit;h=150ac49cf2a2904f4bf5783e4dac84a38e53626d
---

 modules/gui/skins2/src/theme_loader.cpp |   28 +---
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/modules/gui/skins2/src/theme_loader.cpp 
b/modules/gui/skins2/src/theme_loader.cpp
index a8d2725..e54f999 100644
--- a/modules/gui/skins2/src/theme_loader.cpp
+++ b/modules/gui/skins2/src/theme_loader.cpp
@@ -817,29 +817,27 @@ string ThemeLoader::getTmpDir( )
 {
 #if defined( _WIN32 )
 wchar_t *tmpdir = _wtempnam( NULL, L"vlt" );
-#else
-char *tmpdir = tempnam( NULL, "vlt" );
-#endif
 if( tmpdir == NULL )
 return "";
-
-#if defined( _WIN32 )
 char* utf8 = FromWide( tmpdir );
-if( utf8 == NULL )
-{
-free( tmpdir );
-return "";
-}
-string tempPath( utf8 );
+free( tmpdir );
+string tempPath( utf8 ? utf8 : "" );
 free( utf8 );
+return tempPath;
+
 #elif defined( __OS2__ )
+char *tmpdir = tempnam( NULL, "vlt" );
+if( tmpdir == NULL )
+return "";
 string tempPath( sFromLocale( tmpdir ));
-#else
-string tempPath( tmpdir );
-#endif
-
 free( tmpdir );
 return tempPath;
+
+#else
+char templ[] = "/tmp/vltXX";
+char *tmpdir = mkdtemp( templ );
+return string( tmpdir ? tmpdir : "");
+#endif
 }
 
 #endif

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] skins2(Linux): replace tempnam() with mkdtemp()

2015-06-13 Thread Erwan Tulou
vlc | branch: master | Erwan Tulou  | Sat Jun 13 15:29:25 
2015 +0200| [27cb7a2eddae5bd4e730ca7fff5b05cffd1b691c] | committer: Erwan Tulou

skins2(Linux): replace tempnam() with mkdtemp()

Linux manual strongly advises against using tempnam().

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=27cb7a2eddae5bd4e730ca7fff5b05cffd1b691c
---

 modules/gui/skins2/src/theme_loader.cpp |   28 +---
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/modules/gui/skins2/src/theme_loader.cpp 
b/modules/gui/skins2/src/theme_loader.cpp
index a8d2725..e54f999 100644
--- a/modules/gui/skins2/src/theme_loader.cpp
+++ b/modules/gui/skins2/src/theme_loader.cpp
@@ -817,29 +817,27 @@ string ThemeLoader::getTmpDir( )
 {
 #if defined( _WIN32 )
 wchar_t *tmpdir = _wtempnam( NULL, L"vlt" );
-#else
-char *tmpdir = tempnam( NULL, "vlt" );
-#endif
 if( tmpdir == NULL )
 return "";
-
-#if defined( _WIN32 )
 char* utf8 = FromWide( tmpdir );
-if( utf8 == NULL )
-{
-free( tmpdir );
-return "";
-}
-string tempPath( utf8 );
+free( tmpdir );
+string tempPath( utf8 ? utf8 : "" );
 free( utf8 );
+return tempPath;
+
 #elif defined( __OS2__ )
+char *tmpdir = tempnam( NULL, "vlt" );
+if( tmpdir == NULL )
+return "";
 string tempPath( sFromLocale( tmpdir ));
-#else
-string tempPath( tmpdir );
-#endif
-
 free( tmpdir );
 return tempPath;
+
+#else
+char templ[] = "/tmp/vltXX";
+char *tmpdir = mkdtemp( templ );
+return string( tmpdir ? tmpdir : "");
+#endif
 }
 
 #endif

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits