fs/io/Reader: use C++ exceptions instead of class Error
This commit is contained in:
@@ -110,10 +110,7 @@ try {
|
||||
config_global_init();
|
||||
|
||||
Error error;
|
||||
if (!ReadConfigFile(config_path, error)) {
|
||||
cerr << error.GetMessage() << endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
ReadConfigFile(config_path);
|
||||
|
||||
TagLoadConfig();
|
||||
|
||||
|
@@ -65,10 +65,7 @@ try {
|
||||
config_global_init();
|
||||
|
||||
Error error;
|
||||
if (!ReadConfigFile(config_path, error)) {
|
||||
LogError(error);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
ReadConfigFile(config_path);
|
||||
|
||||
const ScopeIOThread io_thread;
|
||||
|
||||
|
@@ -20,7 +20,6 @@
|
||||
#include "config.h"
|
||||
#include "config/ConfigGlobal.hxx"
|
||||
#include "fs/Path.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <assert.h>
|
||||
@@ -39,11 +38,7 @@ try {
|
||||
|
||||
config_global_init();
|
||||
|
||||
Error error;
|
||||
if (!ReadConfigFile(config_path, error)) {
|
||||
LogError(error);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
ReadConfigFile(config_path);
|
||||
|
||||
ConfigOption option = ParseConfigOptionName(name);
|
||||
const char *value = option != ConfigOption::MAX
|
||||
|
@@ -69,7 +69,6 @@ load_filter(const char *name)
|
||||
int main(int argc, char **argv)
|
||||
try {
|
||||
struct audio_format_string af_string;
|
||||
Error error2;
|
||||
char buffer[4096];
|
||||
|
||||
if (argc < 3 || argc > 4) {
|
||||
@@ -84,8 +83,7 @@ try {
|
||||
/* read configuration file (mpd.conf) */
|
||||
|
||||
config_global_init();
|
||||
if (!ReadConfigFile(config_path, error2))
|
||||
FatalError(error2);
|
||||
ReadConfigFile(config_path);
|
||||
|
||||
/* parse the audio format */
|
||||
|
||||
|
@@ -28,32 +28,32 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static bool
|
||||
Copy(OutputStream &dest, Reader &src, Error &error)
|
||||
static void
|
||||
Copy(OutputStream &dest, Reader &src)
|
||||
{
|
||||
while (true) {
|
||||
char buffer[4096];
|
||||
size_t nbytes = src.Read(buffer, sizeof(buffer), error);
|
||||
size_t nbytes = src.Read(buffer, sizeof(buffer));
|
||||
if (nbytes == 0)
|
||||
return !error.IsDefined();
|
||||
break;
|
||||
|
||||
dest.Write(buffer, nbytes);
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
CopyGunzip(OutputStream &dest, Reader &_src, Error &error)
|
||||
static void
|
||||
CopyGunzip(OutputStream &dest, Reader &_src)
|
||||
{
|
||||
GunzipReader src(_src, error);
|
||||
return src.IsDefined() && Copy(dest, src, error);
|
||||
GunzipReader src(_src);
|
||||
Copy(dest, src);
|
||||
}
|
||||
|
||||
static bool
|
||||
CopyGunzip(FILE *_dest, Path src_path, Error &error)
|
||||
static void
|
||||
CopyGunzip(FILE *_dest, Path src_path)
|
||||
{
|
||||
StdioOutputStream dest(_dest);
|
||||
FileReader src(src_path, error);
|
||||
return src.IsDefined() && CopyGunzip(dest, src, error);
|
||||
FileReader src(src_path);
|
||||
CopyGunzip(dest, src);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -67,12 +67,7 @@ main(int argc, gcc_unused char **argv)
|
||||
Path path = Path::FromFS(argv[1]);
|
||||
|
||||
try {
|
||||
Error error;
|
||||
if (!CopyGunzip(stdout, path, error)) {
|
||||
fprintf(stderr, "%s\n", error.GetMessage());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
CopyGunzip(stdout, path);
|
||||
return EXIT_SUCCESS;
|
||||
} catch (const std::exception &e) {
|
||||
LogError(e);
|
||||
|
@@ -59,10 +59,7 @@ try {
|
||||
Error error;
|
||||
|
||||
config_global_init();
|
||||
if (!ReadConfigFile(config_path, error)) {
|
||||
LogError(error);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
ReadConfigFile(config_path);
|
||||
|
||||
/* initialize the core */
|
||||
|
||||
|
@@ -161,10 +161,7 @@ try {
|
||||
/* read configuration file (mpd.conf) */
|
||||
|
||||
config_global_init();
|
||||
if (!ReadConfigFile(config_path, error)) {
|
||||
LogError(error);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
ReadConfigFile(config_path);
|
||||
|
||||
EventLoop event_loop;
|
||||
|
||||
|
Reference in New Issue
Block a user