MCPcopy Create free account
hub / github.com/aws/clock-bound / new

Method new

clock-bound/src/shm/reader.rs:28–36  ·  view source on GitHub ↗

Create a new `FdGuard`. Open a file at `path` and store the open file descriptor

(path: &CStr)

Source from the content-addressed store, hash-verified

26 ///
27 /// Open a file at `path` and store the open file descriptor
28 fn new(path: &CStr) -> Result<Self, ShmError> {
29 // SAFETY: `path` is a valid C string.
30 let fd = unsafe { libc::open(path.as_ptr(), libc::O_RDONLY) };
31 if fd < 0 {
32 return syserror!(format!("Faild to open file at {:?}", path));
33 }
34
35 Ok(FdGuard(fd))
36 }
37}
38
39impl Drop for FdGuard {

Callers

nothing calls this directly

Calls 2

FdGuardClass · 0.85
buildMethod · 0.45

Tested by

no test coverage detected