GNU TeXmacsUser manualReferenceAboutEnglish
The system layer: files, URLs, caches and platform support

1.Introduction

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:

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.

2.Overview

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.

3.Source files

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.

Plugins/MacOS/

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.

4.Contents of this chapter

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".