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