複数パスの受け渡し時にはCSVに準じたダブクォーテーションのエスケープ処理を行うものとした。
macOSではタブや改行文字もファイル名に含む可能性があるため。
This commit is contained in:
@@ -132,6 +132,8 @@ UNIWINC_EXPORT BOOL UnregisterWindowStyleChangedCallback() {
|
||||
return [LibUniWinC unregisterWindowStyleChangedCallback];
|
||||
}
|
||||
|
||||
// コールバックにファイルはダブルクオーテーションで囲まれ改行区切りとなった文字列で渡ります。
|
||||
// e.g. "/Dir/File1.txt"\n"/Dir/File2.txt"\n"/Dir/File""3"".txt"\n
|
||||
UNIWINC_EXPORT BOOL RegisterDropFilesCallback(StringCallback callback) {
|
||||
return [LibUniWinC registerDropFilesCallbackWithCallback: callback];
|
||||
}
|
||||
@@ -140,6 +142,10 @@ UNIWINC_EXPORT BOOL UnregisterDropFilesCallback() {
|
||||
return [LibUniWinC unregisterDropFilesCallback];
|
||||
}
|
||||
|
||||
// コールバックに複数パスがダブルクオーテーションで囲まれ改行区切りとなった文字列で渡ります。
|
||||
// パスにダブルクオーテーションが含まれる場合は連続ダブルクォーテーションになります。
|
||||
// e.g. "/Dir/File1.txt"\n"/Dir/File2.txt"\n"/Dir/File""3"".txt"\n
|
||||
// ファイル選択キャンセル時には空文字列が渡されます
|
||||
UNIWINC_EXPORT BOOL RegisterOpenFilesCallback(StringCallback callback) {
|
||||
return [LibUniWinC registerOpenFilesCallbackWithCallback: callback];
|
||||
}
|
||||
|
||||
@@ -877,13 +877,18 @@ public class LibUniWinC : NSObject {
|
||||
// Make new-line separated string
|
||||
var text: String = ""
|
||||
for url in openFilePanel.urls {
|
||||
text += url.path + "\n"
|
||||
text += "\"" + url.path.replacingOccurrences(of: "\"", with: "\"\"") + "\"\n"
|
||||
//text += '"' + url.path + '"' + "\n"
|
||||
}
|
||||
|
||||
// Run callback
|
||||
if (callStringCallback(callback: openFilesCallback, text: text)) {}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Canceled or failed
|
||||
if (callStringCallback(callback: openFilesCallback, text: "")) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,16 +87,20 @@ class OverlayView: NSView {
|
||||
|
||||
guard let urls = sender.draggingPasteboard.propertyList(
|
||||
forType: NSPasteboard.PasteboardType(rawValue: "NSFilenamesPboardType")
|
||||
) as? NSArray
|
||||
) as? [String]
|
||||
else {
|
||||
return false
|
||||
}
|
||||
|
||||
// Make new-line separated string
|
||||
let files: String = urls.componentsJoined(by: "\n")
|
||||
//let text: String = urls.componentsJoined(by: "\n")
|
||||
var text: String = ""
|
||||
for url in urls {
|
||||
text += "\"" + url.replacingOccurrences(of: "\"", with: "\"\"") + "\"\n"
|
||||
}
|
||||
|
||||
// Do callback
|
||||
return LibUniWinC.callStringCallback(callback: LibUniWinC.dropFilesCallback, text: files)
|
||||
return LibUniWinC.callStringCallback(callback: LibUniWinC.dropFilesCallback, text: text)
|
||||
}
|
||||
|
||||
override func draw(_ dirtyRect: NSRect) {
|
||||
|
||||
Reference in New Issue
Block a user