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
7a341516
Commit
7a341516
authored
Oct 28, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config/Param: add method GetPath()
Move code from config_parse_path().
parent
5b2b4bf1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
21 deletions
+26
-21
Listen.cxx
src/Listen.cxx
+1
-1
ConfigGlobal.cxx
src/config/ConfigGlobal.cxx
+1
-12
ConfigGlobal.hxx
src/config/ConfigGlobal.hxx
+0
-8
Param.cxx
src/config/Param.cxx
+14
-0
Param.hxx
src/config/Param.hxx
+10
-0
No files found.
src/Listen.cxx
View file @
7a341516
...
...
@@ -68,7 +68,7 @@ listen_add_config_param(unsigned int port,
if
(
0
==
strcmp
(
param
->
value
.
c_str
(),
"any"
))
{
return
listen_socket
->
AddPort
(
port
,
error_r
);
}
else
if
(
param
->
value
[
0
]
==
'/'
||
param
->
value
[
0
]
==
'~'
)
{
auto
path
=
config_parse_path
(
param
,
error_r
);
auto
path
=
param
->
GetPath
(
error_r
);
return
!
path
.
IsNull
()
&&
listen_socket
->
AddPath
(
std
::
move
(
path
),
error_r
);
}
else
{
...
...
src/config/ConfigGlobal.cxx
View file @
7a341516
...
...
@@ -128,18 +128,7 @@ config_get_path(ConfigOption option, Error &error)
if
(
param
==
nullptr
)
return
AllocatedPath
::
Null
();
return
config_parse_path
(
param
,
error
);
}
AllocatedPath
config_parse_path
(
const
ConfigParam
*
param
,
Error
&
error
)
{
AllocatedPath
path
=
ParsePath
(
param
->
value
.
c_str
(),
error
);
if
(
gcc_unlikely
(
path
.
IsNull
()))
error
.
FormatPrefix
(
"Invalid path at line %i: "
,
param
->
line
);
return
path
;
return
param
->
GetPath
(
error
);
}
unsigned
...
...
src/config/ConfigGlobal.hxx
View file @
7a341516
...
...
@@ -84,14 +84,6 @@ config_get_string(enum ConfigOption option, const char *default_value=nullptr);
AllocatedPath
config_get_path
(
enum
ConfigOption
option
,
Error
&
error
);
/**
* Parse a configuration parameter as a path.
* If there is a tilde prefix, it is expanded. If the path could
* not be parsed, returns AllocatedPath::Null() and sets the error.
*/
AllocatedPath
config_parse_path
(
const
ConfigParam
*
param
,
Error
&
error_r
);
gcc_pure
unsigned
config_get_unsigned
(
enum
ConfigOption
option
,
unsigned
default_value
);
...
...
src/config/Param.cxx
View file @
7a341516
...
...
@@ -19,6 +19,9 @@
#include "config.h"
#include "Param.hxx"
#include "ConfigPath.hxx"
#include "fs/AllocatedPath.hxx"
#include "util/Error.hxx"
ConfigParam
::
ConfigParam
(
const
char
*
_value
,
int
_line
)
:
next
(
nullptr
),
value
(
_value
),
line
(
_line
),
used
(
false
)
{}
...
...
@@ -27,3 +30,14 @@ ConfigParam::~ConfigParam()
{
delete
next
;
}
AllocatedPath
ConfigParam
::
GetPath
(
Error
&
error
)
const
{
auto
path
=
ParsePath
(
value
.
c_str
(),
error
);
if
(
gcc_unlikely
(
path
.
IsNull
()))
error
.
FormatPrefix
(
"Invalid path at line %i: "
,
line
);
return
path
;
}
src/config/Param.hxx
View file @
7a341516
...
...
@@ -25,6 +25,9 @@
#include <string>
class
Error
;
class
AllocatedPath
;
struct
ConfigParam
{
/**
* The next ConfigParam with the same name. The destructor
...
...
@@ -62,6 +65,13 @@ struct ConfigParam {
bool
IsNull
()
const
{
return
line
<
0
;
}
/**
* Parse the value as a path. If there is a tilde prefix, it
* is expanded. If the path could not be parsed, returns
* AllocatedPath::Null() and sets the error.
*/
AllocatedPath
GetPath
(
Error
&
error
)
const
;
};
#endif
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