From 4c390aa17fe8b431cbb0c3b65da3e22d8701f8d2 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 10 Oct 2020 20:10:39 +0200 Subject: DropZone.m: If dropped file is not a directory, get dirname of file --- Drop Serve/DropZone.m | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Drop Serve/DropZone.m b/Drop Serve/DropZone.m index ac7ccd0..6ae6e49 100644 --- a/Drop Serve/DropZone.m +++ b/Drop Serve/DropZone.m @@ -53,12 +53,19 @@ NSString *file = [files objectAtIndex:0]; BOOL isDirectory = false; - if ([[NSFileManager defaultManager] - fileExistsAtPath:file - isDirectory:&isDirectory] - && isDirectory) { - NSLog(@"%@", file); + if (![[NSFileManager defaultManager] + fileExistsAtPath:file + isDirectory:&isDirectory]) { + NSLog(@"%@ not found", file); } + + NSURL *path = [NSURL fileURLWithPath:file isDirectory:isDirectory]; + + if (!isDirectory) { + path = [path URLByDeletingLastPathComponent]; + } + + NSLog(@"%@", path); } return YES; -- cgit v1.2.3