gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitfe5f707cfe5f707cgitoria 010: report, mission, comment on why current = true staysmrefe5f707c/plugins/fs/server.hl

5.8 KB

  1. file(String path) {
  2. return __native("fs.file", path)
  3. }
  4. readFile(String path) {
  5. return __native("fs.read_file", path)
  6. }
  7. \* `readFile`, but a path that is not there answers null instead of failing: for what
  8. another process may delete between a probe and the read (the shared build cache). *\
  9. tryReadFile(String path) {
  10. return __native("fs.try_read_file", path)
  11. }
  12. \* Read a whole file as Bytes (ticket #88): every byte as it is on disk,
  13. nothing decoded — the way back for what writeFile stored from a Bytes. *\
  14. readBytes(String path) {
  15. return toBytes(__native("fs.read_file", path))
  16. }
  17. \* Name the file every path read, listed or probed is appended to (one line,
  18. `r|l|e <path>`), or stop with null — the build cache's record of what a
  19. build depends on (326 rung 12). *\
  20. traceReads(path) {
  21. return __native("fs.trace", path)
  22. }
  23. \* The SHA-256 of a file's bytes, 64 hex digits, or null when it cannot be
  24. read; `textDigest`, of a text's. Hashed natively (the build cache). *\
  25. fileDigest(String path) {
  26. return __native("fs.digest", path)
  27. }
  28. textDigest(String text) {
  29. return __native("fs.digest_text", text)
  30. }
  31. \* The path's last status change (ctime) in milliseconds since the epoch, or null
  32. when it is not there (#195): what the build cache compares with the moment a
  33. build began. *\
  34. changeTime(String path) {
  35. return __native("fs.change_time", path)
  36. }
  37. listDir(String path) {
  38. return __native("fs.list_dir", path)
  39. }
  40. \* Does this path exist? (mission 077) The one call in hl:fs that cannot fail:
  41. it answers true/false, never an Error event — probing a path is a question,
  42. not an operation. Relative paths resolve against the SCRIPT's directory like
  43. every other hl:fs path. *\
  44. exists(String path) {
  45. return __native("fs.exists", path)
  46. }
  47. \* Watch a directory tree for changes (the dev-reload bell): an ordinary
  48. event-loop source — register it and every save arrives as an event.
  49. __native("eventloop.register", watch("."), "changed")
  50. on changed(ev) { … ev.name … }
  51. `exclude` (2026-08-30) names directories the descent must NOT enter — a
  52. path string, or a list of them. Omit it and the whole tree is watched, as
  53. it always was. The paths are compared RESOLVED (relative ones against the
  54. script's directory, like every hl:fs path) and normalised, so `./sessions`,
  55. `sessions` and `var/../sessions` are the same directory, and a sibling
  56. named `sessions-old` is NOT inside `sessions`.
  57. watch(".", "./sessions")
  58. watch(".", ["./sessions", "/var/cache/app"])
  59. A program that writes to a directory it also watches needs this: without
  60. it the only escape was that the walker skips dot-directories (which it
  61. still does — `.git` is the reason), i.e. renaming the directory. *\
  62. watch(String path, exclude) {
  63. return __native("fs.watch", path, exclude)
  64. }
  65. \* Write a whole file, ATOMICALLY (2026-08-28). Everything above this line
  66. reads; hl:fs could report a file's `chmod` and never set one, which is why
  67. nothing in this language could persist anything until now.
  68. The write goes to a sibling temp file, is fsynced, and is then renamed over
  69. the target — so a concurrent reader sees the whole OLD file or the whole NEW
  70. one, never a half of either. That matters more than it sounds: the first
  71. caller is the session store, and a truncated session file does not read as
  72. an error, it reads as a logged-out user.
  73. `mode` defaults to 0600 — a file this program wrote, for this program. Pass
  74. one to loosen it; nothing here consults the umask on your behalf.
  75. `contents` is a String or a Bytes (ticket #88): a Bytes is written raw,
  76. byte for byte — an uploaded image stays an image. *\
  77. writeFile(
  78. String path
  79. contents \\ a String or a Bytes
  80. Number mode
  81. ) {
  82. if (hlTypeName(contents) == 'Bytes') {
  83. return __native("fs.write_file_hex", path, contents.hex(), mode)
  84. }
  85. return __native("fs.write_file", path, contents, mode)
  86. }
  87. \* Append to a file — the log's shape, not the session store's (2026-09-27, a
  88. creator ask after routger's two). Opened O_APPEND, never truncated: the file
  89. is created (at `mode`, default 0600, same as writeFile) if it is not there
  90. yet, and every call after that lands its bytes after whatever is already on
  91. disk. `writeFile`'s atomicity is a RENAME over a temp file — there is no
  92. "old" or "new" whole file to swap here, since an append MUTATES the one
  93. that is already there — but O_APPEND carries its own, narrower guarantee:
  94. the kernel positions a single write() at the CURRENT end of file and
  95. performs it as one operation, so two processes each appending one line
  96. never interleave their bytes mid-line, and a reader never sees a torn
  97. append. That is what "a single write of a line lands whole" buys — call it
  98. once per line (or per record) you want that guarantee for.
  99. `contents` is a String or a Bytes (ticket #88), same as writeFile: a Bytes
  100. is appended raw, byte for byte. *\
  101. appendFile(
  102. String path
  103. contents \\ a String or a Bytes
  104. Number mode
  105. ) {
  106. if (hlTypeName(contents) == 'Bytes') {
  107. return __native("fs.append_file_hex", path, contents.hex(), mode)
  108. }
  109. return __native("fs.append_file", path, contents, mode)
  110. }
  111. \* Make a directory and every missing parent. Already-there is SUCCESS: the
  112. caller wants the directory to exist, not to be the one who created it.
  113. `mode` defaults to 0700. *\
  114. mkDir(String path, Number mode) {
  115. return __native("fs.mk_dir", path, mode)
  116. }
  117. \* Delete a file or an empty directory. IDEMPOTENT: true when the path is gone on return, and a path
  118. that was already gone counts. A sweep must not fail because something else
  119. deleted the file first. *\
  120. remove(String path) {
  121. return __native("fs.remove", path)
  122. }
  123. \* The canonical absolute path of `path` (symlinks resolved, `.`/`..` folded;
  124. realpath(3)), or null when it is not there. `realPath('/proc/self/exe')` is
  125. the running binary. *\
  126. realPath(String path) {
  127. return __native("fs.real_path", path)
  128. }

Branches

Latest commits

  • fe5f707cgitoria 010: report, mission, comment on why current = true staysmre
  • 9705ca86gitoria 010: gate: menu marker in the server HTMLmre
  • 8cff663agitoria 010: main-menu.hl from layouts 0bcc629 (route marker)mre
  • 359c79f7gitoria 010: re-vendor Hybriel master f9614007 (plugins whole, bin/ git-ignored)mre
  • 6bd7fb3cgitoria 009: theme re-copied from layouts 76f99f6 (menu marks the current page), current = true on the menu item, e2e marker checks, reportmre
  • 44de915cidentkit: refuse a taken ident port, cold-start deadline, abort on dead ident, clear no-code error (as notes)mre
  • 2bf5343egitoria 007: theme re-copied from layouts dbe3de7 (44 px taps), redundant tap overrides dropped, crumbs class, real-browser walk test, reportmre
  • 18843648deploy.sh: a gate without a 'passed,' line (check-theme) no longer ends the script silently (grep under pipefail) — print check-theme's summary, as layouts doesmre
  • e6dff0cbgitoria#23: report 005, STATUS, LOGmre
  • 7f992d62gitoria#23: phone first on the shared theme — brand, branch and pull links 44 px, readme code 14 px; gate block "phone first" (15 pages at 390 + the three dropdowns, fails 20 on old), dropdown-aware login/logout clicks, check-theme in GATESmre
  • a2a840a5gitoria#23 WIP (quota stop): theme from layouts, styles inherit it, shell on the theme's header/menus/sidebar, phone measurement script; gates not runmre
  • 12b665b0mission brief 005mre
  • b680c483Revert "gitoria#22: RepoTabs wrapping component for the repo tabs (active tab, no content for a missing repo)"mre
  • 4fda244fgitoria#22: RepoTabs wrapping component for the repo tabs (active tab, no content for a missing repo)mre
  • 0fd5e280mission brief 004mre
  • e1d425e7paths: projects moved into /media/STORAGE/projects/WorldAPI/mre
  • e59ff114deploy.sh: wait up to DEPLOY_URL_WAIT (120 s) for 200 after the restart, as the other apps (cold compile, hybriel#148)mre
  • bcafcceb003: compose cache volume + tmpfs /tmp, gate start waits 120 s, report/LOG/STATUSmre
  • bed3f2d5Re-vendor Hybriel to the shared static build 0f396652 (plugins; bin/ is git-ignored)mre
  • 3207e128mission brief 003mre