Close package fs review findings: readRange bounds, picker ext, non-ASCII tests
Cap readRange's allocation and reject size_t overflow instead of truncating; re-append .rsbank when the export picker omits it; add cafe coverage for writeFileExclusive and writeLandedFile; loop write() on EINTR.
This commit is contained in:
@@ -5,6 +5,9 @@
|
||||
|
||||
#include "shell/package/package_pickers.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
|
||||
#define REAPERAPI_MINIMAL
|
||||
#define REAPERAPI_WANT_GetUserFileName
|
||||
#include "reaper_plugin_functions.h"
|
||||
@@ -30,6 +33,14 @@ bool runPicker(int mode, const char* caption, const char* initial,
|
||||
return !outAbsPath.empty();
|
||||
}
|
||||
|
||||
bool hasCaseInsensitiveSuffix(const std::string& path, const std::string& suffix) {
|
||||
if (path.size() < suffix.size()) return false;
|
||||
return std::equal(suffix.rbegin(), suffix.rend(), path.rbegin(),
|
||||
[](unsigned char a, unsigned char b) {
|
||||
return std::tolower(a) == std::tolower(b);
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool pickPackageForImport(std::string& outAbsPath) {
|
||||
@@ -39,7 +50,14 @@ bool pickPackageForImport(std::string& outAbsPath) {
|
||||
bool pickPackageSavePath(const std::string& suggestedPath, std::string& outAbsPath) {
|
||||
// [verify — DAW] GetUserFileName takes no owner window, so the dialog's parenting
|
||||
// is REAPER's to do; the previous Win32 path passed GetMainHwnd() explicitly.
|
||||
return runPicker(0, "Export bank package", suggestedPath.c_str(), outAbsPath);
|
||||
if (!runPicker(0, "Export bank package", suggestedPath.c_str(), outAbsPath)) {
|
||||
return false;
|
||||
}
|
||||
// GetUserFileName has no lpstrDefExt equivalent (the old Win32 picker's
|
||||
// ofn.lpstrDefExt = L"rsbank"); whether mode 0 appends one itself from
|
||||
// kExtList is [verify — DAW], so append it ourselves whenever it's missing.
|
||||
if (!hasCaseInsensitiveSuffix(outAbsPath, ".rsbank")) outAbsPath += ".rsbank";
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace reasampler
|
||||
|
||||
Reference in New Issue
Block a user