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
e17805f2
Commit
e17805f2
authored
Oct 28, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config/Block: GetPath() throws exception on error
parent
d8bcdca5
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
23 additions
and
55 deletions
+23
-55
Block.cxx
src/config/Block.cxx
+5
-12
Block.hxx
src/config/Block.hxx
+4
-4
SimpleDatabasePlugin.cxx
src/db/plugins/simple/SimpleDatabasePlugin.cxx
+8
-20
SimpleDatabasePlugin.hxx
src/db/plugins/simple/SimpleDatabasePlugin.hxx
+1
-1
SidplayDecoderPlugin.cxx
src/decoder/plugins/SidplayDecoderPlugin.cxx
+1
-4
WildmidiDecoderPlugin.cxx
src/decoder/plugins/WildmidiDecoderPlugin.cxx
+1
-5
FifoOutputPlugin.cxx
src/output/plugins/FifoOutputPlugin.cxx
+2
-6
RecorderOutputPlugin.cxx
src/output/plugins/RecorderOutputPlugin.cxx
+1
-3
No files found.
src/config/Block.cxx
View file @
e17805f2
...
...
@@ -23,6 +23,7 @@
#include "ConfigPath.hxx"
#include "system/FatalError.hxx"
#include "fs/AllocatedPath.hxx"
#include "util/RuntimeError.hxx"
#include "util/Error.hxx"
#include <assert.h>
...
...
@@ -91,11 +92,8 @@ ConfigBlock::GetBlockValue(const char *name, const char *default_value) const
}
AllocatedPath
ConfigBlock
::
GetPath
(
const
char
*
name
,
const
char
*
default_value
,
Error
&
error
)
const
ConfigBlock
::
GetPath
(
const
char
*
name
,
const
char
*
default_value
)
const
{
assert
(
!
error
.
IsDefined
());
int
line2
=
line
;
const
char
*
s
;
...
...
@@ -110,20 +108,15 @@ ConfigBlock::GetPath(const char *name, const char *default_value,
s
=
default_value
;
}
Error
error
;
AllocatedPath
path
=
ParsePath
(
s
,
error
);
if
(
gcc_unlikely
(
path
.
IsNull
()))
error
.
FormatPrefix
(
"Invalid path in
\"
%s
\"
at line %i:
"
,
name
,
line2
);
throw
FormatRuntimeError
(
"Invalid path in
\"
%s
\"
at line %i: %s
"
,
name
,
line2
,
error
.
GetMessage
()
);
return
path
;
}
AllocatedPath
ConfigBlock
::
GetPath
(
const
char
*
name
,
Error
&
error
)
const
{
return
GetPath
(
name
,
nullptr
,
error
);
}
int
ConfigBlock
::
GetBlockValue
(
const
char
*
name
,
int
default_value
)
const
{
...
...
src/config/Block.hxx
View file @
e17805f2
...
...
@@ -111,11 +111,11 @@ struct ConfigBlock {
/**
* Same as config_get_path(), but looks up the setting in the
* specified block.
*
* Throws #std::runtime_error on error.
*/
AllocatedPath
GetPath
(
const
char
*
name
,
const
char
*
default_value
,
Error
&
error
)
const
;
AllocatedPath
GetPath
(
const
char
*
name
,
Error
&
error
)
const
;
AllocatedPath
GetPath
(
const
char
*
name
,
const
char
*
default_value
=
nullptr
)
const
;
gcc_pure
int
GetBlockValue
(
const
char
*
name
,
int
default_value
)
const
;
...
...
src/db/plugins/simple/SimpleDatabasePlugin.cxx
View file @
e17805f2
...
...
@@ -78,39 +78,27 @@ inline SimpleDatabase::SimpleDatabase(AllocatedPath &&_path,
Database
*
SimpleDatabase
::
Create
(
gcc_unused
EventLoop
&
loop
,
gcc_unused
DatabaseListener
&
listener
,
const
ConfigBlock
&
block
,
Error
&
error
)
const
ConfigBlock
&
block
,
Error
&
)
{
SimpleDatabase
*
db
=
new
SimpleDatabase
();
if
(
!
db
->
Configure
(
block
,
error
))
{
delete
db
;
db
=
nullptr
;
}
db
->
Configure
(
block
);
return
db
;
}
bool
SimpleDatabase
::
Configure
(
const
ConfigBlock
&
block
,
Error
&
error
)
void
SimpleDatabase
::
Configure
(
const
ConfigBlock
&
block
)
{
path
=
block
.
GetPath
(
"path"
,
error
);
if
(
path
.
IsNull
())
{
if
(
!
error
.
IsDefined
())
error
.
Set
(
simple_db_domain
,
"No
\"
path
\"
parameter specified"
);
return
false
;
}
path
=
block
.
GetPath
(
"path"
);
if
(
path
.
IsNull
())
throw
std
::
runtime_error
(
"No
\"
path
\"
parameter specified"
);
path_utf8
=
path
.
ToUTF8
();
cache_path
=
block
.
GetPath
(
"cache_directory"
,
error
);
if
(
path
.
IsNull
()
&&
error
.
IsDefined
())
return
false
;
cache_path
=
block
.
GetPath
(
"cache_directory"
);
#ifdef ENABLE_ZLIB
compress
=
block
.
GetBlockValue
(
"compress"
,
compress
);
#endif
return
true
;
}
void
...
...
src/db/plugins/simple/SimpleDatabasePlugin.hxx
View file @
e17805f2
...
...
@@ -133,7 +133,7 @@ public:
}
private
:
bool
Configure
(
const
ConfigBlock
&
block
,
Error
&
error
);
void
Configure
(
const
ConfigBlock
&
block
);
void
Check
()
const
;
...
...
src/decoder/plugins/SidplayDecoderPlugin.cxx
View file @
e17805f2
...
...
@@ -85,12 +85,9 @@ static bool
sidplay_init
(
const
ConfigBlock
&
block
)
{
/* read the songlengths database file */
Error
error
;
const
auto
database_path
=
block
.
GetPath
(
"songlength_database"
,
error
);
const
auto
database_path
=
block
.
GetPath
(
"songlength_database"
);
if
(
!
database_path
.
IsNull
())
songlength_database
=
sidplay_load_songlength_db
(
database_path
);
else
if
(
error
.
IsDefined
())
FatalError
(
error
);
default_songlength
=
block
.
GetBlockValue
(
"default_songlength"
,
0u
);
...
...
src/decoder/plugins/WildmidiDecoderPlugin.cxx
View file @
e17805f2
...
...
@@ -40,13 +40,9 @@ static constexpr unsigned WILDMIDI_SAMPLE_RATE = 48000;
static
bool
wildmidi_init
(
const
ConfigBlock
&
block
)
{
Error
error
;
const
AllocatedPath
path
=
block
.
GetPath
(
"config_file"
,
"/etc/timidity/timidity.cfg"
,
error
);
if
(
path
.
IsNull
())
FatalError
(
error
);
"/etc/timidity/timidity.cfg"
);
if
(
!
FileExists
(
path
))
{
const
auto
utf8
=
path
.
ToUTF8
();
...
...
src/output/plugins/FifoOutputPlugin.cxx
View file @
e17805f2
...
...
@@ -183,14 +183,10 @@ FifoOutput::Create(const ConfigBlock &block, Error &error)
{
FifoOutput
*
fd
=
new
FifoOutput
();
fd
->
path
=
block
.
GetPath
(
"path"
,
error
);
fd
->
path
=
block
.
GetPath
(
"path"
);
if
(
fd
->
path
.
IsNull
())
{
delete
fd
;
if
(
!
error
.
IsDefined
())
error
.
Set
(
config_domain
,
"No
\"
path
\"
parameter specified"
);
return
nullptr
;
throw
std
::
runtime_error
(
"No
\"
path
\"
parameter specified"
);
}
fd
->
path_utf8
=
fd
->
path
.
ToUTF8
();
...
...
src/output/plugins/RecorderOutputPlugin.cxx
View file @
e17805f2
...
...
@@ -128,9 +128,7 @@ RecorderOutput::Configure(const ConfigBlock &block, Error &error)
return
false
;
}
path
=
block
.
GetPath
(
"path"
,
error
);
if
(
error
.
IsDefined
())
return
false
;
path
=
block
.
GetPath
(
"path"
);
const
char
*
fmt
=
block
.
GetBlockValue
(
"format_path"
,
nullptr
);
if
(
fmt
!=
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