gitoria

layouts

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit7979397c7979397creport ML-mobilemre7979397c/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

  • 7979397creport ML-mobilemre
  • 85d2ed25gate: wordingmre
  • 98a311c0gate: 390 px checks for list rows, table word, edited tap target, code in titlesmre
  • 769b99d7theme: table cells keep a word whole, code in a title stays text-sized, 'edited' is a 44 px tap target on the phonemre
  • c36b7595list rows (notes, mail) stack their parts full width: the date no longer a one-letter column beside the titlemre
  • 02aa74aasync components.hybriel 134b4e3: MdEditor builds an editor put into the page at once, redraws a surface put in anew (F5, hybriel#211)mre
  • 268b1c87sync components.hybriel 6b0936a: the 'edited' foldable drops the theme's border and marginmre
  • c51d039fsync components.hybriel 8d79ff7: bubble hugs its content, quiet 'edited' label; gate checksmre
  • f4ad7eecsync components 9a: shared Icon (icons/icons.hl), md-editor toolbar icons + single focus ring (components f4-icons ba96735)mre
  • db258c11sync-components: copy icons/icons.hl + README (F4); testsmre
  • badc1879md-editor.hl: verbatim copy of components f3-mdvalue (an older text handed back is kept)mre
  • 867a8375md-editor.hl: verbatim copy of components f3-mdvalue (an outside value change is shown by the editor)mre
  • 5d8d2c67tests: wait for hydration before real clicks after a navigation (H2)mre
  • 99db79f0re-vendor Hybriel 5406d146 (hl:web batches 9+10: #72 emits while the socket is closed delivered after reconnect, browser boot linear, faster list appends; contains int 6–14 + m406)mre
  • 30353f60tests: e2e-md-showcase Chrome range from LAYOUTS_GATE_CHROME_MD, default unchangedmre
  • 16a7878cre-vendor Hybriel 6f8a0689 (int 6–11: streaming cursors, #203 index heal + close() fix, fd403 listDir/cursor fds, hl:time browser side, hl:web batches 5+6)mre
  • 6af559e8docker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mre
  • 5599cf56deploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
  • 0bcc6294Mission 011: e2e-197, brief, report, LOGmre
  • 137303c5MainMenu marks the current page from the route (hybriel#197, server-rendered); current prop/item.current stay as fallback; tracker demo drops current; gate: SSR marker; docsmre