In this section we look at how Minimacy interacts with the storage system: - where does the compiler find the packages to compile? - how can a program read or write files? For now we focus on running Minimacy over an operating system (Windows, Linux, MacOs, iOS, Android). Things are slightly different in baremetal. # Partitions We note [minimacy] the path of the Minimacy directory. This directory contains at least the following files: { bin/ a directory with the binaries rom/bios/ a directory with the *.mcy Bios files rom/core/ a directory with the *.mcy core library files programs/ a directory with some application files programs/boot.mcy the default *.mcy launch program topLevel.mcy the topLevel program } Minimacy is always launched with a “program”. The default program is [minimacy]/programs/boot.mcy. It is possible to specify another program in the command line or (on Windows) by double-clicking directly any *.mcy file. Let’s assume that: - the Minimacy directory is “~/minimacy” - the program to launch is “/etc/minimacy/sample/demo.hello.mcy” At first, Minimacy compiles the Bios. The Bios is taking care of file system, i/o, multithreading, ... Its source code is in “[minimacy]/rom/bios/bios.mcy”. The compiling time is around 1 millisecond. Then the Minimacy virtual machine will define three cascading partitions: - a partition for absolute files: any file path starting with “/” will be used to access the host file system - a partition for application files: /etc/minimacy/sample - a read-only partition for system files (bios and core library): ~/minimacy/rom When the Minimacy virtual machine is looking for a file, it scans this partition list until it finds the file, that’s why we mention “cascading”. It is possible to display these partitions with the “fs” function: fs() >Volumes: > Volume Access SectorSize NbSectors TotalSize > ------ ------ ---------- --------- --------- > ansi0 writable - - - > >Partitions: > Volume Access TotalSize Partition > ------ ------ ---------- --------- > ansi0 writable - Ansi > >Mounts: > Id Volume Partition Access Mount Path Partition Path > -- ------ --------- ------ ---------- -------------- > 0 ansi0 Ansi writable / / > 1 ansi0 Ansi writable [empty] C:/home/dev/c/minimacy/programs/ > 2 ansi0 Ansi readonly [empty] C:/home/dev/c/minimacy/rom/ # Packages After setting up these partitions, the Bios compiles the package “demo.hello”, whose name is derived from the program path “/etc/minimacy/sample/demo.hello.mcy” (file name without the “.mcy” extension). When the compiler is looking for a package “demo.hello”, it will look for the following files: - demo.hello.mcy - demo/demo.hello.mcy Each file is searched in all partitions. The scan stops as soon as the file is found. In a more general example, compiling package “a.b.c” will try the following files: - a.b.c.mcy - a/a.b.c.mcy - a/b/a.b.c.mcy - a/b/c/a.b.c.mcy This unusual mechanism helps organize the file tree. # File access To create a file, one may use [[save]]: save("Hello World!","test/hello.txt") The [[save]] function takes two arguments: the content of the file and its path. It creates subdirectories when needed. The easiest way to read a file is to use [[load]]: load("test/hello.txt") The [[load]] function returns the content of the file or [[nil]] when the file is not found. When the file path is an absolute path like “/etc/hosts” or “C:/Windows/win.ini”, it will be searched in the Root partition. Else it will be searched in the Programs or Rom partitions. There are other functions you can find on [this reference page.](page://ref..Files)