cli: add caller-buffer lexical path APIs
Add pure std.path queries and failure-preserving normalization/join using safe reverse measurement/emission and caller-provided output storage. Component queries return explicit Copy ranges; filesystem authority is checked independently. Complete the STD-7 implementation gate. Validation: 1079 conformance cases, 18 path cases with per-step collection and 12-seed schedule stress, independent 132-path/49-join capacity oracle, 68 CLI checks, fourteen previous source/std CLI suites, unit/Quick Reference, formatting, hosted smoke, 117/117 source coverage and reference budgets.
This commit is contained in:
1 parent
8d8bef8f3e
commit
8edec5b831
35 files changed
+1189
-8
No files matched your search
@@ -0,0 +1,18 @@
|
||||
// expect: run
|
||||
// result: 42
|
||||
// phase: 6
|
||||
// spec: docs/spec/16-standard-library.md §2.19
|
||||
// grant: src=fs.read:/allowed
|
||||
// vfs: /denied/file=secret
|
||||
module test.path
|
||||
import std.path;
|
||||
import std.bytes;
|
||||
fn written(result: std.path.WriteResult) -> usize effects [] {
|
||||
match result { std.path.WriteResult::ok(n) => { return n; }, std.path.WriteResult::invalid_input => { trap; }, std.path.WriteResult::size_overflow => { trap; }, std.path.WriteResult::short_output => { trap; } }
|
||||
}
|
||||
fn main(src: cap<fs.read>) -> u64 effects [fs.read] {
|
||||
var bytes: [u8;16] = [255u8;16]; let n = written(std.path.join(mut bytes,b"/allowed",b"../denied/file")); assert(std.bytes.equal(ref bytes[0usize..n],b"/denied/file"));
|
||||
match fs.open_read(src,ref bytes[0usize..n]) { ok(file) => { trap; }, err(error) => { match error { io_error::permission_denied => {}, io_error::not_found => { trap; }, io_error::already_exists => { trap; }, io_error::invalid_input => { trap; }, io_error::no_space => { trap; }, io_error::broken_pipe => { trap; }, io_error::connection_refused => { trap; }, io_error::connection_reset => { trap; }, io_error::address_in_use => { trap; }, io_error::address_unavailable => { trap; }, io_error::timed_out => { trap; }, io_error::other => { trap; } } } }
|
||||
let count = written(std.path.normalize(mut bytes,b"x/../file")); match fs.open_read(src,ref bytes[0usize..count]) { ok(file) => { trap; }, err(error) => { match error { io_error::invalid_input => {}, io_error::permission_denied => { trap; }, io_error::not_found => { trap; }, io_error::already_exists => { trap; }, io_error::no_space => { trap; }, io_error::broken_pipe => { trap; }, io_error::connection_refused => { trap; }, io_error::connection_reset => { trap; }, io_error::address_in_use => { trap; }, io_error::address_unavailable => { trap; }, io_error::timed_out => { trap; }, io_error::other => { trap; } } } }
|
||||
return 42;
|
||||
}
|
||||
Reference in new issue
Block a user