-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// main.m | ||
// readDragboard | ||
// | ||
// Read all file-URIs from the Mac OS X Drag Clipboard and print them to stdout | ||
// | ||
// | ||
// Version: 0.1 | ||
// Date: 2014-03-15 | ||
// Copyright: 2014 Tobias Fischer | ||
// License: The MIT License (MIT) | ||
// Website: https://github.com/tofi86/readDragboard | ||
// | ||
// | ||
// Helpful URLs: | ||
// * https://developer.apple.com/library/mac/samplecode/ClipboardViewer/Introduction/Intro.html | ||
// * https://developer.apple.com/library/mac/documentation/cocoa/conceptual/DragandDrop/Tasks/DraggingFiles.html | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <AppKit/NSPasteboard.h> | ||
|
||
int main(int argc, const char * argv[]) | ||
{ | ||
@autoreleasepool { | ||
|
||
// get Drag Clipboard | ||
NSPasteboard *dragPasteboard = [NSPasteboard pasteboardWithName:NSDragPboard]; | ||
|
||
// if array NSFilenamesPboardType exists | ||
if ( [[dragPasteboard types] containsObject:NSFilenamesPboardType] ) { | ||
|
||
// read array | ||
NSArray *files = [dragPasteboard propertyListForType:NSFilenamesPboardType]; | ||
|
||
// iterate array and print drag filenames to stdout | ||
for (NSString *fileURL in files) { | ||
printf("%s\n", [fileURL UTF8String]); | ||
} | ||
} | ||
|
||
return EXIT_SUCCESS; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// | ||
// Prefix header | ||
// | ||
// The contents of this file are implicitly included at the beginning of every source file. | ||
// | ||
|
||
#ifdef __OBJC__ | ||
#import <Foundation/Foundation.h> | ||
#endif |