diff options
| author | Teddy Wing | 2020-10-10 20:10:39 +0200 |
|---|---|---|
| committer | Teddy Wing | 2020-10-10 20:10:39 +0200 |
| commit | 4c390aa17fe8b431cbb0c3b65da3e22d8701f8d2 (patch) | |
| tree | 2aca230e1c097823623713ad2717443315e45f13 | |
| parent | 0fd6d98d8fd069119e615f7be78b13e1b2b4f41f (diff) | |
| download | Drop-Serve-4c390aa17fe8b431cbb0c3b65da3e22d8701f8d2.tar.bz2 | |
DropZone.m: If dropped file is not a directory, get dirname of file
| -rw-r--r-- | Drop Serve/DropZone.m | 17 |
1 files 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; |
