Crate nodejs_path

Crate nodejs_path 

Source
Expand description

§Description

The default operation of the path module varies based on the operating system on which crate is compiling. Specifically, when compiling on a Windows operating system, the path module will assume that Windows-style paths are being used. So using nodejs_path::basename() might yield different results on POSIX and Windows:

On POSIX:

 nodejs_path::basename!("C:\\temp\\myfile.html");
 // Returns: "C:\\temp\\myfile.html"

On Windows:

nodejs_path::basename!("C:\\temp\\myfile.html");
// Returns: "myfile.html"

To achieve consistent results when working with Windows file paths on any operating system, use nodejs_path::win32: On POSIX and Windows:

assert_eq!(&nodejs_path::win32::basename!("C:\\temp\\myfile.html"), "myfile.html")

To achieve consistent results when working with POSIX file paths on any operating system, use nodejs_path::posix: On POSIX and Windows:

assert_eq!(&nodejs_path::posix::basename!("/tmp/myfile.html"), "myfile.html")

§Porting

Rust doesn’t support variadic function. So, variadic functions of Node.js must be ported to macros.

Modules§

posix
nodejs_path::posix provides access to POSIX specific implementations of the path methods.
win32
nodejs_path::win32 provides access to Windows-specific implementations of the path methods.

Macros§

basename
Returns the last portion of a path, similar to the Unix basename command. Trailing directory separators are ignored.
join
The method joins all given path segments together using the platform-specific separator as a delimiter, then normalizes the resulting path.
resolve
Resolves a sequence of paths or path segments into an absolute path.

Structs§

Parsed

Constants§

delimiter
Provides the platform-specific path delimiter:
sep
Provides the platform-specific path segment separator:

Functions§

is_absolute
The method determines if path is an absolute path. If the given path is a zero-length string, false will be returned.