Import std.io.path
std.io.path
std.io's paths: a Path is where a file or folder is, as text, read by Windows' rules or POSIX's, the target's unless it's made with the other's. A String converts to one wherever a Path is expected. Its own separator is '/' on every OS, which it writes wherever it joins or rebuilds a path, and Windows takes it, so a program's paths read the same everywhere; on Windows '' is one too, and a path can start with a drive, like "C:", or a server's share, like "//server/share". What a Path does to its text is only text: nothing here looks at the disk but Absolute, which asks for the current folder.
std/io/path.fb
Types
PathStyle
enum
Public Enum PathStyle
Whose rules a Path reads its text by.
-
Linux's and macOS's:
/between names. -
Windows's:
\or/between names, and a drive, likeC:, or a share, like//server/share, before them.
Path
struct
Public Struct Path Implements Comparable, Hashable, Printable
Where a file or folder is. Paths are equal when their texts and styles are, so "a/b" and "a//b" aren't until Normalize makes them so, and they sort by their styles, POSIX's first, then by their texts' bytes. A Path's zero, as a Struct's Field starts with, is "" by the target's rules, as Path("") is.
-
Its text, as it was given.
-
A path by the target's rules.
-
A path by
style's rules, whatever the target's are. -
Whose rules it reads its text by.
-
The target's style: WINDOWS on Windows, and POSIX everywhere else.
-
baftera, as Join puts it:saves / "one.dat", since a String converts to a Path. -
Whether
acomes beforeb.Doc from
std.core.interfaces.Comparable.Operator<. -
Whether
aandbare equal.Doc from
std.core.interfaces.Equatable.Operator==. -
Its hash, the same for values that are equal.
Doc from
std.core.interfaces.Hashable.Hash. -
Its text, as a string interpolation like "{value}" shows it.
Doc from
std.core.interfaces.Printable.ToString. -
otherafter this one, with a '/' between them unless this one ends with a separator. Anotherthat's absolute is where it says, and on Windows one that starts at a root, like "/saves", is on this one's drive. An empty one adds nothing, and this one empty gives it. -
The last name in the path, "" when it has none, as a root doesn't: "save.dat" for "games/save.dat" and for "games/save.dat/" too.
-
The file name without its extension: "save" for "save.dat", ".config" for ".config", and "archive.tar" for "archive.tar.gz".
-
The file name's extension with its dot, like ".dat", or "" when it has none. A name that starts with its only dot, like ".config", or ends with one has none.
-
The path with its file name's extension
extension, which a dot is put before when it has none, or without one when it's "": "save.bak" for "save.dat" and ".bak". The name is FileName's, so "a/b/." and "a/b/" give "a/b.bak", without what follows the name. Panics when the path has no file name to give one, as a root or ".." doesn't, or for an extension with a separator in it, or that ends with a dot, which a name can't end its extension with. -
The folder the path's in: "games" for "games/save.dat", "." for "save.dat", and the root for a root, worked out from its text alone, so the parent of ".." is ".". It has '/' between its names.
-
Whether the path says where it is without the current folder: one from a POSIX root, and on Windows one from a drive's root, like "C:/games", or a share, like "//server/share".
-
The same place in the fewest names: '/' between them, no "." or empty ones, and each ".." taking out the name before it, which is only text, so a link's ".." isn't followed. One with no names left is "." or its root. On Windows, a drive or share keeps its case, and a share is written without a separator after it, which "//server/share/" has.
-
The path from
baseto this one, by their texts, with ".." for each ofbase's names they don't share: "saves/one.dat" from "games" to "games/saves/one.dat", and "../music" from "games" to "music". On Windows, names that differ only in their ASCII letters' case are the same. Null when one is absolute and the other isn't, they're on different drives, orbasegoes up past where this one starts, as "../other" from "a" does. -
The path from the current folder's root, normalized: the path itself when it's absolute. On Windows, one from a root without a drive is on the current folder's drive. Throws an IOError when the OS doesn't say what the current folder is. Panics for a path by the other OS's rules that isn't absolute by them, since the current folder is by the target's.
Report an issue with this page or with FutureBlitz on GitHub.