Merge tag 'v0.21.22'
release v0.21.22
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "decoder/DecoderList.hxx"
|
||||
#include "decoder/DecoderPlugin.hxx"
|
||||
#include "fs/Path.hxx"
|
||||
#include "fs/NarrowPath.hxx"
|
||||
#include "fs/io/StdioOutputStream.hxx"
|
||||
#include "fs/io/BufferedOutputStream.hxx"
|
||||
#include "util/PrintException.hxx"
|
||||
@@ -63,7 +64,7 @@ try {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
const Path path = Path::FromFS(argv[1]);
|
||||
const FromNarrowPath path = argv[1];
|
||||
|
||||
const ScopeDecoderPluginsInit decoder_plugins_init({});
|
||||
|
||||
|
@@ -29,6 +29,7 @@
|
||||
#include "ConfigGlue.hxx"
|
||||
#include "tag/Config.hxx"
|
||||
#include "fs/Path.hxx"
|
||||
#include "fs/NarrowPath.hxx"
|
||||
#include "event/Thread.hxx"
|
||||
#include "util/ScopeExit.hxx"
|
||||
#include "util/PrintException.hxx"
|
||||
@@ -106,7 +107,7 @@ try {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const Path config_path = Path::FromFS(argv[1]);
|
||||
const FromNarrowPath config_path = argv[1];
|
||||
const char *const plugin_name = argv[2];
|
||||
|
||||
const DatabasePlugin *plugin = GetDatabasePluginByName(plugin_name);
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include "tag/ApeLoader.hxx"
|
||||
#include "thread/Mutex.hxx"
|
||||
#include "fs/Path.hxx"
|
||||
#include "fs/NarrowPath.hxx"
|
||||
#include "input/InputStream.hxx"
|
||||
#include "input/LocalOpen.hxx"
|
||||
#include "util/StringView.hxx"
|
||||
@@ -58,7 +59,7 @@ try {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
const Path path = Path::FromFS(argv[1]);
|
||||
const FromNarrowPath path = argv[1];
|
||||
|
||||
Mutex mutex;
|
||||
|
||||
|
@@ -29,8 +29,8 @@ public:
|
||||
};
|
||||
|
||||
#ifdef _WIN32
|
||||
ShutdownHandler::ShutdownHandler(EventLoop &loop) {}
|
||||
ShutdownHandler::~ShutdownHandler() {}
|
||||
inline ShutdownHandler::ShutdownHandler(EventLoop &) {}
|
||||
inline ShutdownHandler::~ShutdownHandler() {}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "fs/io/FileOutputStream.hxx"
|
||||
#include "fs/NarrowPath.hxx"
|
||||
#include "util/PrintException.hxx"
|
||||
|
||||
#include <cerrno>
|
||||
@@ -55,7 +56,7 @@ try {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
const Path path = Path::FromFS(argv[1]);
|
||||
const FromNarrowPath path = argv[1];
|
||||
|
||||
FileOutputStream fos(path);
|
||||
|
||||
|
@@ -28,6 +28,7 @@
|
||||
#include "playlist/PlaylistRegistry.hxx"
|
||||
#include "playlist/PlaylistPlugin.hxx"
|
||||
#include "fs/Path.hxx"
|
||||
#include "fs/NarrowPath.hxx"
|
||||
#include "fs/io/BufferedOutputStream.hxx"
|
||||
#include "fs/io/StdioOutputStream.hxx"
|
||||
#include "thread/Cond.hxx"
|
||||
@@ -54,7 +55,7 @@ try {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
const Path config_path = Path::FromFS(argv[1]);
|
||||
const FromNarrowPath config_path = argv[1];
|
||||
uri = argv[2];
|
||||
|
||||
/* initialize MPD */
|
||||
|
@@ -24,6 +24,7 @@ gtest_dep = declare_dependency(
|
||||
)
|
||||
|
||||
subdir('net')
|
||||
subdir('time')
|
||||
|
||||
executable(
|
||||
'read_conf',
|
||||
@@ -52,19 +53,6 @@ test('TestUtil', executable(
|
||||
],
|
||||
))
|
||||
|
||||
test(
|
||||
'TestTime',
|
||||
executable(
|
||||
'TestTime',
|
||||
'TestISO8601.cxx',
|
||||
include_directories: inc,
|
||||
dependencies: [
|
||||
time_dep,
|
||||
gtest_dep,
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
test('TestRewindInputStream', executable(
|
||||
'TestRewindInputStream',
|
||||
'TestRewindInputStream.cxx',
|
||||
@@ -326,6 +314,11 @@ if curl_dep.found()
|
||||
include_directories: inc,
|
||||
dependencies: [
|
||||
curl_dep,
|
||||
|
||||
# Explicitly linking with zlib here works around a linker
|
||||
# failure on Windows, because our Windows CURL build is
|
||||
# statically linked and thus declares no dependency on zlib
|
||||
zlib_dep,
|
||||
],
|
||||
)
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 Max Kellermann <max.kellermann@gmail.com>
|
||||
* Copyright 2012-2020 Max Kellermann <max.kellermann@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -34,13 +34,22 @@
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
static std::string
|
||||
ToString(const struct in_addr &a)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
/* on mingw32, the parameter is non-const (PVOID) */
|
||||
const auto p = const_cast<struct in_addr *>(&a);
|
||||
#else
|
||||
const auto p = &a;
|
||||
#endif
|
||||
|
||||
char buffer[256];
|
||||
const char *result = inet_ntop(AF_INET, &a, buffer, sizeof(buffer));
|
||||
const char *result = inet_ntop(AF_INET, p, buffer, sizeof(buffer));
|
||||
if (result == nullptr)
|
||||
throw std::runtime_error("inet_ntop() failed");
|
||||
return result;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 Max Kellermann <max.kellermann@gmail.com>
|
||||
* Copyright 2012-2020 Max Kellermann <max.kellermann@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -34,13 +34,22 @@
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
static std::string
|
||||
ToString(const struct in6_addr &a)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
/* on mingw32, the parameter is non-const (PVOID) */
|
||||
const auto p = const_cast<struct in6_addr *>(&a);
|
||||
#else
|
||||
const auto p = &a;
|
||||
#endif
|
||||
|
||||
char buffer[256];
|
||||
const char *result = inet_ntop(AF_INET6, &a, buffer, sizeof(buffer));
|
||||
const char *result = inet_ntop(AF_INET6, p, buffer, sizeof(buffer));
|
||||
if (result == nullptr)
|
||||
throw std::runtime_error("inet_ntop() failed");
|
||||
return result;
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include "config/Param.hxx"
|
||||
#include "config/File.hxx"
|
||||
#include "fs/Path.hxx"
|
||||
#include "fs/NarrowPath.hxx"
|
||||
#include "util/PrintException.hxx"
|
||||
#include "util/RuntimeError.hxx"
|
||||
|
||||
@@ -34,7 +35,7 @@ try {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
const Path config_path = Path::FromFS(argv[1]);
|
||||
const FromNarrowPath config_path = argv[1];
|
||||
const char *name = argv[2];
|
||||
|
||||
const auto option = ParseConfigOptionName(name);
|
||||
|
@@ -27,6 +27,7 @@
|
||||
#include "tag/Handler.hxx"
|
||||
#include "tag/Generic.hxx"
|
||||
#include "fs/Path.hxx"
|
||||
#include "fs/NarrowPath.hxx"
|
||||
#include "pcm/AudioFormat.hxx"
|
||||
#include "util/ScopeExit.hxx"
|
||||
#include "util/StringBuffer.hxx"
|
||||
@@ -97,7 +98,7 @@ try {
|
||||
}
|
||||
|
||||
decoder_name = argv[1];
|
||||
const Path path = Path::FromFS(argv[2]);
|
||||
const char *path = argv[2];
|
||||
|
||||
EventThread io_thread;
|
||||
io_thread.Start();
|
||||
@@ -116,7 +117,7 @@ try {
|
||||
DumpTagHandler h;
|
||||
bool success;
|
||||
try {
|
||||
success = plugin->ScanFile(path, h);
|
||||
success = plugin->ScanFile(FromNarrowPath(path), h);
|
||||
} catch (...) {
|
||||
PrintException(std::current_exception());
|
||||
success = false;
|
||||
@@ -126,7 +127,7 @@ try {
|
||||
InputStreamPtr is;
|
||||
|
||||
if (!success && plugin->scan_stream != nullptr) {
|
||||
is = InputStream::OpenReady(path.c_str(), mutex);
|
||||
is = InputStream::OpenReady(path, mutex);
|
||||
success = plugin->ScanStream(*is, h);
|
||||
}
|
||||
|
||||
@@ -139,7 +140,7 @@ try {
|
||||
if (is)
|
||||
ScanGenericTags(*is, h);
|
||||
else
|
||||
ScanGenericTags(path, h);
|
||||
ScanGenericTags(FromNarrowPath(path), h);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include "input/Init.hxx"
|
||||
#include "input/InputStream.hxx"
|
||||
#include "fs/Path.hxx"
|
||||
#include "fs/NarrowPath.hxx"
|
||||
#include "pcm/AudioFormat.hxx"
|
||||
#include "util/OptionDef.hxx"
|
||||
#include "util/OptionParser.hxx"
|
||||
@@ -44,7 +45,7 @@ struct CommandLine {
|
||||
const char *decoder = nullptr;
|
||||
const char *uri = nullptr;
|
||||
|
||||
Path config_path = nullptr;
|
||||
FromNarrowPath config_path;
|
||||
|
||||
bool verbose = false;
|
||||
|
||||
@@ -72,7 +73,7 @@ ParseCommandLine(int argc, char **argv)
|
||||
while (auto o = option_parser.Next()) {
|
||||
switch (Option(o.index)) {
|
||||
case OPTION_CONFIG:
|
||||
c.config_path = Path::FromFS(o.value);
|
||||
c.config_path = o.value;
|
||||
break;
|
||||
|
||||
case OPTION_VERBOSE:
|
||||
@@ -205,7 +206,7 @@ try {
|
||||
MyDecoderClient client(c.seek_where);
|
||||
if (plugin->file_decode != nullptr) {
|
||||
try {
|
||||
plugin->FileDecode(client, Path::FromFS(c.uri));
|
||||
plugin->FileDecode(client, FromNarrowPath(c.uri));
|
||||
} catch (StopDecoder) {
|
||||
}
|
||||
} else if (plugin->stream_decode != nullptr) {
|
||||
|
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "ConfigGlue.hxx"
|
||||
#include "fs/Path.hxx"
|
||||
#include "fs/NarrowPath.hxx"
|
||||
#include "filter/LoadOne.hxx"
|
||||
#include "filter/Filter.hxx"
|
||||
#include "filter/Prepared.hxx"
|
||||
@@ -123,7 +124,7 @@ try {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
const Path config_path = Path::FromFS(argv[1]);
|
||||
const FromNarrowPath config_path = argv[1];
|
||||
|
||||
AudioFormat audio_format(44100, SampleFormat::S16, 2);
|
||||
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#include "fs/io/GunzipReader.hxx"
|
||||
#include "fs/io/FileReader.hxx"
|
||||
#include "fs/io/StdioOutputStream.hxx"
|
||||
#include "fs/NarrowPath.hxx"
|
||||
#include "util/PrintException.hxx"
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -62,7 +63,7 @@ try {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
Path path = Path::FromFS(argv[1]);
|
||||
FromNarrowPath path = argv[1];
|
||||
|
||||
CopyGunzip(stdout, path);
|
||||
return EXIT_SUCCESS;
|
||||
|
@@ -32,6 +32,7 @@
|
||||
#include "Log.hxx"
|
||||
#include "LogBackend.hxx"
|
||||
#include "fs/Path.hxx"
|
||||
#include "fs/NarrowPath.hxx"
|
||||
#include "fs/io/BufferedOutputStream.hxx"
|
||||
#include "fs/io/StdioOutputStream.hxx"
|
||||
#include "util/ConstBuffer.hxx"
|
||||
@@ -51,7 +52,7 @@
|
||||
struct CommandLine {
|
||||
const char *uri = nullptr;
|
||||
|
||||
Path config_path = nullptr;
|
||||
FromNarrowPath config_path;
|
||||
|
||||
bool verbose = false;
|
||||
|
||||
@@ -79,7 +80,7 @@ ParseCommandLine(int argc, char **argv)
|
||||
while (auto o = option_parser.Next()) {
|
||||
switch (Option(o.index)) {
|
||||
case OPTION_CONFIG:
|
||||
c.config_path = Path::FromFS(o.value);
|
||||
c.config_path = o.value;
|
||||
break;
|
||||
|
||||
case OPTION_VERBOSE:
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#include "ConfigGlue.hxx"
|
||||
#include "event/Thread.hxx"
|
||||
#include "fs/Path.hxx"
|
||||
#include "fs/NarrowPath.hxx"
|
||||
#include "pcm/AudioParser.hxx"
|
||||
#include "pcm/AudioFormat.hxx"
|
||||
#include "util/StringBuffer.hxx"
|
||||
@@ -111,7 +112,7 @@ try {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
const Path config_path = Path::FromFS(argv[1]);
|
||||
const FromNarrowPath config_path = argv[1];
|
||||
|
||||
AudioFormat audio_format(44100, SampleFormat::S16, 2);
|
||||
|
||||
|
65
test/time/TestConvert.cxx
Normal file
65
test/time/TestConvert.cxx
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2020 Max Kellermann <max.kellermann@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* author: Max Kellermann <mk@cm4all.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "time/Convert.hxx"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
static constexpr time_t times[] = {
|
||||
1234567890,
|
||||
1580566807,
|
||||
1585750807,
|
||||
1590934807,
|
||||
};
|
||||
|
||||
TEST(Time, LocalTime)
|
||||
{
|
||||
/* convert back and forth using local time zone */
|
||||
|
||||
for (const auto t : times) {
|
||||
auto tp = std::chrono::system_clock::from_time_t(t);
|
||||
auto tm = LocalTime(tp);
|
||||
EXPECT_EQ(MakeTime(tm), tp);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Time, GmTime)
|
||||
{
|
||||
/* convert back and forth using UTC */
|
||||
|
||||
for (const auto t : times) {
|
||||
auto tp = std::chrono::system_clock::from_time_t(t);
|
||||
auto tm = GmTime(tp);
|
||||
EXPECT_EQ(std::chrono::system_clock::to_time_t(TimeGm(tm)),
|
||||
t);
|
||||
}
|
||||
}
|
17
test/time/meson.build
Normal file
17
test/time/meson.build
Normal file
@@ -0,0 +1,17 @@
|
||||
test_time_sources = [
|
||||
'TestConvert.cxx',
|
||||
'TestISO8601.cxx',
|
||||
]
|
||||
|
||||
test(
|
||||
'TestTime',
|
||||
executable(
|
||||
'TestTime',
|
||||
test_time_sources,
|
||||
include_directories: inc,
|
||||
dependencies: [
|
||||
time_dep,
|
||||
gtest_dep,
|
||||
],
|
||||
),
|
||||
)
|
Reference in New Issue
Block a user