Skip to content

Commit

Permalink
version 0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
tofi86 committed Mar 15, 2014
1 parent b9e05a2 commit 55b7929
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
44 changes: 44 additions & 0 deletions main.m
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;
}
}
9 changes: 9 additions & 0 deletions readDragboard-Prefix.pch
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

0 comments on commit 55b7929

Please sign in to comment.