diff --git a/CHANGELOG.md b/CHANGELOG.md
index f803a7f..76633e8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,14 @@
# Changelog
+## 0.4.8
+
+- **A link's own stamp (`fs::stamp_of(node, false)`).** With `resolve` false
+ the stamp is the link's own size and modification time, read without
+ following it (openkal's `KAL_FS_NO_RESOLVE`), and a dangling link has one. A
+ program that keeps links as records reads them so: a store's roots, whose
+ time is when their owner last used the payload they name (xlings'
+ store-roots specification). The default is unchanged.
+
## 0.4.7
- **The processor's model (`machine::processor_model`).** The model as the
diff --git a/README.md b/README.md
index 148919a..f87d79e 100644
--- a/README.md
+++ b/README.md
@@ -132,7 +132,7 @@ at a time). `windows::console_text_code_page()` and
| `mcpplibs.os.platform` | `PLATFORM`, `ARCH`, `is_linux` / `is_macos` / `is_windows` / `is_posix` / `is_openkal` / `is_emscripten`, `exe_suffix`, `path_list_separator`; `host()`, a constant expression on a native target; `can_run_on(p)` and `on
(f)`, a platform question that holds in a native build and an image alike |
| `mcpplibs.os.error` | `errc` (openkal's closed set of conditions), `error`, `result` |
| `mcpplibs.os.env` | variables (names without case on Windows), `NAME=value` entries as overrides (`assignments`), arguments, the program's own image, lists of directories in the host's separator (`split_list`, `join_list`), PATH search with PATHEXT, the kernel layer's version (`kernel_layer`) |
-| `mcpplibs.os.fs` | `write_atomic`, `publish` (no replace), `append`, `sync`, `caps`, `lock`, links, `set_executable`, `stamp_of`, `identity_of`, `owner_of`, `writable`, `locate`, `absolute`, `names_a_place`, `canonical`, a bounded `read`; what a volume does, measured (`measure`, `volume_type`), and the operations that follow it (`place`, `exchange`); names in the host's rules without the file system: `generic`, `native`, `extended`, `is_absolute`, `same`, `within`; which names changed (`watcher`: inotify, kqueue, `ReadDirectoryChangesW`; a look when asked in an image and on Emscripten) |
+| `mcpplibs.os.fs` | `write_atomic`, `publish` (no replace), `append`, `sync`, `caps`, `lock`, links, `set_executable`, `stamp_of` (of a node, or of a link itself), `identity_of`, `owner_of`, `writable`, `locate`, `absolute`, `names_a_place`, `canonical`, a bounded `read`; what a volume does, measured (`measure`, `volume_type`), and the operations that follow it (`place`, `exchange`); names in the host's rules without the file system: `generic`, `native`, `extended`, `is_absolute`, `same`, `within`; which names changed (`watcher`: inotify, kqueue, `ReadDirectoryChangesW`; a look when asked in an image and on Emscripten) |
| `mcpplibs.os.process` | `spawn`, `run` (and with bounds: a hard bound, a grace, a drain, output limits), `exec`, a command line joined as it is for the command interpreter (`one_string`), pipes, both outputs on one pipe, output onto this program's error output, units and `end_unit`, declared units, observation and retirement, bound lifetime, bounded waits and reads; `self`, `describe`, `alive`, `threads` |
| `mcpplibs.os.interrupt` | `requested`, `wait`, `end_as_requested`, `end_as_output_closed` |
| `mcpplibs.os.stdio` | the three streams as bytes; a bounded read of input; the output sent to the error stream for a while (`output_to_error`); what a stream is written, kept and taken in parts (`capture`) |
diff --git a/mcpp.toml b/mcpp.toml
index e5bc9db..708a57c 100644
--- a/mcpp.toml
+++ b/mcpp.toml
@@ -1,7 +1,7 @@
[package]
namespace = "mcpplibs"
name = "os"
-version = "0.4.7"
+version = "0.4.8"
description = "mcpplibs.os: a C++ operating-system library over openkal --- processes, files, environment, terminals, directories and local IPC, with compile-time platform constants and a few platform modules."
license = "Apache-2.0"
authors = ["mcpplibs"]
diff --git a/src/fs.cpp b/src/fs.cpp
index b760dd6..7be67fc 100644
--- a/src/fs.cpp
+++ b/src/fs.cpp
@@ -474,7 +474,8 @@ result set_executable(const std::filesystem::path& file, bool executable)
}
namespace {
-result info(const std::filesystem::path& node, kal_u32 wanted, std::string_view doing) {
+result info(const std::filesystem::path& node, kal_u32 wanted, std::string_view doing,
+ kal_uintptr flags = 0) {
auto l = where(node, doing);
if (!l) return std::unexpected(l.error());
kal_node_info i{};
@@ -482,7 +483,7 @@ result info(const std::filesystem::path& node, kal_u32 wanted, st
// The kind is asked for as well, because absence is read from it: an
// implementation fills only the fields it was asked for (openkal-emscripten
// does), and a kind left at zero reads as kal_node_absent.
- const int rc = kal_fs_info(dir_of(*l), l->relative.data(), l->relative.size(), 0,
+ const int rc = kal_fs_info(dir_of(*l), l->relative.data(), l->relative.size(), flags,
wanted | kal::fs::field::kind, &i);
if (rc != kal_ok) return std::unexpected(from_kal(rc, std::format("{} {}", doing, generic_utf8(node))));
if (i.kind == kal_node_absent) return std::unexpected(error{ errc::not_found, std::format("{} {}", doing, generic_utf8(node)) });
@@ -490,8 +491,9 @@ result info(const std::filesystem::path& node, kal_u32 wanted, st
}
} // namespace
-result stamp_of(const std::filesystem::path& node) {
- auto i = info(node, kal::fs::field::size | kal::fs::field::modified, "asking about");
+result stamp_of(const std::filesystem::path& node, bool resolve) {
+ auto i = info(node, kal::fs::field::size | kal::fs::field::modified, "asking about",
+ resolve ? 0 : kal::fs::no_resolve);
if (!i) return std::unexpected(i.error());
return stamp{ i->size, i->modified_ns };
}
diff --git a/src/fs.cppm b/src/fs.cppm
index 7826511..5d2308d 100644
--- a/src/fs.cppm
+++ b/src/fs.cppm
@@ -224,7 +224,12 @@ struct stamp {
std::uint64_t modified_ns = 0;
auto operator<=>(const stamp&) const = default;
};
-result stamp_of(const std::filesystem::path& node);
+// `resolve' false: the stamp of the name itself where it is a link --- the
+// link's own size and modification time --- and not of the node it finally
+// refers to. A program that keeps links as records (a store's roots, whose
+// time is when their owner last used the payload) reads them so; a dangling
+// link has a stamp of its own.
+result stamp_of(const std::filesystem::path& node, bool resolve = true);
// Two names are one node exactly when their identities are equal.
struct identity {
diff --git a/tests/fs_test.cpp b/tests/fs_test.cpp
index c82da3f..c70ba7d 100644
--- a/tests/fs_test.cpp
+++ b/tests/fs_test.cpp
@@ -90,6 +90,12 @@ UTest fs_tests{"fs", [] {
expect(t && t->find("target") != std::string::npos) << "and reads back its target";
expect(stdfs::exists(dir / "link" / ".")) << "and reaches the directory";
}
+ // A link's own stamp: one that names nothing has one, and what it
+ // would finally refer to has none.
+ if (os::fs::create_link("nowhere", dir / "dangling", false)) {
+ expect(os::fs::stamp_of(dir / "dangling", false).has_value()) << "a dangling link has a stamp of its own";
+ expect(!os::fs::stamp_of(dir / "dangling").has_value()) << "and what it refers to has none";
+ }
}
if (!caps || caps->rename_no_replace) {
expect(os::fs::rename(file, dir / "b.txt", false).has_value()) << "a rename that does not replace renames to a free name";