Macaulay2 » Documentation
Packages » Macaulay2Doc > The Macaulay2 language > file manipulation > realpath
next | previous | forward | backward | up | index | toc

realpath -- convert a filename to one passing through no symbolic links

Synopsis

Description

i1 : realpath "."

o1 = /tmp/M2-770146-0/83-rundir/
i2 : p = temporaryFileName()

o2 = /tmp/M2-773481-0/0
i3 : q = temporaryFileName()

o3 = /tmp/M2-773481-0/1
i4 : symlinkFile(p,q)
i5 : p << close

o5 = /tmp/M2-773481-0/0

o5 : File
i6 : readlink q

o6 = /tmp/M2-773481-0/0
i7 : realpath q

o7 = /tmp/M2-773481-0/0
i8 : removeFile p
i9 : removeFile q

The empty string is interpreted as a reference to the current directory.

i10 : realpath ""

o10 = /tmp/M2-770146-0/83-rundir/

Caveat

Every component of the path must exist in the file system and be accessible to the user. Terminal slashes will be dropped. Warning: under most operating systems, the value returned is an absolute path (one starting at the root of the file system), but under Solaris, this system call may, in certain circumstances, return a relative path when given a relative path.

See also

For the programmer

The object realpath is a compiled function.