+/*****************************************************************************
+ * config_CreateDir: Create configuration directory if it doesn't exist.
+ *****************************************************************************/
+int config_CreateDir( vlc_object_t *p_this, char *psz_dirname )
+{
+ if( !psz_dirname && !*psz_dirname ) return -1;
+
+#if defined( UNDER_CE )
+ {
+ wchar_t psz_new[ MAX_PATH ];
+ char psz_mod[MAX_PATH];
+ int i = 0;
+
+ /* Convert '/' into '\' */
+ while( *psz_dirname )
+ {
+ if( *psz_dirname == '/' ) psz_mod[i] = '\\';
+ else psz_mod[i] = *psz_dirname;
+ psz_dirname++;
+ i++;
+ }
+ psz_mod[i] = 0;
+
+ MultiByteToWideChar( CP_ACP, 0, psz_mod, -1, psz_new, MAX_PATH );
+ if( CreateDirectory( psz_new, NULL ) )
+ {
+ msg_Err( p_this, "could not create %s", psz_mod );
+ }
+ }
+
+#else
+# if defined( WIN32 )
+ if( mkdir( psz_dirname ) && errno != EEXIST )
+# else
+ if( mkdir( psz_dirname, 0755 ) && errno != EEXIST )
+# endif
+ {
+ msg_Err( p_this, "could not create %s (%s)",
+ psz_dirname, strerror(errno) );
+ }
+
+#endif
+
+ return 0;
+}
+