Commit a8c111dd authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Win32: refactor and implement pictures directory

parent 47d017dd
...@@ -53,10 +53,15 @@ const char *config_GetDataDir( void ) ...@@ -53,10 +53,15 @@ const char *config_GetDataDir( void )
return path; return path;
} }
static const char *GetDir( bool b_common ) const char *config_GetConfDir (void)
{ {
static char appdir[PATH_MAX] = "";
wchar_t wdir[MAX_PATH]; wchar_t wdir[MAX_PATH];
#warning FIXME: thread-safety!
if (*appdir)
return appdir;
#if defined (UNDER_CE) #if defined (UNDER_CE)
/*There are some errors in cegcc headers*/ /*There are some errors in cegcc headers*/
#undef SHGetSpecialFolderPath #undef SHGetSpecialFolderPath
...@@ -64,27 +69,18 @@ static const char *GetDir( bool b_common ) ...@@ -64,27 +69,18 @@ static const char *GetDir( bool b_common )
if( SHGetSpecialFolderPath( NULL, wdir, CSIDL_APPDATA, 1 ) ) if( SHGetSpecialFolderPath( NULL, wdir, CSIDL_APPDATA, 1 ) )
#else #else
/* Get the "Application Data" folder for the current user */ /* Get the "Application Data" folder for the current user */
if( S_OK == SHGetFolderPathW( NULL, (b_common ? CSIDL_COMMON_APPDATA if( S_OK == SHGetFolderPathW( NULL, CSIDL_COMMON_APPDATA
: CSIDL_APPDATA)
| CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, wdir ) ) | CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, wdir ) )
#endif #endif
{ {
static char appdir[PATH_MAX] = "";
static char comappdir[PATH_MAX] = "";
WideCharToMultiByte (CP_UTF8, 0, wdir, -1, WideCharToMultiByte (CP_UTF8, 0, wdir, -1,
b_common ? comappdir : appdir, appdir, PATH_MAX, NULL, NULL);
PATH_MAX, NULL, NULL); return appdir;
return b_common ? comappdir : appdir;
} }
return NULL; return NULL;
} }
const char *config_GetConfDir( void ) static char *config_GetShellDir (int csidl)
{
return GetDir( true );
}
static char *config_GetHomeDir (void)
{ {
wchar_t wdir[MAX_PATH]; wchar_t wdir[MAX_PATH];
...@@ -94,7 +90,7 @@ static char *config_GetHomeDir (void) ...@@ -94,7 +90,7 @@ static char *config_GetHomeDir (void)
BOOL WINAPI SHGetSpecialFolderPath(HWND,LPWSTR,int,BOOL); BOOL WINAPI SHGetSpecialFolderPath(HWND,LPWSTR,int,BOOL);
if (SHGetSpecialFolderPath (NULL, wdir, CSIDL_APPDATA, 1)) if (SHGetSpecialFolderPath (NULL, wdir, CSIDL_APPDATA, 1))
#else #else
if (SHGetFolderPathW (NULL, CSIDL_PERSONAL | CSIDL_FLAG_CREATE, if (SHGetFolderPathW (NULL, csidl | CSIDL_FLAG_CREATE,
NULL, SHGFP_TYPE_CURRENT, wdir ) == S_OK) NULL, SHGFP_TYPE_CURRENT, wdir ) == S_OK)
#endif #endif
return FromWide (wdir); return FromWide (wdir);
...@@ -104,10 +100,12 @@ static char *config_GetHomeDir (void) ...@@ -104,10 +100,12 @@ static char *config_GetHomeDir (void)
static char *config_GetAppDir (void) static char *config_GetAppDir (void)
{ {
char *psz_dir; char *psz_dir;
const char *psz_parent = GetDir (false); char *psz_parent = config_GetShellDir (CSIDL_APPDATA);
if( asprintf( &psz_dir, "%s\\vlc", psz_parent ) == -1 ) if (psz_parent == NULL
|| asprintf (&psz_dir, "%s\\vlc", psz_parent) == -1)
psz_dir = NULL; psz_dir = NULL;
free (psz_parent);
return psz_dir; return psz_dir;
} }
...@@ -121,7 +119,7 @@ char *config_GetUserDir (vlc_userdir_t type) ...@@ -121,7 +119,7 @@ char *config_GetUserDir (vlc_userdir_t type)
switch (type) switch (type)
{ {
case VLC_HOME_DIR: case VLC_HOME_DIR:
return config_GetHomeDir (); return config_GetShellDir (CSIDL_PERSONAL);
case VLC_CONFIG_DIR: case VLC_CONFIG_DIR:
return config_GetAppDir (); return config_GetAppDir ();
case VLC_DATA_DIR: case VLC_DATA_DIR:
...@@ -132,8 +130,12 @@ char *config_GetUserDir (vlc_userdir_t type) ...@@ -132,8 +130,12 @@ char *config_GetUserDir (vlc_userdir_t type)
case VLC_PUBLICSHARE_DIR: case VLC_PUBLICSHARE_DIR:
case VLC_DOCUMENTS_DIR: case VLC_DOCUMENTS_DIR:
case VLC_MUSIC_DIR: case VLC_MUSIC_DIR:
#warning FIXME: unimplemented
return config_GetUserDir (VLC_HOME_DIR);
case VLC_PICTURES_DIR: case VLC_PICTURES_DIR:
return config_GetShellDir (CSIDL_MYPICTURES);
case VLC_VIDEOS_DIR: case VLC_VIDEOS_DIR:
#warning FIXME: unimplemented
return config_GetUserDir (VLC_HOME_DIR); return config_GetUserDir (VLC_HOME_DIR);
} }
assert (0); assert (0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment