next | previous | forward | backward | up | top | index | toc | Macaulay2 website
Macaulay2Doc > The Macaulay2 language > file manipulation > realpath

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

Synopsis

Description

i1 : realpath "."

o1 = /tmp/M2-62227-0/70-rundir/
i2 : p = temporaryFileName()

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

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

o5 = /tmp/M2-63226-0/0

o5 : File
i6 : readlink q

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

o7 = /tmp/M2-63226-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-62227-0/70-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.