Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
09b452a3
Commit
09b452a3
authored
May 04, 2008
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
XDG code factorization
parent
60987ce2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
53 deletions
+27
-53
src/config/core.c
src/config/core.c
+27
-53
No files found.
src/config/core.c
View file @
09b452a3
...
...
@@ -724,63 +724,58 @@ char *config_GetUserDir( void )
return
GetDir
(
true
);
}
/**
* Get the user's VLC configuration directory
*/
char
*
config_GetConfigDir
(
libvlc_int_t
*
p_libvlc
)
static
char
*
config_GetFooDir
(
libvlc_int_t
*
p_libvlc
,
const
char
*
xdg_name
,
const
char
*
xdg_default
)
{
char
*
psz_dir
;
#if defined(WIN32) || defined(__APPLE__) || defined(SYS_BEOS)
char
*
psz_parent
=
config_GetUserDir
();
if
(
!
psz_parent
)
psz_parent
=
p_libvlc
->
psz_homedir
;
if
(
!
psz_parent
)
psz_parent
=
p_libvlc
->
psz_homedir
;
if
(
asprintf
(
&
psz_dir
,
"%s"
DIR_SEP
CONFIG_DIR
,
psz_parent
)
==
-
1
)
return
NULL
;
psz_dir
=
NULL
;
(
void
)
xdg_name
;
(
void
)
xdg_default
;
return
psz_dir
;
#else
char
var
[
sizeof
(
"XDG__HOME"
)
+
strlen
(
xdg_name
)],
*
psz_env
;
/* XDG Base Directory Specification - Version 0.6 */
char
*
psz_env
=
getenv
(
"XDG_CONFIG_HOME"
);
snprintf
(
var
,
sizeof
(
var
),
"XDG_%s_HOME"
,
xdg_name
);
psz_env
=
getenv
(
var
);
if
(
psz_env
)
{
if
(
asprintf
(
&
psz_dir
,
"%s/vlc"
,
psz_env
)
==
-
1
)
return
NULL
;
return
psz_dir
;
}
psz_env
=
getenv
(
"HOME"
);
if
(
!
psz_env
)
psz_env
=
p_libvlc
->
psz_homedir
;
/* not part of XDG spec but we want a sensible fallback */
if
(
asprintf
(
&
psz_dir
,
"%s/.config/vlc"
,
psz_env
)
==
-
1
)
/* not part of XDG spec but we want a sensible fallback */
if
(
!
psz_env
)
psz_env
=
p_libvlc
->
psz_homedir
;
if
(
asprintf
(
&
psz_dir
,
"%s/%s/vlc"
,
psz_env
,
xdg_default
)
==
-
1
)
return
NULL
;
return
psz_dir
;
#endif
}
/**
* Get the user's VLC configuration directory
*/
char
*
config_GetConfigDir
(
libvlc_int_t
*
p_libvlc
)
{
return
config_GetFooDir
(
p_libvlc
,
"CONFIG"
,
".config"
);
}
/**
* Get the user's VLC data directory
* (used for stuff like the skins, custom lua modules, ...)
*/
char
*
config_GetUserDataDir
(
libvlc_int_t
*
p_libvlc
)
{
char
*
psz_dir
;
#if defined(WIN32) || defined(__APPLE__) || defined(SYS_BEOS)
char
*
psz_parent
=
config_GetUserDir
();
if
(
!
psz_parent
)
psz_parent
=
p_libvlc
->
psz_homedir
;
if
(
asprintf
(
&
psz_dir
,
"%s"
DIR_SEP
CONFIG_DIR
,
psz_parent
)
==
-
1
)
return
NULL
;
return
psz_dir
;
#else
/* XDG Base Directory Specification - Version 0.6 */
char
*
psz_env
=
getenv
(
"XDG_DATA_HOME"
);
if
(
psz_env
)
{
if
(
asprintf
(
&
psz_dir
,
"%s/vlc"
,
psz_env
)
==
-
1
)
return
NULL
;
return
psz_dir
;
}
psz_env
=
getenv
(
"HOME"
);
if
(
!
psz_env
)
psz_env
=
p_libvlc
->
psz_homedir
;
/* not part of XDG spec but we want a sensible fallback */
if
(
asprintf
(
&
psz_dir
,
"%s/.local/share/vlc"
,
psz_env
)
==
-
1
)
return
NULL
;
return
psz_dir
;
#endif
return
config_GetFooDir
(
p_libvlc
,
"DATA"
,
".local/share"
);
}
/**
...
...
@@ -789,26 +784,5 @@ char *config_GetUserDataDir( libvlc_int_t *p_libvlc )
*/
char
*
config_GetCacheDir
(
libvlc_int_t
*
p_libvlc
)
{
char
*
psz_dir
;
#if defined(WIN32) || defined(__APPLE__) || defined(SYS_BEOS)
char
*
psz_parent
=
config_GetUserDir
();
if
(
!
psz_parent
)
psz_parent
=
p_libvlc
->
psz_homedir
;
if
(
asprintf
(
&
psz_dir
,
"%s"
DIR_SEP
CONFIG_DIR
,
psz_parent
)
==
-
1
)
return
NULL
;
return
psz_dir
;
#else
/* XDG Base Directory Specification - Version 0.6 */
char
*
psz_env
=
getenv
(
"XDG_CACHE_HOME"
);
if
(
psz_env
)
{
if
(
asprintf
(
&
psz_dir
,
"%s/vlc"
,
psz_env
)
==
-
1
)
return
NULL
;
return
psz_dir
;
}
psz_env
=
getenv
(
"HOME"
);
if
(
!
psz_env
)
psz_env
=
p_libvlc
->
psz_homedir
;
/* not part of XDG spec but we want a sensible fallback */
if
(
asprintf
(
&
psz_dir
,
"%s/.cache/vlc"
,
psz_env
)
==
-
1
)
return
NULL
;
return
psz_dir
;
#endif
return
config_GetFooDir
(
p_libvlc
,
"CACHE"
,
".cache"
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment