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
5f95c073
Commit
5f95c073
authored
Aug 19, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config/Path: add InitPathParser()
Eliminate yet another access to the global ConfigData instance.
parent
1a9659ef
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
6 deletions
+23
-6
Main.cxx
src/Main.cxx
+2
-0
Path.cxx
src/config/Path.cxx
+16
-5
Path.hxx
src/config/Path.hxx
+5
-1
No files found.
src/Main.cxx
View file @
5f95c073
...
...
@@ -55,6 +55,7 @@
#include "config/Global.hxx"
#include "config/Data.hxx"
#include "config/Param.hxx"
#include "config/Path.hxx"
#include "config/Defaults.hxx"
#include "config/Option.hxx"
#include "config/Domain.hxx"
...
...
@@ -491,6 +492,7 @@ MainOrThrow(int argc, char *argv[])
#endif
const
auto
&
raw_config
=
GetGlobalConfig
();
InitPathParser
(
raw_config
);
const
auto
config
=
LoadConfig
(
raw_config
);
#ifdef ENABLE_DAEMON
...
...
src/config/Path.cxx
View file @
5f95c073
/*
* Copyright 2003-201
7
The Music Player Daemon Project
* Copyright 2003-201
8
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -19,7 +19,7 @@
#include "config.h"
#include "Path.hxx"
#include "
Global
.hxx"
#include "
Data
.hxx"
#include "fs/AllocatedPath.hxx"
#include "fs/Traits.hxx"
#include "fs/Domain.hxx"
...
...
@@ -32,6 +32,8 @@
#ifndef _WIN32
#include <pwd.h>
static
const
char
*
configured_user
=
nullptr
;
/**
* Determine a given user's home directory.
*/
...
...
@@ -66,14 +68,23 @@ GetHome()
static
AllocatedPath
GetConfiguredHome
()
{
const
char
*
user
=
config_get_string
(
ConfigOption
::
USER
);
return
user
!=
nullptr
?
GetHome
(
user
)
return
configured_user
!=
nullptr
?
GetHome
(
configured_user
)
:
GetHome
();
}
#endif
void
InitPathParser
(
const
ConfigData
&
config
)
noexcept
{
#ifdef _WIN32
(
void
)
config
;
#else
configured_user
=
config
.
GetString
(
ConfigOption
::
USER
);
#endif
}
AllocatedPath
ParsePath
(
const
char
*
path
)
{
...
...
src/config/Path.hxx
View file @
5f95c073
/*
* Copyright 2003-201
7
The Music Player Daemon Project
* Copyright 2003-201
8
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -20,8 +20,12 @@
#ifndef MPD_CONFIG_PATH_HXX
#define MPD_CONFIG_PATH_HXX
struct
ConfigData
;
class
AllocatedPath
;
void
InitPathParser
(
const
ConfigData
&
config
)
noexcept
;
/**
* Throws #std::runtime_error on error.
*/
...
...
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