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

fix: path retrieved in macOS Sequoia is in fileid format #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
16 changes: 10 additions & 6 deletions src/clip_osx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@
Local<Array> fileNames = Array::New(isolate);
Local<Context> context = isolate->GetCurrentContext();

NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
NSArray* tempArray = [pasteboard pasteboardItems];
int count = 0;
for(NSPasteboardItem *tmpItem in tempArray){
for(NSPasteboardItem *tmpItem in tempArray){
NSString *pathString = [tmpItem stringForType:@"public.file-url"];
const char* str = [pathString UTF8String];
if(str){
fileNames->Set(context, count, String::NewFromUtf8(isolate, str, NewStringType::kNormal).ToLocalChecked());
count++;
if (pathString && [pathString isKindOfClass:[NSString class]]) {
NSURL *url = [NSURL URLWithString:pathString];
NSString *realPathString = [url path];
if (realPathString) {
const char* str = [[NSString stringWithFormat:@"file://%@", realPathString] UTF8String];
fileNames->Set(context, count, String::NewFromUtf8(isolate, str, NewStringType::kNormal).ToLocalChecked());
count++;
}
}
}
return fileNames;
Expand Down