mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-19 21:51:06 +00:00
# Description <!-- > Please provide a summary of the changes made in this PR. Include details such as: > * What issue does this PR address or fix? > * What new features or enhancements does this PR introduce? > * Are there any breaking changes or dependencies that need to be considered? --> Windows traditionally limits many file operations to `MAX_PATH` (260 characters). Deeply nested plugin packages can exceed this limit during `.whl` extraction, leaving files missing and causing the plugin to fail to load. This change adds a shared extended_path helper that prepares paths for Windows file operations using the extended-length prefixes `\\?\` or `\\?\UNC\`. The helper is used for ZIP archive I/O and extraction destinations, including plugin wheel extraction. This avoids relying on the Windows long-path setting, which changes machine-wide settings. Paths remain unprefixed outside file operations. Code that bypasses the shared ZIP helpers may still require separate long-path handling. See [Microsoft's documentation on path length limitation](https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry) # Screenshots/Recordings/Graphs <!-- > Please attach relevant screenshots to showcase the UI changes. > Please attach images that can help explain the changes. --> ## Tests <!-- > Please describe the tests that you have conducted to verify the changes made in this PR. --> Tested on Windows 11 by using a portable installation of OrcaSlicer and placing it in some really long filepath length e.g. `C:/somename/<240 characters long folder path>/OrcaSlicer` and then running and trying to install any plugin locally or on OrcaCloud. <!-- > A guide for users on how to download the artifacts from this PR. --> [How to Download Pull Requests Artifacts for Testing](https://www.orcaslicer.com/wiki/how_to_download_pr_artifacts)
44 lines
1.5 KiB
C++
44 lines
1.5 KiB
C++
#ifndef MINIZ_EXTENSION_HPP
|
|
#define MINIZ_EXTENSION_HPP
|
|
|
|
#include <boost/filesystem/path.hpp>
|
|
#include <string>
|
|
#include <miniz.h>
|
|
|
|
namespace Slic3r {
|
|
|
|
bool open_zip_reader(mz_zip_archive *zip, const std::string &fname_utf8);
|
|
bool open_zip_writer(mz_zip_archive *zip, const std::string &fname_utf8);
|
|
bool close_zip_reader(mz_zip_archive *zip);
|
|
bool close_zip_writer(mz_zip_archive *zip);
|
|
std::string decode_archive_entry_path(mz_zip_archive *zip, const mz_zip_archive_file_stat &stat);
|
|
// Extracts every entry of the archive under dest_dir. Nothing is written if any entry would resolve outside dest_dir.
|
|
bool extract_archive_confined(const std::string &zip_path_utf8, const std::string &dest_dir);
|
|
// Extracts one entry into dest_path, binary-safe and overwriting. On Windows the destination is
|
|
// opened through an extended-length path so it works past MAX_PATH even with LongPathsEnabled off;
|
|
// a partial file is removed if the write fails. False for a directory/unsupported entry or on error.
|
|
bool extract_zip_entry_to_file(mz_zip_archive *zip, mz_uint file_index, const boost::filesystem::path &dest_path);
|
|
|
|
class MZ_Archive {
|
|
public:
|
|
mz_zip_archive arch;
|
|
|
|
MZ_Archive();
|
|
|
|
static std::string get_errorstr(mz_zip_error mz_err);
|
|
|
|
std::string get_errorstr() const
|
|
{
|
|
return get_errorstr(arch.m_last_error) + "!";
|
|
}
|
|
|
|
bool is_alive() const
|
|
{
|
|
return arch.m_zip_mode != MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED;
|
|
}
|
|
};
|
|
|
|
} // namespace Slic3r
|
|
|
|
#endif // MINIZ_EXTENSION_HPP
|