pub struct CurrentExecutable { /* private fields */ }Expand description
The exact executable that is currently running, bound once to a canonical target.
Binding resolves symlinks, so an invocation through a link updates the real image and never overwrites the link object. It also proves that the target is a regular file beneath a real directory and records an identity for it: on Unix that is device plus inode, and on every platform it is the SHA-256 of the image’s bytes.
The content digest is what makes the binding safe on Windows. A file identity there needs handle-based FFI, which this crate forbids, so a path-only recheck would silently accept an image swapped in between binding and commit. Content equality is the strongest identity provable with safe code on every platform, and a mismatch fails closed.
Implementations§
Source§impl CurrentExecutable
impl CurrentExecutable
Sourcepub fn resolve() -> Result<Self>
pub fn resolve() -> Result<Self>
Resolves and binds the running executable from the process environment.
std::env::current_exe is only a starting point: on some platforms it
reports the invocation path, which may traverse symlinks. The result is
always canonicalized and re-proven before it is used for mutation.
Sourcepub fn installation_root(&self) -> &Path
pub fn installation_root(&self) -> &Path
Returns the executable’s own directory, which is the installation root
used by crate::InstallPlan::for_current_executable.
The whole self-update transaction stays inside this directory, so no write authority above it is ever required.
Sourcepub fn destination_name(&self) -> &Path
pub fn destination_name(&self) -> &Path
Returns the file name used as the single destination member, relative to
installation_root.
Sourcepub fn destination(&self) -> PathBuf
pub fn destination(&self) -> PathBuf
Returns the absolute destination path of the running image.