Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

The directory that was dragged will then open in the application it was dragged to (if the app accepts the path). What happens at the low level?

How does the application know it can open that path? How does Finder provide the application with the path to open?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

At a low level, everything on the disk is a file. So a folder is a special file that contains directory information pointing to more files.

The application is told that the file should be opened - and it's up to the program to determine what type of file was passed and decide whether to recursively handle that file by reading the files contained in that folder or take some other action.

Similarly, you can select many items in Finder and drop them on an icon and the same sort of file open event is posted to the application so that it can process the files and do what needs to be done.

share|improve this answer
    
Thank you for the response, @bmike, that makes sense! How would one go about telling an app (using a script or something along those lines) to do a general "Open" command on a path? –  Tyler Bell Aug 1 '12 at 18:50
2  
This might be useful as a separate question, but in a bash script you could do open -a Application /path/to/open –  robmathers Aug 1 '12 at 18:59
    
Thanks, @CanuckSkier, I'll give it a shot :-) –  Tyler Bell Aug 1 '12 at 19:00
2  
Also, @TylerBell, you can simply use open /path/to/file on the command line/in a script, and the file will be opened with the default application for that file type. For directories, that's Finder. –  tnorthcutt Aug 1 '12 at 19:04
1  
@TylerBell you're welcome. I see you're new here; don't forget to upvote helpful answers and comments and mark an answer as accepted if it answers your question. –  tnorthcutt Aug 1 '12 at 19:15
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.