[vlc-commits] skins2(Linux): replace tempnam() with mkdtemp()
Erwan Tulou
git at videolan.org
Sat Jun 13 16:07:37 CEST 2015
vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | 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/vltXXXXXX";
+ char *tmpdir = mkdtemp( templ );
+ return string( tmpdir ? tmpdir : "");
+#endif
}
#endif
More information about the vlc-commits
mailing list