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
b152c831
Commit
b152c831
authored
May 22, 2008
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Store the home directory statically, as it cannot change
parent
eef284f3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
33 deletions
+47
-33
src/config/dirs.c
src/config/dirs.c
+47
-33
No files found.
src/config/dirs.c
View file @
b152c831
...
@@ -90,37 +90,43 @@ const char *config_GetConfDir( void )
...
@@ -90,37 +90,43 @@ const char *config_GetConfDir( void )
#endif
#endif
}
}
static
char
*
GetDir
(
bool
b_appdata
)
static
c
onst
c
har
*
GetDir
(
bool
b_appdata
)
{
{
const
char
*
psz_localhome
=
NULL
;
static
char
homedir
[
PATH_MAX
]
=
""
;
#if defined(WIN32) && !defined(UNDER_CE)
#if defined (WIN32)
wchar_t
whomedir
[
MAX_PATH
];
wchar_t
wdir
[
MAX_PATH
];
# if defined (UNDER_CE)
if
(
SHGetSpecialFolderPath
(
NULL
,
wdir
,
CSIDL_APPDATA
,
1
)
)
# else
/* Get the "Application Data" folder for the current user */
/* Get the "Application Data" folder for the current user */
if
(
S_OK
==
SHGetFolderPathW
(
NULL
,
if
(
S_OK
==
SHGetFolderPathW
(
NULL
,
(
b_appdata
?
CSIDL_APPDATA
:
CSIDL_PROFILE
)
|
CSIDL_FLAG_CREATE
,
(
b_appdata
?
CSIDL_APPDATA
:
CSIDL_PROFILE
)
|
CSIDL_FLAG_CREATE
,
NULL
,
SHGFP_TYPE_CURRENT
,
whomedir
)
)
NULL
,
SHGFP_TYPE_CURRENT
,
wdir
)
)
return
FromWide
(
whomedir
);
# endif
{
#elif defined(UNDER_CE)
static
char
appdir
[
PATH_MAX
]
=
""
;
WideCharToMultiByte
(
CP_UTF8
,
0
,
wdir
,
-
1
,
b_appdata
?
appdir
:
homedir
,
PATH_MAX
,
NULL
,
NULL
);
return
b_appdata
?
appdir
:
homedir
;
}
#else
(
void
)
b_appdata
;
(
void
)
b_appdata
;
#ifndef CSIDL_APPDATA
# define CSIDL_APPDATA 0x1A
#endif
#endif
wchar_t
whomedir
[
MAX_PATH
];
#ifdef LIBVLC_USE_PTHREAD
static
pthread_mutex_t
lock
=
PTHREAD_MUTEX_INITIALIZER
;
/* get the "Application Data" folder for the current user */
pthread_mutex_lock
(
&
lock
);
if
(
SHGetSpecialFolderPath
(
NULL
,
whomedir
,
CSIDL_APPDATA
,
1
)
)
return
FromWide
(
whomedir
);
#else
(
void
)
b_appdata
;
#endif
#endif
psz_localhome
=
getenv
(
"HOME"
);
if
(
!*
homedir
)
{
const
char
*
psz_localhome
=
getenv
(
"HOME"
);
#if defined(HAVE_GETPWUID_R)
#if defined(HAVE_GETPWUID_R)
char
buf
[
sysconf
(
_SC_GETPW_R_SIZE_MAX
)];
char
buf
[
sysconf
(
_SC_GETPW_R_SIZE_MAX
)];
if
(
psz_localhome
==
NULL
)
if
(
psz_localhome
==
NULL
)
{
{
struct
passwd
pw
,
*
res
;
struct
passwd
pw
,
*
res
;
...
@@ -133,7 +139,15 @@ static char *GetDir( bool b_appdata )
...
@@ -133,7 +139,15 @@ static char *GetDir( bool b_appdata )
if
(
psz_localhome
==
NULL
)
if
(
psz_localhome
==
NULL
)
psz_localhome
=
"/tmp"
;
psz_localhome
=
"/tmp"
;
return
FromLocaleDup
(
psz_localhome
);
const
char
*
uhomedir
=
FromLocale
(
psz_localhome
);
strncpy
(
homedir
,
uhomedir
,
sizeof
(
homedir
)
-
1
);
homedir
[
sizeof
(
homedir
)
-
1
]
=
'\0'
;
LocaleFree
(
uhomedir
);
}
#ifdef LIBVLC_USE_PTHREAD
pthread_mutex_unlock
(
&
lock
);
#endif
return
homedir
;
}
}
/**
/**
...
@@ -141,14 +155,14 @@ static char *GetDir( bool b_appdata )
...
@@ -141,14 +155,14 @@ static char *GetDir( bool b_appdata )
*/
*/
char
*
config_GetHomeDir
(
void
)
char
*
config_GetHomeDir
(
void
)
{
{
return
GetDir
(
false
);
return
strdup
(
GetDir
(
false
)
);
}
}
static
char
*
config_GetFooDir
(
const
char
*
xdg_name
,
const
char
*
xdg_default
)
static
char
*
config_GetFooDir
(
const
char
*
xdg_name
,
const
char
*
xdg_default
)
{
{
char
*
psz_dir
;
char
*
psz_dir
;
#if defined(WIN32) || defined(__APPLE__) || defined(SYS_BEOS)
#if defined(WIN32) || defined(__APPLE__) || defined(SYS_BEOS)
char
*
psz_parent
=
GetDir
(
true
);
char
*
psz_parent
=
strdup
(
GetDir
(
true
)
);
if
(
asprintf
(
&
psz_dir
,
"%s"
DIR_SEP
CONFIG_DIR
,
psz_parent
)
==
-
1
)
if
(
asprintf
(
&
psz_dir
,
"%s"
DIR_SEP
CONFIG_DIR
,
psz_parent
)
==
-
1
)
psz_dir
=
NULL
;
psz_dir
=
NULL
;
...
...
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