Node:Files, Next:, Previous:Strings, Up:Sequences



Files

Unix and many other operating systems view files as just an unstructured sequence of bytes, Q views such a files as a string (which just happens to be stored in the file system, instead of in main memory).

A word that begins with / or ./ or ../ is considered to be a filename. The word is not evaluated.

As a convenience, an identifier that is unbound, but which names an existing file, is also treated as a file name.

Note that filenames follow the emacs convention, where two /-es means start again from the file system root, ignoring anything before. Thus foo//bar/baz means /bar/baz.

Hence, if the variable fn is a string, then ./$(fn) is the file named by the string fn.

An example of the use of file objects:

./a := ./b
will copy file b to a, just like
cp b a
Actually, since no flags are preserved, the semantics are more like the shell command:
cat <a >b  # /bin/sh syntax, not Q syntax!

One way to byte-reverse a file:

Q1> size ./Makefile
110
Q2> ./Makefile (109 downto 0)

Z.rat.Q>c- sserpmoc|derat-non elifekaM
\ tset knilQ elifekaM/xinu cod im derat-non X- - fc- v- rat
:Z.rat.Q
:Z.rat.Q