Skip to content

Commit

Permalink
Fix digidoc-tool file extraction (#518)
Browse files Browse the repository at this point in the history
IB-7636

Signed-off-by: Raul Metsma <raul@metsma.ee>

Signed-off-by: Raul Metsma <raul@metsma.ee>
  • Loading branch information
metsma authored Jan 9, 2023
1 parent a709980 commit 3defd67
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ jobs:
env:
MAKEFLAGS: ""
VER_SUFFIX: .VS${{ matrix.toolset }}
VERSION: 3.14.11.${{ github.run_number }}
VERSION: 3.14.12.${{ github.run_number }}
VCPKG_OVERLAY_TRIPLETS: ${{ github.workspace }}/patches/vcpkg-triplets
VCPKG_OVERLAY_PORTS: ${{ github.workspace }}/patches/vcpkg-ports
steps:
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.10)
project(libdigidocpp VERSION 3.14.11)
project(libdigidocpp VERSION 3.14.12)
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif()
Expand Down
6 changes: 6 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Libdigidocpp library [3.14.12](https://github.com/open-eid/libdigidocpp/releases/tag/v3.14.12) release notes
--------------------------------------
- Fix digidoc-tool file extraction

[Full Changelog](https://github.com/open-eid/libdigidocpp/compare/v3.14.11...v3.14.12)

Libdigidocpp library [3.14.11](https://github.com/open-eid/libdigidocpp/releases/tag/v3.14.11) release notes
--------------------------------------
- Update libraries (#472, #495, #490, #500)
Expand Down
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ param(
[string]$vcpkg = "vcpkg\vcpkg.exe",
[string]$vcpkg_dir = (split-path -parent $vcpkg),
[string]$buildver = "0",
[string]$msiversion = "3.14.11.$buildver",
[string]$msiversion = "3.14.12.$buildver",
[string]$msi_name = "libdigidocpp-$msiversion$env:VER_SUFFIX.msi",
[string]$cmake = "cmake.exe",
[string]$generator = "NMake Makefiles",
Expand Down
21 changes: 9 additions & 12 deletions src/digidoc-tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,6 @@ static ostream &operator<<(ostream &os, Signature::Validator::Status status)
}
return os;
}

static string& operator+(string_view lhs, string rhs)
{
return rhs.insert(0, lhs);
}
}

/**
Expand Down Expand Up @@ -556,7 +551,7 @@ static int open(int argc, char* argv[])
{
ToolConfig::Warning reportwarnings = ToolConfig::WWarning;
string path, policy;
string_view extractPath;
fs::path extractPath;
bool validateOnExtract = false;
int returnCode = EXIT_SUCCESS;

Expand All @@ -573,11 +568,13 @@ static int open(int argc, char* argv[])
}
else if(arg.find("--extractAll") == 0)
{
extractPath = ".";
size_t pos = arg.find('=');
if(pos != string::npos)
extractPath = arg.substr(pos + 1);
if(!fs::is_directory(fs::u8path(extractPath)))
extractPath = fs::current_path();
if(auto pos = arg.find('='); pos != string::npos)
{
fs::path newPath = fs::u8path(arg.substr(pos + 1));
extractPath = newPath.is_relative() ? extractPath / newPath : newPath;
}
if(!fs::is_directory(extractPath))
THROW("Path is not directory");
}
else if(arg == "--validateOnExtract")
Expand Down Expand Up @@ -605,7 +602,7 @@ static int open(int argc, char* argv[])
for(const DataFile *file: doc->dataFiles())
{
try {
string dst = extractPath + "/" + File::fileName(file->fileName());
string dst = (extractPath / fs::u8path(file->fileName()).filename()).u8string();
file->saveAs(dst);
cout << " Document(" << file->mediaType() << ") extracted to " << dst << " (" << file->fileSize() << " bytes)" << endl;
} catch(const Exception &e) {
Expand Down

0 comments on commit 3defd67

Please sign in to comment.