Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
225d85fd
Commit
225d85fd
authored
Oct 26, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs/StandardDirectory: use "if" with initializer
parent
1bb22f11
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
17 deletions
+14
-17
StandardDirectory.cxx
src/fs/StandardDirectory.cxx
+14
-17
No files found.
src/fs/StandardDirectory.cxx
View file @
225d85fd
...
@@ -228,13 +228,12 @@ GetUserConfigDir() noexcept
...
@@ -228,13 +228,12 @@ GetUserConfigDir() noexcept
return
GetStandardDir
(
CSIDL_LOCAL_APPDATA
);
return
GetStandardDir
(
CSIDL_LOCAL_APPDATA
);
#elif defined(USE_XDG)
#elif defined(USE_XDG)
// Check for $XDG_CONFIG_HOME
// Check for $XDG_CONFIG_HOME
auto
config_home
=
getenv
(
"XDG_CONFIG_HOME"
);
if
(
const
auto
config_home
=
getenv
(
"XDG_CONFIG_HOME"
);
if
(
IsValidPathString
(
config_home
)
&&
IsValidDir
(
config_home
))
IsValidPathString
(
config_home
)
&&
IsValidDir
(
config_home
))
return
AllocatedPath
::
FromFS
(
config_home
);
return
AllocatedPath
::
FromFS
(
config_home
);
// Check for $HOME/.config
// Check for $HOME/.config
auto
home
=
GetHomeDir
();
if
(
const
auto
home
=
GetHomeDir
();
!
home
.
IsNull
())
{
if
(
!
home
.
IsNull
())
{
auto
fallback
=
home
/
Path
::
FromFS
(
".config"
);
auto
fallback
=
home
/
Path
::
FromFS
(
".config"
);
if
(
IsValidDir
(
fallback
.
c_str
()))
if
(
IsValidDir
(
fallback
.
c_str
()))
return
fallback
;
return
fallback
;
...
@@ -265,17 +264,15 @@ GetUserCacheDir() noexcept
...
@@ -265,17 +264,15 @@ GetUserCacheDir() noexcept
{
{
#ifdef USE_XDG
#ifdef USE_XDG
// Check for $XDG_CACHE_HOME
// Check for $XDG_CACHE_HOME
auto
cache_home
=
getenv
(
"XDG_CACHE_HOME"
);
if
(
const
auto
cache_home
=
getenv
(
"XDG_CACHE_HOME"
);
if
(
IsValidPathString
(
cache_home
)
&&
IsValidDir
(
cache_home
))
IsValidPathString
(
cache_home
)
&&
IsValidDir
(
cache_home
))
return
AllocatedPath
::
FromFS
(
cache_home
);
return
AllocatedPath
::
FromFS
(
cache_home
);
// Check for $HOME/.cache
// Check for $HOME/.cache
auto
home
=
GetHomeDir
();
if
(
const
auto
home
=
GetHomeDir
();
!
home
.
IsNull
())
if
(
!
home
.
IsNull
())
{
if
(
auto
fallback
=
home
/
Path
::
FromFS
(
".cache"
);
auto
fallback
=
home
/
Path
::
FromFS
(
".cache"
);
IsValidDir
(
fallback
.
c_str
()))
if
(
IsValidDir
(
fallback
.
c_str
()))
return
fallback
;
return
fallback
;
}
return
nullptr
;
return
nullptr
;
#elif defined(ANDROID)
#elif defined(ANDROID)
...
@@ -317,11 +314,11 @@ AllocatedPath
...
@@ -317,11 +314,11 @@ AllocatedPath
GetHomeDir
()
noexcept
GetHomeDir
()
noexcept
{
{
#ifndef ANDROID
#ifndef ANDROID
auto
home
=
getenv
(
"HOME"
);
if
(
const
auto
home
=
getenv
(
"HOME"
);
if
(
IsValidPathString
(
home
)
&&
IsValidDir
(
home
))
IsValidPathString
(
home
)
&&
IsValidDir
(
home
))
return
AllocatedPath
::
FromFS
(
home
);
return
AllocatedPath
::
FromFS
(
home
);
PasswdEntry
pw
;
if
(
pw
.
ReadByUid
(
getuid
()))
if
(
PasswdEntry
pw
;
pw
.
ReadByUid
(
getuid
()))
return
SafePathFromFS
(
pw
->
pw_dir
);
return
SafePathFromFS
(
pw
->
pw_dir
);
#endif
#endif
return
nullptr
;
return
nullptr
;
...
@@ -334,8 +331,8 @@ GetHomeDir(const char *user_name) noexcept
...
@@ -334,8 +331,8 @@ GetHomeDir(const char *user_name) noexcept
(
void
)
user_name
;
(
void
)
user_name
;
#else
#else
assert
(
user_name
!=
nullptr
);
assert
(
user_name
!=
nullptr
);
PasswdEntry
pw
;
if
(
pw
.
ReadByName
(
user_name
))
if
(
PasswdEntry
pw
;
pw
.
ReadByName
(
user_name
))
return
SafePathFromFS
(
pw
->
pw_dir
);
return
SafePathFromFS
(
pw
->
pw_dir
);
#endif
#endif
return
nullptr
;
return
nullptr
;
...
...
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