Home /Modules/operating-system/SLPermissions.sleela

SLPermissions.sleela

lib/operating-system/SLPermissions.sleela · 78 line(s) · sleela

<< lib/operating-system/SLPermissions.sleela
   SLeeLa Standard Library Definition.
   Definition: Defines SLPermissions โ€” a portable view of a filesystem entry's
     access permissions. The permission MODEL differs sharply between POSIX
     (owner/group/other read/write/execute bits) and Windows (ACL-based), so
     this class presents the common, portable questions โ€” can the current
     process read/write/execute a path, and does the path exist โ€” and leaves the
     full native ACL/mode surface to the OS-specific flavor classes. Existence
     and type come from the real OS via `os*`; the read/write/execute view is
     modeled from existence + platform until finer-grained access checks are
     added to the VM.
   
   Family: operating-system. Native VM/OS work crosses the explicit `os*` SLVM bridge. >>
#sleela 2.5
material;
class SLPermissions {
  < ---- 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 = 663;
  String metaAuthor = "Max Rupplin vs. Dr. Mrs. Elisabeth Harkins";
  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-09-28";
  < 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; }
  String path;
  void configure(String p) { path = p; }

  boolean exists() { return osExists(path) == 1; }

  < Portable access questions. Existence is authoritative (from the host); the >
  < finer read/write/execute distinctions are conservatively derived here and >
  < refined by SLWindowsOS / SLLinuxOS / SLMacOS where the native model allows. >
  boolean readable() { return osExists(path) == 1; }
  boolean writable() { return osExists(path) == 1; }
  boolean executable() {
    < On POSIX a directory is "executable" (searchable); files need the x bit, >
    < which this portable view cannot see yet, so report false for files. >
    if (osPlatform() == "Windows") { return osExists(path) == 1; }
    return osIsDir(path) == 1;
  }

  < Whether the host uses the POSIX mode-bit model (vs. Windows ACLs). >
  boolean posixModel() { return osPlatform() != "Windows"; }
}