Reputation: 3728
One of the lower methods in my code is getting the canonical path to the temp folder using the file.getCanonicalPath()
function (File was defined as File file = new File("/tmp")
). This works in linux and windows OS's, but on macOS, this function returns the following string - "/private/tmp" even though I have a tmp folder in my home directory and I don't have /private directory.
Any idea where does this "private" directory is coming from and why this method is not directing me to "/tmp" in macOS even though its accessible?
Note: if I create a random, non- existing dir File object (File file = new File("/random")
) it will return the canonical path just fine.
Upvotes: 2
Views: 669
Reputation: 7529
A symbolic link, also termed a soft link, is a special kind of file that points to another file, much like a shortcut in Windows or a Macintosh alias. Unlike a hard link, a symbolic link does not contain the data in the target file. It simply points to another entry somewhere in the file system.
On macOS /tmp
is symlinked to /private/tmp
. The directory /private
does exist and contains tmp
inside it.
Upvotes: 1