Lightweight 0.20261105.1
Loading...
Searching...
No Matches
ZipPath.hpp
1// SPDX-License-Identifier: Apache-2.0
2
3#pragma once
4
5#include <filesystem>
6#include <string>
7
8namespace Lightweight::Zip
9{
10
11/// The bytes libzip expects for a file path: UTF-8, where `path.string()` would give the ANSI code page on Windows.
12///
13/// @param path The archive file.
14/// @return The path as UTF-8 bytes.
15[[nodiscard]] inline std::string ZipPathUtf8(std::filesystem::path const& path)
16{
17 auto const utf8 = path.u8string();
18 return std::string { reinterpret_cast<char const*>(utf8.data()), utf8.size() };
19}
20
21} // namespace Lightweight::Zip