Home /Modules/operating-system/SLFilesystemLayout.sleela

SLFilesystemLayout.sleela

lib/operating-system/SLFilesystemLayout.sleela · 125 line(s) · sleela

<< lib/operating-system/SLFilesystemLayout.sleela
   SLeeLa Standard Library Definition.
   Definition: Defines SLFilesystemLayout — the root-filesystem namespace of an
     OS being constructed. It records the on-disk filesystem format (ext4 / NTFS
     / APFS), the mount hierarchy, and the directory tree the installed system
     presents: the FHS roots for Linux shapes (/etc,/usr,/var,/home,/proc,/sys,
     /tmp,/boot), the Windows directory world (C:\Windows, Program Files, Users,
     ProgramData) for Windows shapes, and the Apple layout (/System,/Library,
     /Applications,/Users) for macOS shapes.
   
   In the firmware -> boot -> kernel -> userspace -> desktop model, this is the
   installed root filesystem the early userspace mounts. Directories are
   accumulated into a portable, newline-separated manifest the ISO builder reads
   to assemble the rootfs tree (the debootstrap-style compositional assembly the
   OS lineage uses).
   
   Family: operating-system. Pure design model; no native bridge calls. >>
#sleela 2.5
material;
class SLFilesystemLayout {
  < ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
  << Eleven catalogued attributes with getter/setter pairs, so a GUI, loader,
     or catalog can read and (where appropriate) override this record.
     Values are faithful to the subject's real origin where publicly known. >>
  String metaVersion = "1.0.0";
  int metaId = 10893;
  String metaAuthor = "Kiro Agent";
  String metaDate = "2026-10-16";
  String metaCopyright = "SLeeLa project";
  String metaTrademark = "none";
  String metaCorporation = "none";
  < metaOrigin: National | <nation> | International | Galactic >
  String metaOrigin = "International";
  String metaBirthDate = "2026-10-10";
  < metaScienceRating: maturity/robustness on a 1..10 scale >
  int metaScienceRating = 9;
  < metaNationalSchedule: a real, citable instrument or "none" >
  String metaNationalSchedule = "none";

  String getMetaVersion() { return metaVersion; }
  void setMetaVersion(String v) { metaVersion = v; }
  int getMetaId() { return metaId; }
  void setMetaId(int v) { metaId = v; }
  String getAuthor() { return metaAuthor; }
  void setAuthor(String v) { metaAuthor = v; }
  String getDate() { return metaDate; }
  void setDate(String v) { metaDate = v; }
  String getCopyright() { return metaCopyright; }
  void setCopyright(String v) { metaCopyright = v; }
  String getTrademark() { return metaTrademark; }
  void setTrademark(String v) { metaTrademark = v; }
  String getCorporation() { return metaCorporation; }
  void setCorporation(String v) { metaCorporation = v; }
  String getOrigin() { return metaOrigin; }
  void setOrigin(String v) { metaOrigin = v; }
  String getBirthDate() { return metaBirthDate; }
  void setBirthDate(String v) { metaBirthDate = v; }
  int getScienceRating() { return metaScienceRating; }
  void setScienceRating(int v) { metaScienceRating = v; }
  String getNationalSchedule() { return metaNationalSchedule; }
  void setNationalSchedule(String v) { metaNationalSchedule = v; }
  < "ext4" / "NTFS" / "APFS" >
  String format;
  < path separator for this layout >
  String separator;
  < newline-separated directory manifest >
  String tree;
  int dirCount;
  int configured;

  void configure(String fsFormat, String sep) {
    format = fsFormat; separator = sep; tree = ""; dirCount = 0; configured = 1;
  }

  < Add one directory to the manifest. >
  void addDir(String path) {
    if (tree == "") { tree = path; } else { tree = tree + "\n" + path; }
    dirCount = dirCount + 1;
  }

  < Seed the standard directory tree for a shape. >
  void forShape(SLOSShape shape) {
    configure(shape.rootFilesystem(), shape.pathSeparator());
    if (shape.isWindows()) {
      addDir("C:\\Windows");
      addDir("C:\\Windows\\System32");
      addDir("C:\\Program Files");
      addDir("C:\\Program Files (x86)");
      addDir("C:\\ProgramData");
      addDir("C:\\Users");
      addDir("C:\\Users\\Default");
      return;
    }
    if (shape.isMac()) {
      addDir("/System");
      addDir("/System/Library");
      addDir("/Library");
      addDir("/Applications");
      addDir("/Users");
      addDir("/private/var");
      addDir("/private/tmp");
      return;
    }
    < Linux: Filesystem Hierarchy Standard roots. >
    addDir("/boot");
    addDir("/etc");
    addDir("/usr");
    addDir("/usr/bin");
    addDir("/usr/lib");
    addDir("/var");
    addDir("/home");
    addDir("/root");
    addDir("/proc");
    addDir("/sys");
    addDir("/dev");
    addDir("/tmp");
  }

  String fsFormat()  { return format; }
  String manifest()  { return tree; }
  int directoryCount() { return dirCount; }
  < A layout must declare at least a system root and a user-data root. >
  boolean isComplete() { return dirCount >= 2; }
}