-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: better long-paths support on Windows
- Loading branch information
Showing
22 changed files
with
218 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* This file is part of nzbget. See <https://nzbget.com>. | ||
* | ||
* Copyright (C) 2023 Denis <[email protected]> | ||
* Copyright (C) 2023-2024 Denis <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -21,32 +21,37 @@ | |
|
||
#include "Json.h" | ||
|
||
namespace Json { | ||
JsonValue Deserialize(std::istream& is, ErrorCode& ec) | ||
namespace Json | ||
{ | ||
std::optional<JsonValue> Deserialize(std::basic_istream<char>& is) noexcept | ||
{ | ||
ErrorCode ec; | ||
StreamParser parser; | ||
std::string line; | ||
|
||
while (std::getline(is, line)) | ||
{ | ||
parser.write(line, ec); | ||
if (ec) | ||
{ | ||
return nullptr; | ||
} | ||
if (ec) return std::nullopt; | ||
} | ||
|
||
parser.finish(ec); | ||
|
||
if (ec) | ||
{ | ||
return nullptr; | ||
} | ||
if (ec) return std::nullopt; | ||
|
||
return parser.release(); | ||
} | ||
|
||
std::string Serialize(const JsonObject& json) | ||
std::optional<JsonValue> Deserialize(const std::string& jsonStr) noexcept | ||
{ | ||
ErrorCode ec; | ||
JsonValue value = parse(jsonStr, ec); | ||
|
||
if (ec) return std::nullopt; | ||
|
||
return value; | ||
} | ||
|
||
std::string Serialize(const JsonObject& json) noexcept | ||
{ | ||
return serialize(json); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* This file is part of nzbget. See <https://nzbget.com>. | ||
* | ||
* Copyright (C) 2023 Denis <[email protected]> | ||
* Copyright (C) 2023-2024 Denis <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -22,6 +22,8 @@ | |
|
||
#include <boost/json.hpp> | ||
#include <iostream> | ||
#include <optional> | ||
#include <string> | ||
|
||
namespace Json | ||
{ | ||
|
@@ -32,8 +34,9 @@ namespace Json | |
using StreamParser = boost::json::stream_parser; | ||
using ErrorCode = boost::system::error_code; | ||
|
||
JsonValue Deserialize(std::istream& is, ErrorCode& ec); | ||
std::string Serialize(const JsonObject& json); | ||
std::optional<JsonValue> Deserialize(std::basic_istream<char>& is) noexcept; | ||
std::optional<JsonValue> Deserialize(const std::string& jsonStr) noexcept; | ||
std::string Serialize(const JsonObject& json) noexcept; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,8 @@ | |
#include "YEncode.h" | ||
|
||
#ifdef WIN32 | ||
#include "utf8.h" | ||
|
||
// getopt for WIN32: | ||
// from http://www.codeproject.com/cpp/xgetopt.asp | ||
// Original Author: Hans Dietrich ([email protected]) | ||
|
@@ -707,7 +709,15 @@ uint32 Util::HashBJ96(const char* buffer, int bufSize, uint32 initValue) | |
|
||
std::unique_ptr<FILE, std::function<void(FILE*)>> Util::MakePipe(const std::string& cmd) | ||
{ | ||
#ifdef WIN32 | ||
auto res = Utf8::Utf8ToWide(cmd); | ||
if (!res.has_value()) return nullptr; | ||
|
||
FILE* pipe = popen(res.value().c_str(), L"r"); | ||
#else | ||
FILE* pipe = popen(cmd.c_str(), "r"); | ||
#endif | ||
|
||
return std::unique_ptr<FILE, std::function<void(FILE*)>>(pipe, [](FILE* pipe) | ||
{ | ||
if (pipe) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.