Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle saved Windows paths on Unix #100

Closed
wants to merge 6 commits into from
Closed
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: 29 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,28 @@ jobs:
build_for_macos:
name: macOS 11
runs-on: macos-11
env:
install_name: "sfizz-${{ github.ref_name }}-macos"
steps:
- name: Update bash
run: brew install bash
- name: Set install_name
run: |
ghref=${{ github.ref_name }}
echo "install_name=sfizz-${ghref//'/'/'-'}-macos" >> "$GITHUB_ENV"
- name: Show summary
run: |
echo "install_name: ${{ env.install_name }}"
echo "BASH_VERSION: $BASH_VERSION"
system_profiler SPSoftwareDataType
cmake --version
gcc -v
xcodebuild -version
- name: Install dependencies
if: ${{ github.ref_type == 'branch' }}
run: brew install abseil
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Install dependencies
if: ${{ github.ref_type == 'branch' }}
run: brew install abseil
- name: Configure CMake
run: |
options=(
Expand Down Expand Up @@ -188,10 +200,10 @@ jobs:
sudo killall -9 AudioComponentRegistrar
auval -v aumu samp Sfzt
- name: Package bundles
if: ${{ github.ref_type == 'tag' }}
if: github.ref_type == 'tag' || github.event_name == 'pull_request'
run: ./scripts/package-osx-bundles.sh
- name: Create installer
if: ${{ github.ref_type == 'tag' }}
if: github.ref_type == 'tag' || github.event_name == 'pull_request'
working-directory: ${{ github.workspace }}/build
run: |
options=(
Expand All @@ -203,7 +215,7 @@ jobs:
)
productbuild "${options[@]}"
- name: Upload
if: ${{ github.ref_type == 'tag' }}
if: github.ref_type == 'tag' || github.event_name == 'pull_request'
uses: actions/upload-artifact@v3
with:
name: macOS package
Expand All @@ -223,9 +235,14 @@ jobs:
pkg_platform: Win64
release_arch: x64
bits: 64
env:
install_name: sfizz-${{ github.ref_name }}-win${{ matrix.bits }}
steps:
- name: Set install name
run: |
$stripped_name="${{ github.ref_name }}".replace('/', '-')
echo "install_name=sfizz-$stripped_name-win${{ matrix.bits }}" >> "${env:GITHUB_ENV}"
- name: Show summary
run: |
echo "install_name: $env:install_name"
- name: Checkout
uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -267,11 +284,11 @@ jobs:
working-directory: ${{ github.workspace }}/build
run: pluginval --validate-in-process --validate sfizz.vst3
- name: Create installer
if: ${{ github.ref_type == 'tag' }}
if: github.ref_type == 'tag' || github.event_name == 'pull_request'
working-directory: ${{ github.workspace }}/build
run: iscc /O"." /F"${{ env.install_name }}" /dARCH="${{ matrix.platform }}" innosetup.iss
- name: Upload
if: ${{ github.ref_type == 'tag' }}
if: github.ref_type == 'tag' || github.event_name == 'pull_request'
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.pkg_platform }} installer
Expand Down
4 changes: 4 additions & 0 deletions plugins/common/plugin/FileTrie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ size_t FileTrieBuilder::ensureDirectory(const fs::path& dirPath)
fs::path parentPath = dirPath.parent_path();
if (parentPath != dirPath)
ent.parent = ensureDirectory(parentPath);
else
// On Windows, (--dirPath.end()) would be `\\` but `parent_path` and `dirPath`
// would both be `C:\\` so we update the name to match.
ent.name = dirPath.u8string();
}

size_t dirIndex = trie.entries_.size();
Expand Down
13 changes: 12 additions & 1 deletion plugins/common/plugin/SfizzFileScan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,18 @@ bool SfzFileScan::locateRealFile(const fs::path& pathOrig, fs::path& pathFound)
std::unique_lock<std::mutex> lock { mutex };
refreshScan();

auto it = file_index_.find(keyOf(pathOrig.filename()));
const auto key = [&] {
auto path = pathOrig.string();
if (path.size() > 3 && path[1] == ':' && path[2] == '\\') {
// Assume an absolute windows path and switch anti-slashes to slashes
std::replace(path.begin(), path.end(), '\\', '/');
return keyOf(fs::path(path).filename());
}

return keyOf(pathOrig.filename());
}();

auto it = file_index_.find(key);
if (it == file_index_.end())
return false;

Expand Down