Websites Navigation: Airbit | Shop | m-shell.net
Languages: EN | DE

Path and File Names

A complete file name in m (and in Symbian OS) consists of a drive, a directory path, and the file name with extension. The drive is followed by a colon; drive, directories and file name are separated by backslashes (\). Since the backslash is also the escape character in strings, each backslash must be entered as two backslashes (unless simplified interactive syntax is used, see section * (Reference)):

path="c:\\documents\\mShell\\script.m"

By convention, a directory name always ends with a backslash, allowing immediate differentation between directory names and file names.

Function files.parse splits a file name into its four parts:

p=files.parse(path)
for k in keys(p) do
  print k,p[k]
end
→ drive c:
dir \documents\mShell\
base script
ext .m

To avoid the need for a fully specified file name, each process in m maintains a current directory (see .cd). Unlike in DOS/Windows, which maintains a current directory for each drive, there is only one current directory in m, which always includes the drive.

All functions taking file or directory names as arguments therefore accept absolute, drive-relative or relative file names:

  • Absolute file names start with the drive letter. The directory path always starts from the root of the drive, even if the first backslash is missing.

    cd("c:documents");
    print cd()
    → c:\documents\

  • Drive-relative file names start with a backslash. They are always relative to the root of the current drive (which is part of the current directory).

    cd("\\documents");
    print cd()
    → c:\documents\

  • Relative file names start with a directory name, or simply a file name. They are always relative to the current directory.

    cd("mShell");
    print cd()
    → c:\documents\mShell\

m also interprets two special directory names:
  • A single dot refers to the current directory.
  • A double dot refers to the preceding directory.
Single and double dots can occur anywhere in the directory path.

cd("c:\\documents");
cd(".\\mShell"); // . refers to c:\documents
print cd()
→ c:\documents\mShell\
cd("..\\Jotter"); // .. refers to c:\documents
print cd()
→ c:\documents\Jotter\


© 2004-2010 airbit AG, CH-8008 Zürich
Document AB-M-LIB-871
mShell Home  > Documentation  > Manuals