Skip to main content

PATH_MAX

Constant PATH_MAX 

Source
pub const PATH_MAX: usize = 120;
Expand description

The longest path services/fs accepts. A longer one is Error::InvalidInput and is never sent, rather than being silently truncated into a request for a DIFFERENT file.

ยงPaths are BYTES

Every path parameter here takes impl AsRef<[u8]>, so a string literal works as it reads - fs.read_into("/data/message.txt", &mut buf) - and so does a byte slice a program is holding from somewhere else.

That is not generality for its own sake. services/fs accepts any byte above 0x1f except / and 0x7f in a name, so a disk prepared elsewhere holds names that are not UTF-8, and this OS must still be able to list and DELETE them. A &str-only API forces such a caller through from_utf8(..).unwrap_or(""), which turns an unreadable name into a request for a different file - silently. DirEntry::name hands back raw bytes for the same reason; these parameters accept them for the other half of the round trip.