POSIX path returns strange path

applescript

I was writing some AppleScript code when I came to the following result :

tell application "QuickTime Player"
set paths to file of document of windows
get paths
repeat with theItem in paths
    display dialog POSIX path of theItem
end repeat
end tell

Basically it get the path of movies open in a QuickTimeX window.

The AppleScript path is OK : Macintosh HD:Users:MyUser:Downloads:aMovie#.mp4

But in one posix output I got : ~/Library/Containers/com.apple.QuickTimePlayerX/Data/Downloads/aMovie2.mp4

Any idea why this (and what ~/Library/Containers/ actually is ?), since the AppleScript was ok ? In the path above Downloads is a link to ~/Downloads.

Edit : ~/Library/Containers seems to be used for sandboxing (sandboxing on dev.apple.com). But why do I have 2 differents POSIX path for the same AppleScript paths ?

Best Answer

The sandbox container directories contain symlinks to files the application is allowed read and write access to. For example ~/Library/Containers/com.apple.QuickTimePlayerX/Data/Downloads/ is a symlink to ~/Downloads/.

You'll get the sandboxed directory path when you open the file and QuickTime is already open and the "normal" path when you open the file and QuickTime is not already open yet.