![]() |
The system layer: files, URLs, caches and platform support | ![]() |
Everything in TeXmacs that touches the operating system goes through a small set of portable routines: names of files and other resources are URLs, files are read and written as strings, external programs are run through a few system functions, and the differences between Unix, macOS, Windows and Android are confined to a thin platform layer. This chapter describes that layer:
the url class, its tree representation, the parsing and printing of names, search paths and wildcards, and the resolution and concretization of URLs into local file names;
the file routines, the on-disk caches in $TEXMACS_HOME_PATH/system/cache, the persistent key-value store and the make directory;
the setup of paths, environment variables, user directories, temporary directories and the settings file during the boot;
the utilities for running external programs, fetching web files, sending HTTP requests, printing messages and measuring time;
the platform layers in
Plugins/Unix
, Plugins/MacOS,
Plugins/Windows
,
Plugins/Windows64
and
Plugins/Android
.
Several neighbouring subjects are described elsewhere. The Scheme interface to URLs is documented in the URL system, and the tmfs file system, including the way the C++ file layer calls back into Scheme for tmfs URLs, in internals of the TeXmacs file system. The order of the boot steps, the command line options and the crash handler are in the main program and crash handling; user preferences are in the event loop and preferences; memory allocation and the basic containers are in basic data types; pipes, sockets and dynamic libraries used by plug-ins are in the plug-in machinery.
All file names below are relative to
src/src/
unless stated otherwise.
The layers fit together as follows.
editor, typesetter, converters, Scheme glue
|
load_string / save_string / is_of_type / read_directory (file.cpp)
| |
resolve / concretize (url.cpp) cache_get / cache_set (data_cache.cpp)
| |
get_from_web / get_from_server $TEXMACS_HOME_PATH/system/cache
|
texmacs_fopen / texmacs_stat / … (Plugins/Unix, Windows64, Android)
|
operating system |
A typical read, load_string (u, s, false), first resolves u (a name which may contain search paths, wildcards and environment variables) to one existing resource, then concretizes it to a local file name (downloading it or asking a Scheme handler for a copy if it is remote), consults the file cache, and finally reads the file through the platform function texmacs_fopen. Each step is described on its own page below.
System/Classes/url.hpp,
url.cpp
The class url: constructors and parsing, printing, operations, resolution (complete, resolve) and concretization.
System/Files/file.hpp,
file.cpp
Loading and saving strings, file tests and attributes, directories, temporary, scratch and backup names, file operations, file searches.
System/Files/web_files.hpp,
web_files.cpp
Local copies of web, tmfs and ramdisc resources; HTTP POST requests.
System/Files/make_file.cpp
Generated files in $TEXMACS_HOME_PATH/system/make (downloaded images, images with effects).
System/Files/tm_ostream.hpp,
tm_ostream.cpp
Output streams: cout, cerr, the error, warning and debug channels.
System/Files/image_files.cpp
Image sizes and image conversion; described with the graphics output, not here.
System/Classes/tm_timer.hpp,
tm_timer.cpp
Time in milliseconds, CPU time and the benchmarking routines.
System/Misc/data_cache.hpp,
data_cache.cpp
The caches of directory contents, file attributes and file contents.
System/Misc/persistent.hpp,
persistent.cpp
A persistent key-value store on disk.
System/Misc/sys_utils.hpp,
sys_utils.cpp
Running programs synchronously and asynchronously, environment variables, printing command, portable poll.
System/Misc/server_log.hpp
Log levels and macros for the TeXmacs server; implemented in the platform layers.
System/Misc/fast_alloc.hpp,
fast_alloc.cpp
Memory allocation (see basic data types).
System/Boot/init_texmacs.cpp,
init_upgrade.cpp,
preferences.cpp,
boot.hpp
Paths, environment variables, user and temporary directories, the boot lock, the settings file, upgrades and the C++ store of user preferences.
Plugins/Unix/
Entry point, file and directory primitives, system, logging and stack traces for Linux, macOS and the other Unix systems.
macOS specific services (startup modifiers, remote controls, Cocoa spell checking and image conversion, App Nap).
Plugins/Windows/,
Plugins/Windows64/
The 32-bit and 64-bit Windows layers.
Plugins/Android/
The Android layer.