Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 13 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
cd /Library
zip -q -r ${OLDPWD}/libdigidocpp.${{ matrix.target }}.zip libdigidocpp.*
- name: Archive artifacts
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v5
with:
name: ${{ matrix.target }}
path: |
Expand All @@ -84,32 +84,24 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Expose Android NDK env
shell: bash
run: |
echo "ANDROID_NDK_HOME=$ANDROID_NDK_LATEST_HOME" >> "$GITHUB_ENV"
echo "ANDROID_NDK_ROOT=$ANDROID_NDK_LATEST_HOME" >> "$GITHUB_ENV"
- name: Cache vcpkg
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/vcpkg_cache
key: vcpkg-${{ matrix.target }}-${{ hashFiles('vcpkg.json', 'vcpkg-ports/**') }}
- name: Prepare vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgJsonGlob: ./vcpkg.json
runVcpkgInstall: true
- name: Build
env:
VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}/vcpkg_cache,readwrite
VCPKG_DEFAULT_TRIPLET: ${{ matrix.triplet }}
- name: Build
run: |
export VCPKG_ROOT=$VCPKG_INSTALLATION_ROOT
export ANDROID_NDK_HOME=$ANDROID_NDK_LATEST_HOME
export ANDROID_NDK_ROOT=$ANDROID_NDK_LATEST_HOME
cmake --preset ${{ matrix.target }} "-GUnix Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build --preset ${{ matrix.target }}
cmake --build --preset ${{ matrix.target }} --target install/strip
zip -q -r libdigidocpp.${{ matrix.target }}.zip libdigidocpp.${{ matrix.target }}
- name: Archive artifacts
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v5
with:
name: ${{ matrix.target }}
path: |
Expand All @@ -120,7 +112,7 @@ jobs:
container: fedora:${{ matrix.container }}
strategy:
matrix:
container: [41, 42, 43, rawhide]
container: [42, 43, rawhide]
steps:
- name: Install Deps
run: |
Expand All @@ -134,7 +126,7 @@ jobs:
cmake --build build
cmake --build build --target package
- name: Archive artifacts
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v5
with:
name: fedora_${{ matrix.container }}
path: build/libdigidocpp*.rpm
Expand Down Expand Up @@ -177,7 +169,7 @@ jobs:
- name: Lintian
run: lintian *.deb;
- name: Archive artifacts
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v5
with:
name: ${{ matrix.dist }}_${{ matrix.ver }}_${{ matrix.arch }}
path: libdigidocpp*.*
Expand Down Expand Up @@ -206,16 +198,6 @@ jobs:
with:
path: ${{ github.workspace }}/vcpkg_cache
key: vcpkg-${{ matrix.toolset }}-${{ matrix.platform }}-${{ hashFiles('vcpkg.json', 'vcpkg-ports/**') }}
- name: Prepare vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgJsonGlob: ./vcpkg.json
runVcpkgInstall: true
runVcpkgFormatString: "[`install`, `--recurse`, `--clean-after-build`, `--x-install-root`, `$[env.VCPKG_INSTALLED_DIR]`, `--triplet`, `$[env.VCPKG_DEFAULT_TRIPLET]`, `--x-feature`, `tests`]"
env:
VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}/vcpkg_cache,readwrite
VCPKG_DEFAULT_TRIPLET: ${{ matrix.platform }}-windows
VCPKG_INSTALLED_DIR: ${{ github.workspace }}/vcpkg_installed_${{ matrix.platform }}
- name: Install dependencies
run: winget install --silent --accept-source-agreements --accept-package-agreements swig doxygen
- uses: actions/setup-java@v4
Expand All @@ -228,14 +210,17 @@ jobs:
python-version: 3.12
architecture: ${{ matrix.platform }}
- name: Build
env:
VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}/vcpkg_cache,readwrite
run: |
$swig = (Get-Item "$env:LOCALAPPDATA\Microsoft\WinGet\Links\swig.exe").Target
& "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Auxiliary\\Build\\vcvarsall.bat" ${{ matrix.setenv }} "&&" pwsh build.ps1 `
-vcpkg "C:/vcpkg/vcpkg.exe" `
-swig $swig `
-doxygen "C:/Program files/doxygen/bin/doxygen.exe" `
-boost
- name: Archive artifacts
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v5
with:
name: msi_${{ matrix.toolset }}_${{ matrix.platform }}
path: ./*.msi
Expand Down
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ param(
[string]$libdigidocpp = $PSScriptRoot,
[string]$platform = $env:PLATFORM,
[string]$build_number = $(if ($null -eq $env:BUILD_NUMBER) {"0"} else {$env:BUILD_NUMBER}),
[string]$msiversion = "4.3.0.$build_number",
[string]$msiversion = "4.4.0.$build_number",
[string]$msi_name = "libdigidocpp-$msiversion$env:VER_SUFFIX.$platform.msi",
[string]$git = "git.exe",
[string]$vcpkg = "vcpkg\vcpkg.exe",
Expand Down
20 changes: 16 additions & 4 deletions src/DataFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,17 @@ using namespace std;
DataFile::DataFile() = default;
DataFile::~DataFile() = default;

struct DataFilePrivate::Private {
optional<unsigned long> size;
};

DataFilePrivate::DataFilePrivate(unique_ptr<istream> &&is, string filename, string mediatype, string id)
: m_is(std::move(is))
: d(make_unique<Private>())
, m_is(std::move(is))
, m_id(std::move(id))
, m_filename(std::move(filename))
, m_mediatype(std::move(mediatype))
{
m_is->seekg(0, istream::end);
istream::pos_type pos = m_is->tellg();
m_size = pos < 0 ? 0 : (unsigned long)pos;
}

void DataFilePrivate::digest(const Digest &digest) const
Expand All @@ -109,6 +110,17 @@ vector<unsigned char> DataFilePrivate::calcDigest(const string &method) const
return d.result();
}

unsigned long DataFilePrivate::fileSize() const
{
if(d->size.has_value())
return d->size.value();
m_is->clear();
m_is->seekg(0, istream::end);
istream::pos_type pos = m_is->tellg();
d->size.emplace(pos < 0 ? 0 : (unsigned long)pos);
return d->size.value();
}

void DataFilePrivate::saveAs(const string& path) const
{
ofstream ofs(File::encodeName(path), ofstream::binary);
Expand Down
32 changes: 17 additions & 15 deletions src/DataFile_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <istream>
#include <memory>
#include <optional>

namespace digidoc
{
Expand All @@ -31,20 +32,21 @@ class Digest;
class DataFilePrivate final: public DataFile
{
public:
DataFilePrivate(std::unique_ptr<std::istream> &&is, std::string filename, std::string mediatype, std::string id = {});

std::string id() const final { return m_id.empty() ? m_filename : m_id; }
std::string fileName() const final { return m_filename; }
unsigned long fileSize() const final { return m_size; }
std::string mediaType() const final { return m_mediatype; }

void digest(const Digest &method) const;
std::vector<unsigned char> calcDigest(const std::string &method) const final;
void saveAs(std::ostream &os) const final;
void saveAs(const std::string& path) const final;

std::unique_ptr<std::istream> m_is;
std::string m_id, m_filename, m_mediatype;
unsigned long m_size;
DataFilePrivate(std::unique_ptr<std::istream> &&is, std::string filename, std::string mediatype, std::string id = {});

std::string id() const final { return m_id.empty() ? m_filename : m_id; }
std::string fileName() const final { return m_filename; }
unsigned long fileSize() const final;
std::string mediaType() const final { return m_mediatype; }

void digest(const Digest &method) const;
std::vector<unsigned char> calcDigest(const std::string &method) const final;
void saveAs(std::ostream &os) const final;
void saveAs(const std::string& path) const final;

struct Private;
std::unique_ptr<Private> d;
std::unique_ptr<std::istream> m_is;
std::string m_id, m_filename, m_mediatype;
};
}