Found 704927 results in 80920 files, showing top 50 files (show more).
android.googlesource.com/platform/external/python/parse_type:tasks/_vendor/pathlib.py: [ master, ]
928: class Path(PurePath):
210:     def _split_extended_path(self, s, ext_prefix=ext_namespace_prefix):
134:     pathmod = ntpath
253:     pathmod = posixpath
565: class PurePath(object):
844:     def joinpath(self, *args):
915: class PurePosixPath(PurePath):
920: class PureWindowsPath(PurePath):
952:     def _make_child_relpath(self, part):
1275: class PosixPath(Path, PurePosixPath):
1278: class WindowsPath(Path, PureWindowsPath):
537: class _PathParents(Sequence):
40:         _getfinalpathname = None
45:     "Path", "PosixPath", "WindowsPath",
67:     """A flavour implements a particular (platform-specific) set of path
119:                 # Same drive => second path is relative to the first
122:             # Second path is non-anchored (common case)
162:             prefix, part = self._split_extended_path(part)
169:             # is a UNC path:
176:                 # a UNC path can't have two slashes in a row
201:     def resolve(self, path):
202:         s = str(path)
221:         # Turn back an extended path into a normal DOS-like path
222:         return self._split_extended_path(s)[1]
236:     def make_uri(self, path):
238:         drive = path.drive
240:             # It's a path on a local drive => 'file:///c:/a/b'
241:             rest = path.as_posix()[2:].lstrip('/')
245:             # It's a path on a network drive => 'file://host/share/a/b'
246:             return 'file:' + urlquote_from_bytes(path.as_posix().encode('utf-8'))
260:             # According to POSIX path resolution:
278:     def resolve(self, path):
280:         accessor = path._accessor
282:         def _resolve(path, rest):
284:                 path = ''
292:                     path, _, _ = path.rpartition(sep)
294:                 newpath = path + sep + name
296:                     # Already seen this path
297:                     path = seen[newpath]
298:                     if path is not None:
310:                     path = newpath
313:                     path = _resolve(path, target)
314:                     seen[newpath] = path # resolved symlink
316:             return path
317:         # NOTE: according to POSIX, getcwd() cannot contain path components
319:         base = '' if path.is_absolute() else os.getcwd()
320:         return _resolve(base, str(path)) or sep
325:     def make_uri(self, path):
326:         # We represent the path using the local filesystem encoding,
328:         bpath = bytes(path)
397:     def readlink(self, path):
398:         return os.readlink(path)
433:         raise ValueError("Invalid pattern: '**' can only be an entire path component")
446:     of a given path."""
455:     def select_from(self, parent_path):
456:         """Iterate over all child paths of `parent_path` matched by this
457:         selector.  This can contain parent_path itself."""
458:         path_cls = type(parent_path)
459:         is_dir = path_cls.is_dir
460:         exists = path_cls.exists
461:         listdir = parent_path._accessor.listdir
462:         return self._select_from(parent_path, is_dir, exists, listdir)
467:     def _select_from(self, parent_path, is_dir, exists, listdir):
468:         yield parent_path
477:     def _select_from(self, parent_path, is_dir, exists, listdir):
478:         if not is_dir(parent_path):
480:         path = parent_path._make_child_relpath(self.name)
481:         if exists(path):
482:             for p in self.successor._select_from(path, is_dir, exists, listdir):
492:     def _select_from(self, parent_path, is_dir, exists, listdir):
493:         if not is_dir(parent_path):
495:         cf = parent_path._flavour.casefold
496:         for name in listdir(parent_path):
499:                 path = parent_path._make_child_relpath(name)
500:                 for p in self.successor._select_from(path, is_dir, exists, listdir):
509:     def _iterate_directories(self, parent_path, is_dir, listdir):
510:         yield parent_path
511:         for name in listdir(parent_path):
512:             path = parent_path._make_child_relpath(name)
513:             if is_dir(path):
514:                 for p in self._iterate_directories(path, is_dir, listdir):
517:     def _select_from(self, parent_path, is_dir, exists, listdir):
518:         if not is_dir(parent_path):
524:                 for starting_point in self._iterate_directories(parent_path, is_dir, listdir):
539:     of a path.  Don't try to construct it yourself."""
542:     def __init__(self, path):
544:         self._pathcls = type(path)
545:         self._drv = path._drv
546:         self._root = path._root
547:         self._parts = path._parts
566:     """PurePath represents a filesystem path and offers operations which
579:         PurePath objects.  The strings and path objects are combined so as
580:         to yield a canonicalized path, which is incorporated into the
588:         # Using the parts tuple helps share interned path parts
604:                     "argument should be a path or str object, not %r"
639:         # Overriden in concrete Path
649:         """Return the string representation of the path, suitable for
659:         """Return the string representation of the path with forward (/)
665:         """Return the bytes representation of the path.  This is only
675:         """Return the path as a 'file' URI."""
677:             raise ValueError("relative path can't be expressed as a file URI")
725:                      doc="""The drive prefix (letter or UNC path), if any.""")
728:                     doc="""The root of the path, if any.""")
738:         """The final path component, if any."""
765:         """The final path component, minus its last suffix."""
774:         """Return a new path with the file name changed."""
781:         """Return a new path with the file suffix changed (or added, if none)."""
801:         """Return the relative path to another path identified by the passed
803:         a subpath of the other path), raise ValueError.
807:         #   Path('c:/').relative_to('c:')  gives Path('/')
808:         #   Path('c:/').relative_to('/')   raise ValueError
835:         components in the filesystem path."""
845:         """Combine this path with one or several arguments, and return a
846:         new path representing either a subpath (if all arguments are relative
847:         paths) or a totally different path (if one of the arguments is
864:         """The logical parent of the path."""
874:         """A sequence of this path's logical parents."""
878:         """True if the path is absolute (has both a root and, if applicable,
885:         """Return True if the path contains one of the special names reserved
889:     def match(self, path_pattern):
891:         Return True if this path matches the given pattern.
894:         path_pattern = cf(path_pattern)
895:         drv, root, pat_parts = self._flavour.parse_parts((path_pattern,))
934:         if cls is Path:
954:         # a single part relative to this path.
964:         Open the file pointed by this path and return a file descriptor,
973:         """Return a new path pointing to the current working directory
984:                 # Yielding a path object for these makes little sense
1013:         """Return an absolute version of this path.  This function works
1014:         even if the path doesn't point to anything.
1017:         Use resolve() to get the canonical path to a file.
1030:         Make the path absolute, resolving all symlinks on the way and also
1037:             # the path doesn't exist or is forbidden
1040:         # Now we have no symlinks in the path, it's safe to normalize it.
1048:         Return the result of the stat() system call on this path, like
1070:         Open the file pointed by this path and return a file object, as
1115:         Change the permissions of the path, like os.chmod().
1121:         Like chmod(), except if the path points to a symlink, the symlink's
1129:         If the path is a directory, use rmdir() instead.
1141:         Like stat(), except if the path points to a symlink, the symlink's
1148:         Rename this path to the given path.
1154:         Rename this path to the given path, clobbering the existing
1164:         Make this path a symlink pointing to the given path.
1173:         Whether this path exists.
1185:         Whether this path is a directory.
1192:             # Path doesn't exist or is a broken symlink
1198:         Whether this path is a regular file (also True for symlinks pointing
1206:             # Path doesn't exist or is a broken symlink
1212:         Whether this path is a symbolic link.
1219:             # Path doesn't exist
1224:         Whether this path is a block device.
1231:             # Path doesn't exist or is a broken symlink
1237:         Whether this path is a character device.
1244:             # Path doesn't exist or is a broken symlink
1250:         Whether this path is a FIFO.
1257:             # Path doesn't exist or is a broken symlink
1263:         Whether this path is a socket.
1270:             # Path doesn't exist or is a broken symlink
4: import ntpath
6: import posixpath
44:     "PurePath", "PurePosixPath", "PureWindowsPath",
111:         Join the two paths represented by the respective
128:     # Reference for Windows paths can be found at
150:     # Interesting findings about extended paths:
153:     # - extended paths are always absolute; "relative" extended paths will
160:             # XXX extended paths should also disable the collapsing of "."
227:         # We err on the side of caution and return True for paths which are
232:             # UNC paths are never reserved
262:             # "A pathname that begins with two successive slashes may be
295:                 if newpath in seen:
302:                     raise RuntimeError("Symlink loop from %r" % newpath)
305:                     target = accessor.readlink(newpath)
312:                     seen[newpath] = None # not resolved symlink
329:         return 'file://' + urlquote_from_bytes(bpath)
338:     accessing paths on the filesystem."""
345:         def wrapped(pathobj, *args):
346:             return strfunc(str(pathobj), *args)
351:         def wrapped(pathobjA, pathobjB, *args):
352:             return strfunc(str(pathobjA), str(pathobjB), *args)
368:         def lchmod(self, pathobj, mode):
540:     __slots__ = ('_pathcls', '_drv', '_root', '_parts')
558:         return self._pathcls._from_parsed_parts(self._drv, self._root,
562:         return "<{0}.parents>".format(self._pathcls.__name__)
568:     instantiating a PurePath will return either a PurePosixPath or a
569:     PureWindowsPath object.  You can also instantiate either of these classes
578:         """Construct a PurePath from one or several strings and or existing
581:         new PurePath object.
583:         if cls is PurePath:
584:             cls = PureWindowsPath if os.name == 'nt' else PurePosixPath
589:         # when pickling related paths.
598:             if isinstance(a, PurePath):
690:         if not isinstance(other, PurePath):
705:         if not isinstance(other, PurePath) or self._flavour is not other._flavour:
710:         if not isinstance(other, PurePath) or self._flavour is not other._flavour:
715:         if not isinstance(other, PurePath) or self._flavour is not other._flavour:
720:         if not isinstance(other, PurePath) or self._flavour is not other._flavour:
875:         return _PathParents(self)
935:             cls = WindowsPath if os.name == 'nt' else PosixPath
980:         result for the special paths '.' and '..'.
986:             yield self._make_child_relpath(name)
1041:         normed = self._flavour.pathmod.normpath(s)
1193:             # (see https://bitbucket.org/pitrou/pathlib/issue/12/)
1207:             # (see https://bitbucket.org/pitrou/pathlib/issue/12/)
1232:             # (see https://bitbucket.org/pitrou/pathlib/issue/12/)
1245:             # (see https://bitbucket.org/pitrou/pathlib/issue/12/)
1258:             # (see https://bitbucket.org/pitrou/pathlib/issue/12/)
1271:             # (see https://bitbucket.org/pitrou/pathlib/issue/12/)
37:         from nt import _getfinalpathname
205:         if _getfinalpathname is not None:
206:             return self._ext_to_normal(_getfinalpathname(s))
1023:         # use nt._getfullpathname())
github.com/apache/incubator-teaclave-sgx-sdk:sgx_tstd/src/path.rs: [ master, ]
582:     path: &'a [u8],
1748: impl ToOwned for Path {
1835: pub struct Path {
1848: impl Path {
2746: impl AsRef<OsStr> for Path {
2753: impl fmt::Debug for Path {
2780:     path: &'a Path,
2795: impl cmp::PartialEq for Path {
2802: impl Hash for Path {
2853: impl cmp::Eq for Path {}
2855: impl cmp::PartialOrd for Path {
2862: impl cmp::Ord for Path {
2869: impl AsRef<Path> for Path {
2927: impl<'a> IntoIterator for &'a Path {
675:     pub fn as_path(&self) -> &'a Path {
817:     pub fn as_path(&self) -> &'a Path {
1186:     pub fn as_path(&self) -> &Path {
1435:     pub fn into_boxed_path(self) -> Box<Path> {
1124: pub struct PathBuf {
1128: impl PathBuf {
1507: impl Clone for PathBuf {
1543: impl From<Box<Path>> for PathBuf {
1571: impl<T: ?Sized + AsRef<OsStr>> From<&T> for PathBuf {
1581: impl From<OsString> for PathBuf {
1601: impl From<String> for PathBuf {
1611: impl FromStr for PathBuf {
1620: impl<P: AsRef<Path>> iter::FromIterator<P> for PathBuf {
1628: impl<P: AsRef<Path>> iter::Extend<P> for PathBuf {
1639: impl fmt::Debug for PathBuf {
1645: impl ops::Deref for PathBuf {
1653: impl Borrow<Path> for PathBuf {
1660: impl Default for PathBuf {
1700: impl<'a> From<Cow<'a, Path>> for PathBuf {
1760: impl cmp::PartialEq for PathBuf {
1767: impl Hash for PathBuf {
1773: impl cmp::Eq for PathBuf {}
1775: impl cmp::PartialOrd for PathBuf {
1782: impl cmp::Ord for PathBuf {
1789: impl AsRef<OsStr> for PathBuf {
2911: impl AsRef<Path> for PathBuf {
2918: impl<'a> IntoIterator for &'a PathBuf {
1964:     pub fn to_path_buf(&self) -> PathBuf {
2739:     pub fn into_path_buf(self: Box<Path>) -> PathBuf {
18: //! Cross-platform path manipulation.
20: //! This module provides two types, [`PathBuf`] and [`Path`] (akin to [`String`]
23: //! on strings according to the local platform's path syntax.
26: //! returned by the [`components`] method on [`Path`]. [`Component`]s roughly
27: //! correspond to the substrings between path separators (`/` or `\`). You can
28: //! reconstruct an equivalent path from components with the [`push`] method on
34: //! Unless otherwise indicated path methods that do not access the filesystem,
35: //! such as [`Path::starts_with`] and [`Path::ends_with`], are case sensitive no
41: //! Path manipulation includes both parsing components from slices and building
44: //! To parse a path, you can create a [`Path`] slice from a [`str`]
48: //! use std::path::Path;
51: //! let path = Path::new("/tmp/foo/bar.txt");
53: //! let parent = path.parent();
54: //! assert_eq!(parent, Some(Path::new("/tmp/foo")));
56: //! let file_stem = path.file_stem();
59: //! let extension = path.extension();
66: //! use std::path::PathBuf;
69: //! let mut path = PathBuf::from("c:\\");
71: //! path.push("windows");
72: //! path.push("system32");
74: //! path.set_extension("dll");
78: //! let path: PathBuf = ["c:\\", "windows", "system32.dll"].iter().collect();
81: //! [`components`]: Path::components
104: use crate::sys::path::{is_sep_byte, is_verbatim_sep, parse_prefix, MAIN_SEP_STR};
120: /// Windows path prefixes, e.g., `C:` or `\\server\share`.
122: /// Windows uses a variety of path prefix styles, including references to drive
124: /// others. In addition, some path prefixes are "verbatim" (i.e., prefixed with
131: /// use std::path::{Component, Path, Prefix};
132: /// use std::path::Prefix::*;
135: /// fn get_path_prefix(s: &str) -> Prefix {
136: ///     let path = Path::new(s);
137: ///     match path.components().next().unwrap() {
145: ///            get_path_prefix(r"\\?\pictures\kittens"));
147: ///            get_path_prefix(r"\\?\UNC\server\share"));
148: /// assert_eq!(VerbatimDisk(b'C'), get_path_prefix(r"\\?\c:\"));
150: ///            get_path_prefix(r"\\.\BrainInterface"));
152: ///            get_path_prefix(r"\\server\share"));
153: /// assert_eq!(Disk(b'C'), get_path_prefix(r"C:\Users\Rust\Pictures\Ferris"));
218:     /// use std::path::Prefix::*;
250: /// Determines whether the character is one of the permitted path
256: /// use std::path;
258: /// assert!(path::is_separator('/')); // '/' works for both Unix and Windows
259: /// assert!(!path::is_separator('❤'));
266: /// The primary separator of path components for the current platform.
269: pub const MAIN_SEPARATOR: char = crate::sys::path::MAIN_SEP;
271: /// The primary separator of path components for the current platform.
274: pub const MAIN_SEPARATOR_STR: &str = crate::sys::path::MAIN_SEP_STR;
322:     let path = if let Some(p) = prefix { &s[p.len()..] } else { s };
323:     !path.is_empty() && is_sep_byte(path[0])
370: /// front and back of the path each keep track of what parts of the path have
373: /// Going front to back, a path is made up of a prefix, a starting
383: /// A structure wrapping a Windows path prefix as well as its unparsed string
399: /// use std::path::{Component, Path, Prefix};
402: /// let path = Path::new(r"c:\you\later\");
403: /// match path.components().next().unwrap() {
471: /// A single component of a path.
473: /// A `Component` roughly corresponds to a substring between path separators
477: /// created by the [`components`](Path::components) method on [`Path`].
482: /// use std::path::{Component, Path};
484: /// let path = Path::new("/tmp/foo/bar.txt");
485: /// let components = path.components().collect::<Vec<_>>();
496:     /// A Windows path prefix, e.g., `C:` or `\\server\share`.
506:     /// It represents a separator that designates that a path starts from root.
528:     /// use std::path::Path;
530:     /// let path = Path::new("./tmp/foo/bar.txt");
531:     /// let components: Vec<_> = path.components().map(|comp| comp.as_os_str()).collect();
541:             Component::Normal(path) => path,
553: impl AsRef<Path> for Component<'_> {
555:     fn as_ref(&self) -> &Path {
560: /// An iterator over the [`Component`]s of a [`Path`].
562: /// This `struct` is created by the [`components`] method on [`Path`].
568: /// use std::path::Path;
570: /// let path = Path::new("/tmp/foo/bar.txt");
572: /// for component in path.components() {
577: /// [`components`]: Path::components
581:     // The path left to parse components from
587:     // true if path *physically* has a root separator; for most Windows
598: /// An iterator over the [`Component`]s of a [`Path`], as [`OsStr`] slices.
600: /// This `struct` is created by the [`iter`] method on [`Path`].
603: /// [`iter`]: Path::iter
612:         struct DebugHelper<'a>(&'a Path);
620:         f.debug_tuple("Components").field(&DebugHelper(self.as_path())).finish()
642:     // Given the iteration so far, how much of the pre-State::Body path is left?
661:     /// Extracts a slice corresponding to the portion of the path remaining for iteration.
666:     /// use std::path::Path;
668:     /// let mut components = Path::new("/tmp/foo/bar.txt").components();
672:     /// assert_eq!(Path::new("foo/bar.txt"), components.as_path());
683:         unsafe { Path::from_u8_slice(comps.path) }
686:     /// Is the *original* path rooted?
699:     /// Should the normalized path include a leading . ?
704:         let mut iter = self.path[self.prefix_remaining()..].iter();
712:     // parse a given byte sequence into the corresponding path component
717:             // the beginning of a path, which is treated
729:         let (extra, comp) = match self.path.iter().position(|b| self.is_sep_byte(*b)) {
730:             None => (0, self.path),
731:             Some(i) => (1, &self.path[..i]),
741:         let (extra, comp) = match self.path[start..].iter().rposition(|b| self.is_sep_byte(*b)) {
742:             None => (0, &self.path[start..]),
743:             Some(i) => (1, &self.path[start + i + 1..]),
750:         while !self.path.is_empty() {
755:                 self.path = &self.path[size..];
762:         while self.path.len() > self.len_before_body() {
767:                 self.path = &self.path[..self.path.len() - size];
773: impl AsRef<Path> for Components<'_> {
775:     fn as_ref(&self) -> &Path {
776:         self.as_path()
783:         self.as_path().as_os_str()
789:         struct DebugHelper<'a>(&'a Path);
797:         f.debug_tuple("Iter").field(&DebugHelper(self.as_path())).finish()
802:     /// Extracts a slice corresponding to the portion of the path remaining for iteration.
807:     /// use std::path::Path;
809:     /// let mut iter = Path::new("/tmp/foo/bar.txt").iter();
813:     /// assert_eq!(Path::new("foo/bar.txt"), iter.as_path());
818:         self.inner.as_path()
822: impl AsRef<Path> for Iter<'_> {
824:     fn as_ref(&self) -> &Path {
825:         self.as_path()
832:         self.as_path().as_os_str()
862:                     debug_assert!(self.prefix_len() <= self.path.len());
863:                     let raw = &self.path[..self.prefix_len()];
864:                     self.path = &self.path[self.prefix_len()..];
876:                         debug_assert!(!self.path.is_empty());
877:                         self.path = &self.path[1..];
884:                         debug_assert!(!self.path.is_empty());
885:                         self.path = &self.path[1..];
889:                 State::Body if !self.path.is_empty() => {
891:                     self.path = &self.path[size..];
910:                 State::Body if self.path.len() > self.len_before_body() => {
912:                     self.path = &self.path[..self.path.len() - size];
923:                         self.path = &self.path[..self.path.len() - 1];
930:                         self.path = &self.path[..self.path.len() - 1];
937:                         raw: unsafe { u8_slice_as_os_str(self.path) },
957:         let Components { path: _, front: _, back: _, has_physical_root: _, prefix: _ } = self;
959:         // Fast path for exact matches, e.g. for hashmap lookups.
961:         // either be covered by the `path` buffer or are only relevant for `prefix_verbatim()`.
962:         if self.path.len() == other.path.len()
970:             if self.path == other.path {
997:     // Fast path for long shared prefixes
1002:     //   otherwise do it on the full path
1004:     // The fast path isn't taken for paths with a PrefixComponent to avoid backtracking into
1008:         let first_difference = match left.path.iter().zip(right.path).position(|(&a, &b)| a != b) {
1009:             None if left.path.len() == right.path.len() => return cmp::Ordering::Equal,
1010:             None => left.path.len().min(right.path.len()),
1015:             left.path[..first_difference].iter().rposition(|&b| left.is_sep_byte(b))
1018:             left.path = &left.path[mismatched_component_start..];
1020:             right.path = &right.path[mismatched_component_start..];
1028: /// An iterator over [`Path`] and its ancestors.
1030: /// This `struct` is created by the [`ancestors`] method on [`Path`].
1036: /// use std::path::Path;
1038: /// let path = Path::new("/foo/bar");
1040: /// for ancestor in path.ancestors() {
1045: /// [`ancestors`]: Path::ancestors
1049:     next: Option<&'a Path>,
1053:     type Item = &'a Path;
1058:         self.next = next.and_then(Path::parent);
1069: /// An owned, mutable path (akin to [`String`]).
1072: /// the path in place. It also implements [`Deref`] to [`Path`], meaning that
1073: /// all methods on [`Path`] slices are available on `PathBuf` values as well.
1087: /// use std::path::PathBuf;
1089: /// let mut path = PathBuf::new();
1091: /// path.push(r"C:\");
1092: /// path.push("windows");
1093: /// path.push("system32");
1095: /// path.set_extension("dll");
1102: /// use std::path::PathBuf;
1104: /// let path: PathBuf = [r"C:\", "windows", "system32.dll"].iter().collect();
1111: /// use std::path::PathBuf;
1113: /// let path = PathBuf::from(r"C:\windows\system32.dll");
1139:     /// use std::path::PathBuf;
1141:     /// let path = PathBuf::new();
1155:     /// use std::path::PathBuf;
1157:     /// let mut path = PathBuf::with_capacity(10);
1158:     /// let capacity = path.capacity();
1161:     /// path.push(r"C:\");
1163:     /// assert_eq!(capacity, path.capacity());
1173:     /// Coerces to a [`Path`] slice.
1178:     /// use std::path::{Path, PathBuf};
1181:     /// assert_eq!(Path::new("/test"), p.as_path());
1190:     /// Extends `self` with `path`.
1192:     /// If `path` is absolute, it replaces the current path.
1196:     /// * if `path` has a root but no prefix (e.g., `\windows`), it
1198:     /// * if `path` has a prefix but no root, it replaces `self`.
1200:     ///   and `path` is not empty, the new path is normalized: all references
1205:     /// Pushing a relative path extends the existing path:
1208:     /// use std::path::PathBuf;
1210:     /// let mut path = PathBuf::from("/tmp");
1211:     /// path.push("file.bk");
1212:     /// assert_eq!(path, PathBuf::from("/tmp/file.bk"));
1215:     /// Pushing an absolute path replaces the existing path:
1218:     /// use std::path::PathBuf;
1220:     /// let mut path = PathBuf::from("/tmp");
1221:     /// path.push("/etc");
1222:     /// assert_eq!(path, PathBuf::from("/etc"));
1224:     pub fn push<P: AsRef<Path>>(&mut self, path: P) {
1225:         self._push(path.as_ref())
1228:     fn _push(&mut self, path: &Path) {
1236:             && comps.prefix_len() == comps.path.len()
1242:         // absolute `path` replaces `self`
1243:         if path.is_absolute() || path.prefix().is_some() {
1247:         } else if comps.prefix_verbatim() && !path.inner.is_empty() {
1249:             for c in path.components() {
1286:         // `path` has a root but no prefix, e.g., `\windows` (Windows only)
1287:         } else if path.has_root() {
1291:         // `path` is a pure relative path
1296:         self.inner.push(path);
1304:     /// [`self.parent`]: Path::parent
1309:     /// use std::path::{Path, PathBuf};
1314:     /// assert_eq!(Path::new("/spirited"), p);
1316:     /// assert_eq!(Path::new("/"), p);
1334:     /// `file_name`. The new path will be a sibling of the original path.
1337:     /// [`self.file_name`]: Path::file_name
1343:     /// use std::path::PathBuf;
1373:     /// [`self.file_name`]: Path::file_name
1374:     /// [`self.extension`]: Path::extension
1379:     /// use std::path::{Path, PathBuf};
1384:     /// assert_eq!(Path::new("/feel/the.force"), p.as_path());
1387:     /// assert_eq!(Path::new("/feel/the.dark_side"), p.as_path());
1421:     /// use std::path::PathBuf;
1432:     /// Converts this `PathBuf` into a [boxed](Box) [`Path`].
1436:         let rw = Box::into_raw(self.inner.into_boxed_os_str()) as *mut Path;
1519: impl From<&Path> for Box<Path> {
1520:     /// Creates a boxed [`Path`] from a reference.
1522:     /// This will allocate and clone `path` to it.
1523:     fn from(path: &Path) -> Box<Path> {
1524:         let boxed: Box<OsStr> = path.inner.into();
1525:         let rw = Box::into_raw(boxed) as *mut Path;
1530: impl From<Cow<'_, Path>> for Box<Path> {
1531:     /// Creates a boxed [`Path`] from a clone-on-write pointer.
1535:     fn from(cow: Cow<'_, Path>) -> Box<Path> {
1537:             Cow::Borrowed(path) => Box::from(path),
1538:             Cow::Owned(path) => Box::from(path),
1544:     /// Converts a <code>[Box]&lt;[Path]&gt;</code> into a [`PathBuf`].
1548:     fn from(boxed: Box<Path>) -> PathBuf {
1549:         boxed.into_path_buf()
1553: impl From<PathBuf> for Box<Path> {
1554:     /// Converts a [`PathBuf`] into a <code>[Box]&lt;[Path]&gt;</code>.
1559:     fn from(p: PathBuf) -> Box<Path> {
1560:         p.into_boxed_path()
1564: impl Clone for Box<Path> {
1567:         self.to_path_buf().into_boxed_path()
1596:     fn from(path_buf: PathBuf) -> OsString {
1597:         path_buf.inner
1646:     type Target = Path;
1648:     fn deref(&self) -> &Path {
1649:         Path::new(&self.inner)
1655:     fn borrow(&self) -> &Path {
1667: impl<'a> From<&'a Path> for Cow<'a, Path> {
1669:     /// [`Path`].
1673:     fn from(s: &'a Path) -> Cow<'a, Path> {
1678: impl<'a> From<PathBuf> for Cow<'a, Path> {
1684:     fn from(s: PathBuf) -> Cow<'a, Path> {
1689: impl<'a> From<&'a PathBuf> for Cow<'a, Path> {
1695:     fn from(p: &'a PathBuf) -> Cow<'a, Path> {
1696:         Cow::Borrowed(p.as_path())
1701:     /// Converts a clone-on-write pointer to an owned path.
1705:     fn from(p: Cow<'a, Path>) -> Self {
1710: impl From<PathBuf> for Arc<Path> {
1711:     /// Converts a [`PathBuf`] into an <code>[Arc]<[Path]></code> by moving the [`PathBuf`] data
1714:     fn from(s: PathBuf) -> Arc<Path> {
1716:         unsafe { Arc::from_raw(Arc::into_raw(arc) as *const Path) }
1720: impl From<&Path> for Arc<Path> {
1721:     /// Converts a [`Path`] into an [`Arc`] by copying the [`Path`] data into a new [`Arc`] buffer.
1723:     fn from(s: &Path) -> Arc<Path> {
1725:         unsafe { Arc::from_raw(Arc::into_raw(arc) as *const Path) }
1729: impl From<PathBuf> for Rc<Path> {
1730:     /// Converts a [`PathBuf`] into an <code>[Rc]<[Path]></code> by moving the [`PathBuf`] data into
1733:     fn from(s: PathBuf) -> Rc<Path> {
1735:         unsafe { Rc::from_raw(Rc::into_raw(rc) as *const Path) }
1739: impl From<&Path> for Rc<Path> {
1740:     /// Converts a [`Path`] into an [`Rc`] by copying the [`Path`] data into a new [`Rc`] buffer.
1742:     fn from(s: &Path) -> Rc<Path> {
1744:         unsafe { Rc::from_raw(Rc::into_raw(rc) as *const Path) }
1752:         self.to_path_buf()
1769:         self.as_path().hash(h)
1796: /// A slice of a path (akin to [`str`]).
1798: /// This type supports a number of operations for inspecting a path, including
1799: /// breaking the path into its components (separated by `/` on Unix and by either
1800: /// `/` or `\` on Windows), extracting the file name, determining whether the path
1813: /// use std::path::Path;
1817: /// let path = Path::new("./foo/bar.txt");
1819: /// let parent = path.parent();
1820: /// assert_eq!(parent, Some(Path::new("./foo")));
1822: /// let file_stem = path.file_stem();
1825: /// let extension = path.extension();
1828: #[cfg_attr(not(test), rustc_diagnostic_item = "Path")]
1830: // `Path::new` current implementation relies
1831: // on `Path` being layout-compatible with `OsStr`.
1832: // When attribute privacy is implemented, `Path` should be annotated as `#[repr(transparent)]`.
1833: // Anyway, `Path` representation and layout are considered implementation detail, are
1839: /// An error returned from [`Path::strip_prefix`] if the prefix was not found.
1841: /// This `struct` is created by the [`strip_prefix`] method on [`Path`].
1844: /// [`strip_prefix`]: Path::strip_prefix
1849:     // The following (private!) function allows construction of a path from a u8
1851:     unsafe fn from_u8_slice(s: &[u8]) -> &Path {
1852:         Path::new(u8_slice_as_os_str(s))
1859:     /// Directly wraps a string slice as a `Path` slice.
1866:     /// use std::path::Path;
1868:     /// Path::new("foo.txt");
1871:     /// You can create `Path`s from `String`s, or even other `Path`s:
1874:     /// use std::path::Path;
1877:     /// let from_string = Path::new(&string);
1878:     /// let from_path = Path::new(&from_string);
1879:     /// assert_eq!(from_string, from_path);
1881:     pub fn new<S: AsRef<OsStr> + ?Sized>(s: &S) -> &Path {
1882:         unsafe { &*(s.as_ref() as *const OsStr as *const Path) }
1890:     /// use std::path::Path;
1892:     /// let os_str = Path::new("foo.txt").as_os_str();
1901:     /// Yields a [`&str`] slice if the `Path` is valid unicode.
1912:     /// use std::path::Path;
1914:     /// let path = Path::new("foo.txt");
1915:     /// assert_eq!(path.to_str(), Some("foo.txt"));
1924:     /// Converts a `Path` to a [`Cow<str>`].
1933:     /// Calling `to_string_lossy` on a `Path` with valid unicode:
1936:     /// use std::path::Path;
1938:     /// let path = Path::new("foo.txt");
1939:     /// assert_eq!(path.to_string_lossy(), "foo.txt");
1942:     /// Had `path` contained invalid unicode, the `to_string_lossy` call might
1951:     /// Converts a `Path` to an owned [`PathBuf`].
1956:     /// use std::path::Path;
1958:     /// let path_buf = Path::new("foo.txt").to_path_buf();
1959:     /// assert_eq!(path_buf, std::path::PathBuf::from("foo.txt"));
1968:     /// Returns `true` if the `Path` is absolute, i.e., if it is independent of
1971:     /// * On Unix, a path is absolute if it starts with the root, so
1974:     /// * On Windows, a path is absolute if it has a prefix and starts with the
1980:     /// use std::path::Path;
1982:     /// assert!(!Path::new("foo.txt").is_absolute());
1985:     /// [`has_root`]: Path::has_root
1992:     /// Returns `true` if the `Path` is relative, i.e., not absolute.
1999:     /// use std::path::Path;
2001:     /// assert!(Path::new("foo.txt").is_relative());
2004:     /// [`is_absolute`]: Path::is_absolute
2015:     /// Returns `true` if the `Path` has a root.
2017:     /// * On Unix, a path has a root if it begins with `/`.
2019:     /// * On Windows, a path has a root if it:
2027:     /// use std::path::Path;
2029:     /// assert!(Path::new("/etc/passwd").has_root());
2037:     /// Returns the `Path` without its final component, if there is one.
2039:     /// Returns [`None`] if the path terminates in a root or prefix.
2044:     /// use std::path::Path;
2046:     /// let path = Path::new("/foo/bar");
2047:     /// let parent = path.parent().unwrap();
2048:     /// assert_eq!(parent, Path::new("/foo"));
2051:     /// assert_eq!(grand_parent, Path::new("/"));
2055:     pub fn parent(&self) -> Option<&Path> {
2060:                 Some(comps.as_path())
2066:     /// Produces an iterator over `Path` and its ancestors.
2068:     /// The iterator will yield the `Path` that is returned if the [`parent`] method is used zero
2077:     /// use std::path::Path;
2079:     /// let mut ancestors = Path::new("/foo/bar").ancestors();
2080:     /// assert_eq!(ancestors.next(), Some(Path::new("/foo/bar")));
2081:     /// assert_eq!(ancestors.next(), Some(Path::new("/foo")));
2082:     /// assert_eq!(ancestors.next(), Some(Path::new("/")));
2085:     /// let mut ancestors = Path::new("../foo/bar").ancestors();
2086:     /// assert_eq!(ancestors.next(), Some(Path::new("../foo/bar")));
2087:     /// assert_eq!(ancestors.next(), Some(Path::new("../foo")));
2088:     /// assert_eq!(ancestors.next(), Some(Path::new("..")));
2089:     /// assert_eq!(ancestors.next(), Some(Path::new("")));
2093:     /// [`parent`]: Path::parent
2099:     /// Returns the final component of the `Path`, if there is one.
2101:     /// If the path is a normal file, this is the file name. If it's the path of a directory, this
2104:     /// Returns [`None`] if the path terminates in `..`.
2109:     /// use std::path::Path;
2112:     /// assert_eq!(Some(OsStr::new("bin")), Path::new("/usr/bin/").file_name());
2113:     /// assert_eq!(Some(OsStr::new("foo.txt")), Path::new("tmp/foo.txt").file_name());
2114:     /// assert_eq!(Some(OsStr::new("foo.txt")), Path::new("foo.txt/.").file_name());
2115:     /// assert_eq!(Some(OsStr::new("foo.txt")), Path::new("foo.txt/.//").file_name());
2116:     /// assert_eq!(None, Path::new("foo.txt/..").file_name());
2117:     /// assert_eq!(None, Path::new("/").file_name());
2127:     /// Returns a path that, when joined onto `base`, yields `self`.
2134:     /// [`starts_with`]: Path::starts_with
2139:     /// use std::path::{Path, PathBuf};
2141:     /// let path = Path::new("/test/haha/foo.txt");
2143:     /// assert_eq!(path.strip_prefix("/"), Ok(Path::new("test/haha/foo.txt")));
2144:     /// assert_eq!(path.strip_prefix("/test"), Ok(Path::new("haha/foo.txt")));
2145:     /// assert_eq!(path.strip_prefix("/test/"), Ok(Path::new("haha/foo.txt")));
2146:     /// assert_eq!(path.strip_prefix("/test/haha/foo.txt"), Ok(Path::new("")));
2147:     /// assert_eq!(path.strip_prefix("/test/haha/foo.txt/"), Ok(Path::new("")));
2149:     /// assert!(path.strip_prefix("test").is_err());
2150:     /// assert!(path.strip_prefix("/haha").is_err());
2153:     /// assert_eq!(path.strip_prefix(prefix), Ok(Path::new("haha/foo.txt")));
2155:     pub fn strip_prefix<P>(&self, base: P) -> Result<&Path, StripPrefixError>
2157:         P: AsRef<Path>,
2162:     fn _strip_prefix(&self, base: &Path) -> Result<&Path, StripPrefixError> {
2164:             .map(|c| c.as_path())
2170:     /// Only considers whole path components to match.
2175:     /// use std::path::Path;
2177:     /// let path = Path::new("/etc/passwd");
2179:     /// assert!(path.starts_with("/etc"));
2180:     /// assert!(path.starts_with("/etc/"));
2181:     /// assert!(path.starts_with("/etc/passwd"));
2182:     /// assert!(path.starts_with("/etc/passwd/")); // extra slash is okay
2183:     /// assert!(path.starts_with("/etc/passwd///")); // multiple extra slashes are okay
2185:     /// assert!(!path.starts_with("/e"));
2186:     /// assert!(!path.starts_with("/etc/passwd.txt"));
2188:     /// assert!(!Path::new("/etc/foo.rs").starts_with("/etc/foo"));
2191:     pub fn starts_with<P: AsRef<Path>>(&self, base: P) -> bool {
2195:     fn _starts_with(&self, base: &Path) -> bool {
2201:     /// Only considers whole path components to match.
2206:     /// use std::path::Path;
2208:     /// let path = Path::new("/etc/resolv.conf");
2210:     /// assert!(path.ends_with("resolv.conf"));
2211:     /// assert!(path.ends_with("etc/resolv.conf"));
2212:     /// assert!(path.ends_with("/etc/resolv.conf"));
2214:     /// assert!(!path.ends_with("/resolv.conf"));
2215:     /// assert!(!path.ends_with("conf")); // use .extension() instead
2218:     pub fn ends_with<P: AsRef<Path>>(&self, child: P) -> bool {
2222:     fn _ends_with(&self, child: &Path) -> bool {
2228:     /// [`self.file_name`]: Path::file_name
2240:     /// use std::path::Path;
2242:     /// assert_eq!("foo", Path::new("foo.rs").file_stem().unwrap());
2243:     /// assert_eq!("foo.tar", Path::new("foo.tar.gz").file_stem().unwrap());
2247:     /// This method is similar to [`Path::file_prefix`], which extracts the portion of the file name
2250:     /// [`Path::file_prefix`]: Path::file_prefix
2267:     /// [`self.file_name`]: Path::file_name
2272:     /// # #![feature(path_file_prefix)]
2273:     /// use std::path::Path;
2275:     /// assert_eq!("foo", Path::new("foo.rs").file_prefix().unwrap());
2276:     /// assert_eq!("foo", Path::new("foo.tar.gz").file_prefix().unwrap());
2280:     /// This method is similar to [`Path::file_stem`], which extracts the portion of the file name
2283:     /// [`Path::file_stem`]: Path::file_stem
2300:     /// [`self.file_name`]: Path::file_name
2305:     /// use std::path::Path;
2307:     /// assert_eq!("rs", Path::new("foo.rs").extension().unwrap());
2308:     /// assert_eq!("gz", Path::new("foo.tar.gz").extension().unwrap());
2315:     /// Creates an owned [`PathBuf`] with `path` adjoined to `self`.
2317:     /// See [`PathBuf::push`] for more details on what it means to adjoin a path.
2322:     /// use std::path::{Path, PathBuf};
2324:     /// assert_eq!(Path::new("/etc").join("passwd"), PathBuf::from("/etc/passwd"));
2327:     pub fn join<P: AsRef<Path>>(&self, path: P) -> PathBuf {
2328:         self._join(path.as_ref())
2331:     fn _join(&self, path: &Path) -> PathBuf {
2332:         let mut buf = self.to_path_buf();
2333:         buf.push(path);
2344:     /// use std::path::{Path, PathBuf};
2346:     /// let path = Path::new("/tmp/foo.txt");
2347:     /// assert_eq!(path.with_file_name("bar.txt"), PathBuf::from("/tmp/bar.txt"));
2349:     /// let path = Path::new("/tmp");
2350:     /// assert_eq!(path.with_file_name("var"), PathBuf::from("/var"));
2358:         let mut buf = self.to_path_buf();
2370:     /// use std::path::{Path, PathBuf};
2372:     /// let path = Path::new("foo.rs");
2373:     /// assert_eq!(path.with_extension("txt"), PathBuf::from("foo.txt"));
2375:     /// let path = Path::new("foo.tar.gz");
2376:     /// assert_eq!(path.with_extension(""), PathBuf::from("foo.tar"));
2377:     /// assert_eq!(path.with_extension("xz"), PathBuf::from("foo.tar.xz"));
2378:     /// assert_eq!(path.with_extension("").with_extension("txt"), PathBuf::from("foo.txt"));
2385:         let mut buf = self.to_path_buf();
2390:     /// Produces an iterator over the [`Component`]s of the path.
2392:     /// When parsing the path, there is a small amount of normalization:
2398:     ///   beginning of the path. For example, `a/./b`, `a/b/`, `a/b/.` and
2411:     /// use std::path::{Path, Component};
2414:     /// let mut components = Path::new("/tmp/foo.txt").components();
2426:             path: self.as_u8_slice(),
2434:     /// Produces an iterator over the path's components viewed as [`OsStr`]
2437:     /// For more information about the particulars of how the path is separated
2440:     /// [`components`]: Path::components
2445:     /// use std::path::{self, Path};
2448:     /// let mut it = Path::new("/tmp/foo.txt").iter();
2449:     /// assert_eq!(it.next(), Some(OsStr::new(&path::MAIN_SEPARATOR.to_string())));
2462:     /// escapes the path please use [`Debug`] instead.
2469:     /// use std::path::Path;
2471:     /// let path = Path::new("/tmp/foo.rs");
2473:     /// println!("{}", path.display());
2475:     #[must_use = "this does not display the path, \
2479:         Display { path: self }
2492:     /// use std::path::Path;
2494:     /// let path = Path::new("/Minas/tirith");
2495:     /// let metadata = path.metadata().expect("metadata call failed");
2511:     /// use std::path::Path;
2513:     /// let path = Path::new("/Minas/tirith");
2514:     /// let metadata = path.symlink_metadata().expect("symlink_metadata call failed");
2523:     /// Returns the canonical, absolute form of the path with all intermediate
2531:     /// use std::path::{Path, PathBuf};
2533:     /// let path = Path::new("/foo/test/../test/bar.rs");
2534:     /// assert_eq!(path.canonicalize().unwrap(), PathBuf::from("/foo/test/bar.rs"));
2549:     /// use std::path::Path;
2551:     /// let path = Path::new("/laputa/sky_castle.rs");
2552:     /// let path_link = path.read_link().expect("read_link call failed");
2570:     /// use std::path::Path;
2572:     /// let path = Path::new("/laputa");
2573:     /// for entry in path.read_dir().expect("read_dir call failed") {
2575:     ///         println!("{:?}", entry.path());
2585:     /// Returns `true` if the path points at an existing entity.
2599:     /// use std::path::Path;
2600:     /// assert!(!Path::new("does_not_exist.txt").exists());
2606:     /// check errors, call [`Path::try_exists`].
2616:     /// Returns `Ok(true)` if the path points at an existing entity.
2622:     /// unrelated to the path not existing. (E.g. it will return `Err(_)` in case of permission
2632:     /// use std::path::Path;
2633:     /// assert!(!Path::new("does_not_exist.txt").try_exists().expect("Can't check existence of file does_not_exist.txt"))...(1 bytes skipped)...
2634:     /// assert!(Path::new("/root/secret_file.txt").try_exists().is_err());
2644:     /// Returns `true` if the path exists on disk and is pointing at a regular file.
2655:     /// use std::path::Path;
2656:     /// assert_eq!(Path::new("./is_a_directory/").is_file(), false);
2657:     /// assert_eq!(Path::new("a_file.txt").is_file(), true);
2677:     /// Returns `true` if the path exists on disk and is pointing at a directory.
2688:     /// use std::path::Path;
2689:     /// assert_eq!(Path::new("./is_a_directory/").is_dir(), true);
2690:     /// assert_eq!(Path::new("a_file.txt").is_dir(), false);
2704:     /// Returns `true` if the path exists on disk and is pointing at a symbolic link.
2716:     /// use std::path::Path;
2719:     /// let link_path = Path::new("link");
2720:     /// symlink("/origin_does_not_exist/", link_path).unwrap();
2721:     /// assert_eq!(link_path.is_symlink(), true);
2722:     /// assert_eq!(link_path.exists(), false);
2736:     /// Converts a [`Box<Path>`](Box) into a [`PathBuf`] without copying or
2761: /// A [`Path`] might contain non-Unicode data. This `struct` implements the
2763: /// [`display`](Path::display) method on [`Path`]. This may perform lossy
2765: /// which escapes the path please use [`Debug`] instead.
2770: /// use std::path::Path;
2772: /// let path = Path::new("/tmp/foo.rs");
2774: /// println!("{}", path.display());
2785:         fmt::Debug::fmt(&self.path, f)
2791:         self.path.inner.display(f)
2797:     fn eq(&self, other: &Path) -> bool {
2857:     fn partial_cmp(&self, other: &Path) -> Option<cmp::Ordering> {
2864:     fn cmp(&self, other: &Path) -> cmp::Ordering {
2871:     fn as_ref(&self) -> &Path {
2876: impl AsRef<Path> for OsStr {
2878:     fn as_ref(&self) -> &Path {
2879:         Path::new(self)
2883: impl AsRef<Path> for Cow<'_, OsStr> {
2885:     fn as_ref(&self) -> &Path {
2886:         Path::new(self)
2890: impl AsRef<Path> for OsString {
2892:     fn as_ref(&self) -> &Path {
2893:         Path::new(self)
2897: impl AsRef<Path> for str {
2899:     fn as_ref(&self) -> &Path {
2900:         Path::new(self)
2904: impl AsRef<Path> for String {
2906:     fn as_ref(&self) -> &Path {
2907:         Path::new(self)
2913:     fn as_ref(&self) -> &Path {
2941:                 <Path as PartialEq>::eq(self, other)
2948:                 <Path as PartialEq>::eq(self, other)
2955:                 <Path as PartialOrd>::partial_cmp(self, other)
2962:                 <Path as PartialOrd>::partial_cmp(self, other)
2968: impl_cmp!(PathBuf, Path);
2969: impl_cmp!(PathBuf, &'a Path);
2970: impl_cmp!(Cow<'a, Path>, Path);
2971: impl_cmp!(Cow<'a, Path>, &'b Path);
2972: impl_cmp!(Cow<'a, Path>, PathBuf);
2979:                 <Path as PartialEq>::eq(self, other.as_ref())
2986:                 <Path as PartialEq>::eq(self.as_ref(), other)
2993:                 <Path as PartialOrd>::partial_cmp(self, other.as_ref())
3000:                 <Path as PartialOrd>::partial_cmp(self.as_ref(), other)
3010: impl_cmp_os_str!(Path, OsStr);
3011: impl_cmp_os_str!(Path, &'a OsStr);
3012: impl_cmp_os_str!(Path, Cow<'a, OsStr>);
3013: impl_cmp_os_str!(Path, OsString);
3014: impl_cmp_os_str!(&'a Path, OsStr);
3015: impl_cmp_os_str!(&'a Path, Cow<'b, OsStr>);
3016: impl_cmp_os_str!(&'a Path, OsString);
3017: impl_cmp_os_str!(Cow<'a, Path>, OsStr);
3018: impl_cmp_os_str!(Cow<'a, Path>, &'b OsStr);
3019: impl_cmp_os_str!(Cow<'a, Path>, OsString);
3035: /// Makes the path absolute without accessing the filesystem.
3037: /// If the path is relative, the current directory is used as the base directory.
3040: /// resolve symlinks and may succeed even if the path does not exist.
3042: /// If the `path` is empty or getting the
3051: /// #![feature(absolute_path)]
3054: ///   use std::path::{self, Path};
3057: ///   let absolute = path::absolute("foo/./bar")?;
3061: ///   let absolute = path::absolute("/foo//test/.././bar.rs")?;
3062: ///   assert_eq!(absolute, Path::new("/foo/test/../bar.rs"));
3069: /// The path is resolved using [POSIX semantics][posix-semantics] except that
3076: /// #![feature(absolute_path)]
3079: ///   use std::path::{self, Path};
3082: ///   let absolute = path::absolute("foo/./bar")?;
3086: ///   let absolute = path::absolute(r"C:\foo//test\..\./bar.rs")?;
3088: ///   assert_eq!(absolute, Path::new(r"C:\foo\bar.rs"));
3095: /// For verbatim paths this will simply return the path as given. For other
3096: /// paths this is currently equivalent to calling [`GetFullPathNameW`][windows-path]
3100: /// [windows-path]: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfullpathnamew
3102: pub fn absolute<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
3103:     _absolute(path)
3106: pub(crate) fn _absolute<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
3107:     let path = path.as_ref();
3108:     if path.as_os_str().is_empty() {
3109:         Err(io::const_io_error!(io::ErrorKind::InvalidInput, "cannot make an empty path absolute",))
3111:         sys::path::absolute(path)
21: //! and [`str`]), for working with paths abstractly. These types are thin wrappers
25: //! Paths can be parsed into [`Component`]s by iterating over the structure
29: //! [`PathBuf`]; note that the paths may differ syntactically by the
42: //! new owned paths.
63: //! To build or modify paths, use [`PathBuf`]:
82: //! [`push`]: PathBuf::push
975:         // compare back to front since absolute paths often share long prefixes
1075: /// [`push`]: PathBuf::push
1076: /// [`set_extension`]: PathBuf::set_extension
1083: /// You can use [`push`] to build up a `PathBuf` from
1117: #[cfg_attr(not(test), rustc_diagnostic_item = "PathBuf")]
1119: // `PathBuf::as_mut_vec` current implementation relies
1120: // on `PathBuf` being layout-compatible with `Vec<u8>`.
1121: // When attribute privacy is implemented, `PathBuf` should be annotated as `#[repr(transparent)]`.
1122: // Anyway, `PathBuf` representation and layout are considered implementation detail, are
1131:         unsafe { &mut *(self as *mut PathBuf as *mut Vec<u8>) }
1134:     /// Allocates an empty `PathBuf`.
1145:     pub fn new() -> PathBuf {
1146:         PathBuf { inner: OsString::new() }
1149:     /// Creates a new `PathBuf` with a given capacity used to create the
1169:     pub fn with_capacity(capacity: usize) -> PathBuf {
1170:         PathBuf { inner: OsString::with_capacity(capacity) }
1180:     /// let p = PathBuf::from("/test");
1246:         // verbatim paths need . and .. removed
1311:     /// let mut p = PathBuf::from("/spirited/away.rs");
1338:     /// [`pop`]: PathBuf::pop
1345:     /// let mut buf = PathBuf::from("/");
1348:     /// assert!(buf == PathBuf::from("/bar"));
1351:     /// assert!(buf == PathBuf::from("/baz.txt"));
1381:     /// let mut p = PathBuf::from("/feel/the");
1416:     /// Consumes the `PathBuf`, yielding its internal [`OsString`] storage.
1423:     /// let p = PathBuf::from("/the/head");
1510:         PathBuf { inner: self.inner.clone() }
1572:     /// Converts a borrowed [`OsStr`] to a [`PathBuf`].
1574:     /// Allocates a [`PathBuf`] and copies the data into it.
1576:     fn from(s: &T) -> PathBuf {
1577:         PathBuf::from(s.as_ref().to_os_string())
1582:     /// Converts an [`OsString`] into a [`PathBuf`]
1586:     fn from(s: OsString) -> PathBuf {
1587:         PathBuf { inner: s }
1591: impl From<PathBuf> for OsString {
1592:     /// Converts a [`PathBuf`] into an [`OsString`]
1602:     /// Converts a [`String`] into a [`PathBuf`]
1606:     fn from(s: String) -> PathBuf {
1607:         PathBuf::from(OsString::from(s))
1616:         Ok(PathBuf::from(s))
1621:     fn from_iter<I: IntoIterator<Item = P>>(iter: I) -> PathBuf {
1622:         let mut buf = PathBuf::new();
1663:         PathBuf::new()
1680:     /// instance of [`PathBuf`].
1691:     /// [`PathBuf`].
1749:     type Owned = PathBuf;
1751:     fn to_owned(&self) -> PathBuf {
1755:     fn clone_into(&self, target: &mut PathBuf) {
1762:     fn eq(&self, other: &PathBuf) -> bool {
1777:     fn partial_cmp(&self, other: &PathBuf) -> Option<cmp::Ordering> {
1784:     fn cmp(&self, other: &PathBuf) -> cmp::Ordering {
1805: /// see [`PathBuf`].
1965:         PathBuf::from(self.inner.to_os_string())
2152:     /// let prefix = PathBuf::from("/test/");
2337:     /// Creates an owned [`PathBuf`] like `self` but with the given file name.
2339:     /// See [`PathBuf::set_file_name`] for more details.
2353:     pub fn with_file_name<S: AsRef<OsStr>>(&self, file_name: S) -> PathBuf {
2357:     fn _with_file_name(&self, file_name: &OsStr) -> PathBuf {
2363:     /// Creates an owned [`PathBuf`] like `self` but with the given extension.
2365:     /// See [`PathBuf::set_extension`] for more details.
2380:     pub fn with_extension<S: AsRef<OsStr>>(&self, extension: S) -> PathBuf {
2384:     fn _with_extension(&self, extension: &OsStr) -> PathBuf {
2459:     /// Returns an object that implements [`Display`] for safely printing paths
2538:     pub fn canonicalize(&self) -> io::Result<PathBuf> {
2556:     pub fn read_link(&self) -> io::Result<PathBuf> {
2742:         PathBuf { inner: OsString::from(inner) }
2759: /// Helper struct for safely printing paths with [`format!`] and `{}`.
3006: impl_cmp_os_str!(PathBuf, OsStr);
3007: impl_cmp_os_str!(PathBuf, &'a OsStr);
3008: impl_cmp_os_str!(PathBuf, Cow<'a, OsStr>);
3009: impl_cmp_os_str!(PathBuf, OsString);
3048: /// ## Posix paths
3073: /// ## Windows paths
github.com/apache/servicecomb-service-center:datasource/etcd/path/key_generator.go: [ master, ]
18: package path
github.com/apache/incubator-teaclave:third_party/rust-sgx-sdk/sgx_tstd/src/path.rs: [ master, ]
392:     path: &'a [u8],
1202: impl ToOwned for Path {
1262: pub struct Path {
1277: impl Path {
1730: impl AsRef<OsStr> for Path {
1736: impl fmt::Debug for Path {
1749:     path: &'a Path,
1764: impl cmp::PartialEq for Path {
1770: impl Hash for Path {
1778: impl cmp::Eq for Path {}
1780: impl cmp::PartialOrd for Path {
1786: impl cmp::Ord for Path {
1792: impl AsRef<Path> for Path {
1844: impl<'a> IntoIterator for &'a Path {
475:     pub fn as_path(&self) -> &'a Path {
602:     pub fn as_path(&self) -> &'a Path {
823:     pub fn as_path(&self) -> &Path {
968:     pub fn into_boxed_path(self) -> Box<Path> {
797: pub struct PathBuf {
801: impl PathBuf {
1030: impl From<Box<Path>> for PathBuf {
1056: impl<T: ?Sized + AsRef<OsStr>> From<&T> for PathBuf {
1062: impl From<OsString> for PathBuf {
1081: impl From<String> for PathBuf {
1090: impl FromStr for PathBuf {
1098: impl<P: AsRef<Path>> iter::FromIterator<P> for PathBuf {
1106: impl<P: AsRef<Path>> iter::Extend<P> for PathBuf {
1112: impl fmt::Debug for PathBuf {
1118: impl ops::Deref for PathBuf {
1126: impl Borrow<Path> for PathBuf {
1132: impl Default for PathBuf {
1159: impl<'a> From<Cow<'a, Path>> for PathBuf {
1212: impl cmp::PartialEq for PathBuf {
1218: impl Hash for PathBuf {
1224: impl cmp::Eq for PathBuf {}
1226: impl cmp::PartialOrd for PathBuf {
1232: impl cmp::Ord for PathBuf {
1238: impl AsRef<OsStr> for PathBuf {
1829: impl AsRef<Path> for PathBuf {
1836: impl<'a> IntoIterator for &'a PathBuf {
1333:     pub fn to_path_buf(&self) -> PathBuf {
1723:     pub fn into_path_buf(self: Box<Path>) -> PathBuf {
18: //! Cross-platform path manipulation.
20: //! This module provides two types, [`PathBuf`] and [`Path`] (akin to [`String`]
23: //! on strings according to the local platform's path syntax.
26: //! returned by the [`components`] method on [`Path`]. [`Component`]s roughly
27: //! correspond to the substrings between path separators (`/` or `\`). You can
28: //! reconstruct an equivalent path from components with the [`push`] method on
39: use crate::sys::path::{is_sep_byte, is_verbatim_sep, parse_prefix, MAIN_SEP_STR};
65: /// Windows path prefixes, e.g., `C:` or `\\server\share`.
67: /// Windows uses a variety of path prefix styles, including references to drive
69: /// others. In addition, some path prefixes are "verbatim" (i.e., prefixed with
152: /// Determines whether the character is one of the permitted path
159: /// The primary separator of path components for the current platform.
162: pub const MAIN_SEPARATOR: char = crate::sys::path::MAIN_SEP;
210:     let path = if let Some(p) = prefix { &s[p.len()..] } else { s };
211:     !path.is_empty() && is_sep_byte(path[0])
242: /// front and back of the path each keep track of what parts of the path have
245: /// Going front to back, a path is made up of a prefix, a starting
255: /// A structure wrapping a Windows path prefix as well as its unparsed string
319: /// A single component of a path.
321: /// A `Component` roughly corresponds to a substring between path separators
325: /// created by the [`components`][`Path::components`] method on [`Path`].
330:     /// A Windows path prefix, e.g., `C:` or `\\server\share`.
342:     /// It represents a separator that designates that a path starts from root.
367:             Component::Normal(path) => path,
378: impl AsRef<Path> for Component<'_> {
379:     fn as_ref(&self) -> &Path {
384: /// An iterator over the [`Component`]s of a [`Path`].
386: /// This `struct` is created by the [`components`] method on [`Path`].
391:     // The path left to parse components from
397:     // true if path *physically* has a root separator; for most Windows
408: /// An iterator over the [`Component`]s of a [`Path`], as [`OsStr`] slices.
410: /// This `struct` is created by the [`iter`] method on [`Path`].
414: /// [`iter`]: struct.Path.html#method.iter
416: /// [`Path`]: struct.Path.html
424:         struct DebugHelper<'a>(&'a Path);
432:         f.debug_tuple("Components").field(&DebugHelper(self.as_path())).finish()
454:     // Given the iteration so far, how much of the pre-State::Body path is left?
473:     /// Extracts a slice corresponding to the portion of the path remaining for iteration.
483:         unsafe { Path::from_u8_slice(comps.path) }
486:     /// Is the *original* path rooted?
499:     /// Should the normalized path include a leading . ?
504:         let mut iter = self.path[self.prefix_len()..].iter();
512:     // parse a given byte sequence into the corresponding path component
517:             // the beginning of a path, which is treated
529:         let (extra, comp) = match self.path.iter().position(|b| self.is_sep_byte(*b)) {
530:             None => (0, self.path),
531:             Some(i) => (1, &self.path[..i]),
541:         let (extra, comp) = match self.path[start..].iter().rposition(|b| self.is_sep_byte(*b)) {
542:             None => (0, &self.path[start..]),
543:             Some(i) => (1, &self.path[start + i + 1..]),
550:         while !self.path.is_empty() {
555:                 self.path = &self.path[size..];
562:         while self.path.len() > self.len_before_body() {
567:                 self.path = &self.path[..self.path.len() - size];
573: impl AsRef<Path> for Components<'_> {
574:     fn as_ref(&self) -> &Path {
575:         self.as_path()
581:         self.as_path().as_os_str()
587:         struct DebugHelper<'a>(&'a Path);
595:         f.debug_tuple("Iter").field(&DebugHelper(self.as_path())).finish()
600:     /// Extracts a slice corresponding to the portion of the path remaining for iteration.
603:         self.inner.as_path()
607: impl AsRef<Path> for Iter<'_> {
608:     fn as_ref(&self) -> &Path {
609:         self.as_path()
615:         self.as_path().as_os_str()
643:                     debug_assert!(self.prefix_len() <= self.path.len());
644:                     let raw = &self.path[..self.prefix_len()];
645:                     self.path = &self.path[self.prefix_len()..];
657:                         debug_assert!(!self.path.is_empty());
658:                         self.path = &self.path[1..];
665:                         debug_assert!(!self.path.is_empty());
666:                         self.path = &self.path[1..];
670:                 State::Body if !self.path.is_empty() => {
672:                     self.path = &self.path[size..];
691:                 State::Body if self.path.len() > self.len_before_body() => {
693:                     self.path = &self.path[..self.path.len() - size];
704:                         self.path = &self.path[..self.path.len() - 1];
711:                         self.path = &self.path[..self.path.len() - 1];
718:                         raw: unsafe { u8_slice_as_os_str(self.path) },
755: /// An iterator over [`Path`] and its ancestors.
757: /// This `struct` is created by the [`ancestors`] method on [`Path`].
762:     next: Option<&'a Path>,
766:     type Item = &'a Path;
770:         self.next = next.and_then(Path::parent);
781: /// An owned, mutable path (akin to [`String`]).
784: /// the path in place. It also implements [`Deref`] to [`Path`], meaning that
785: /// all methods on [`Path`] slices are available on `PathBuf` values as well.
788: /// [`Path`]: struct.Path.html
819:     /// Coerces to a [`Path`] slice.
821:     /// [`Path`]: struct.Path.html
827:     /// Extends `self` with `path`.
829:     /// If `path` is absolute, it replaces the current path.
833:     /// * if `path` has a root but no prefix (e.g., `\windows`), it
835:     /// * if `path` has a prefix but no root, it replaces `self`.
837:     pub fn push<P: AsRef<Path>>(&mut self, path: P) {
838:         self._push(path.as_ref())
841:     fn _push(&mut self, path: &Path) {
849:                 && comps.prefix_len() == comps.path.len()
856:         // absolute `path` replaces `self`
857:         if path.is_absolute() || path.prefix().is_some() {
860:         // `path` has a root but no prefix, e.g., `\windows` (Windows only)
861:         } else if path.has_root() {
865:         // `path` is a pure relative path
870:         self.inner.push(path);
898:     /// `file_name`. The new path will be a sibling of the original path.
964:     /// Converts this `PathBuf` into a [boxed][`Box`] [`Path`].
967:     /// [`Path`]: struct.Path.html
969:         let rw = Box::into_raw(self.inner.into_boxed_os_str()) as *mut Path;
1022: impl From<&Path> for Box<Path> {
1023:     fn from(path: &Path) -> Box<Path> {
1024:         let boxed: Box<OsStr> = path.inner.into();
1025:         let rw = Box::into_raw(boxed) as *mut Path;
1031:     /// Converts a `Box<Path>` into a `PathBuf`
1034:     fn from(boxed: Box<Path>) -> PathBuf {
1035:         boxed.into_path_buf()
1039: impl From<PathBuf> for Box<Path> {
1040:     /// Converts a `PathBuf` into a `Box<Path>`
1044:     fn from(p: PathBuf) -> Box<Path> {
1045:         p.into_boxed_path()
1049: impl Clone for Box<Path> {
1052:         self.to_path_buf().into_boxed_path()
1076:     fn from(path_buf: PathBuf) -> OsString {
1077:         path_buf.inner
1119:     type Target = Path;
1121:     fn deref(&self) -> &Path {
1122:         Path::new(&self.inner)
1127:     fn borrow(&self) -> &Path {
1138: impl<'a> From<&'a Path> for Cow<'a, Path> {
1140:     fn from(s: &'a Path) -> Cow<'a, Path> {
1145: impl<'a> From<PathBuf> for Cow<'a, Path> {
1147:     fn from(s: PathBuf) -> Cow<'a, Path> {
1152: impl<'a> From<&'a PathBuf> for Cow<'a, Path> {
1154:     fn from(p: &'a PathBuf) -> Cow<'a, Path> {
1155:         Cow::Borrowed(p.as_path())
1161:     fn from(p: Cow<'a, Path>) -> Self {
1166: impl From<PathBuf> for Arc<Path> {
1169:     fn from(s: PathBuf) -> Arc<Path> {
1171:         unsafe { Arc::from_raw(Arc::into_raw(arc) as *const Path) }
1175: impl From<&Path> for Arc<Path> {
1176:     /// Converts a `Path` into an `Arc` by copying the `Path` data into a new `Arc` buffer.
1178:     fn from(s: &Path) -> Arc<Path> {
1180:         unsafe { Arc::from_raw(Arc::into_raw(arc) as *const Path) }
1184: impl From<PathBuf> for Rc<Path> {
1187:     fn from(s: PathBuf) -> Rc<Path> {
1189:         unsafe { Rc::from_raw(Rc::into_raw(rc) as *const Path) }
1193: impl From<&Path> for Rc<Path> {
1194:     /// Converts a `Path` into an `Rc` by copying the `Path` data into a new `Rc` buffer.
1196:     fn from(s: &Path) -> Rc<Path> {
1198:         unsafe { Rc::from_raw(Rc::into_raw(rc) as *const Path) }
1205:         self.to_path_buf()
1220:         self.as_path().hash(h)
1244: /// A slice of a path (akin to [`str`]).
1246: /// This type supports a number of operations for inspecting a path, including
1247: /// breaking the path into its components (separated by `/` on Unix and by either
1248: /// `/` or `\` on Windows), extracting the file name, determining whether the path
1266: /// An error returned from [`Path::strip_prefix`][`strip_prefix`] if the prefix
1269: /// This `struct` is created by the [`strip_prefix`] method on [`Path`].
1272: /// [`strip_prefix`]: struct.Path.html#method.strip_prefix
1273: /// [`Path`]: struct.Path.html
1278:     // The following (private!) function allows construction of a path from a u8
1280:     unsafe fn from_u8_slice(s: &[u8]) -> &Path {
1281:         Path::new(u8_slice_as_os_str(s))
1288:     /// Directly wraps a string slice as a `Path` slice.
1292:     pub fn new<S: AsRef<OsStr> + ?Sized>(s: &S) -> &Path {
1293:         unsafe { &*(s.as_ref() as *const OsStr as *const Path) }
1304:     /// Yields a [`&str`] slice if the `Path` is valid unicode.
1316:     /// Converts a `Path` to a [`Cow<str>`].
1328:     /// Converts a `Path` to an owned [`PathBuf`].
1337:     /// Returns `true` if the `Path` is absolute, i.e., if it is independent of
1340:     /// * On Unix, a path is absolute if it starts with the root, so
1343:     /// * On Windows, a path is absolute if it has a prefix and starts with the
1351:     /// Returns `true` if the `Path` is relative, i.e., not absolute.
1363:     /// Returns `true` if the `Path` has a root.
1365:     /// * On Unix, a path has a root if it begins with `/`.
1367:     /// * On Windows, a path has a root if it:
1376:     /// Returns the `Path` without its final component, if there is one.
1378:     /// Returns [`None`] if the path terminates in a root or prefix.
1382:     pub fn parent(&self) -> Option<&Path> {
1387:                 Some(comps.as_path())
1393:     /// Produces an iterator over `Path` and its ancestors.
1395:     /// The iterator will yield the `Path` that is returned if the [`parent`] method is used zero
1405:     /// Returns the final component of the `Path`, if there is one.
1407:     /// If the path is a normal file, this is the file name. If it's the path of a directory, this
1410:     /// Returns [`None`] if the path terminates in `..`.
1421:     /// Returns a path that, when joined onto `base`, yields `self`.
1431:     pub fn strip_prefix<P>(&self, base: P) -> Result<&Path, StripPrefixError>
1433:         P: AsRef<Path>,
1438:     fn _strip_prefix(&self, base: &Path) -> Result<&Path, StripPrefixError> {
1440:             .map(|c| c.as_path())
1446:     /// Only considers whole path components to match.
1448:     pub fn starts_with<P: AsRef<Path>>(&self, base: P) -> bool {
1452:     fn _starts_with(&self, base: &Path) -> bool {
1458:     /// Only considers whole path components to match.
1460:     pub fn ends_with<P: AsRef<Path>>(&self, child: P) -> bool {
1464:     fn _ends_with(&self, child: &Path) -> bool {
1470:     /// [`self.file_name`]: struct.Path.html#method.file_name
1494:     /// [`self.file_name`]: struct.Path.html#method.file_name
1501:     /// Creates an owned [`PathBuf`] with `path` adjoined to `self`.
1503:     /// See [`PathBuf::push`] for more details on what it means to adjoin a path.
1508:     pub fn join<P: AsRef<Path>>(&self, path: P) -> PathBuf {
1509:         self._join(path.as_ref())
1512:     fn _join(&self, path: &Path) -> PathBuf {
1513:         let mut buf = self.to_path_buf();
1514:         buf.push(path);
1530:         let mut buf = self.to_path_buf();
1547:         let mut buf = self.to_path_buf();
1552:     /// Produces an iterator over the [`Component`]s of the path.
1554:     /// When parsing the path, there is a small amount of normalization:
1560:     ///   beginning of the path. For example, `a/./b`, `a/b/`, `a/b/.` and
1573:             path: self.as_u8_slice(),
1581:     /// Produces an iterator over the path's components viewed as [`OsStr`]
1584:     /// For more information about the particulars of how the path is separated
1600:         Display { path: self }
1628:     /// Returns the canonical, absolute form of the path with all intermediate
1665:     /// use std::path::Path;
1667:     /// let path = Path::new("/laputa");
1668:     /// for entry in path.read_dir().expect("read_dir call failed") {
1670:     ///         println!("{:?}", entry.path());
1679:     /// Returns `true` if the path points at an existing entity.
1692:     /// Returns `true` if the path exists on disk and is pointing at a regular file.
1705:     /// Returns `true` if the path exists on disk and is pointing at a directory.
1718:     /// Converts a [`Box<Path>`][`Box`] into a [`PathBuf`] without copying or
1744: /// A [`Path`] might contain non-Unicode data. This `struct` implements the
1746: /// [`display`][`Path::display`] method on [`Path`].
1754:         fmt::Debug::fmt(&self.path, f)
1760:         self.path.inner.display(f)
1765:     fn eq(&self, other: &Path) -> bool {
1781:     fn partial_cmp(&self, other: &Path) -> Option<cmp::Ordering> {
1787:     fn cmp(&self, other: &Path) -> cmp::Ordering {
1793:     fn as_ref(&self) -> &Path {
1798: impl AsRef<Path> for OsStr {
1799:     fn as_ref(&self) -> &Path {
1800:         Path::new(self)
1804: impl AsRef<Path> for Cow<'_, OsStr> {
1805:     fn as_ref(&self) -> &Path {
1806:         Path::new(self)
1810: impl AsRef<Path> for OsString {
1811:     fn as_ref(&self) -> &Path {
1812:         Path::new(self)
1816: impl AsRef<Path> for str {
1818:     fn as_ref(&self) -> &Path {
1819:         Path::new(self)
1823: impl AsRef<Path> for String {
1824:     fn as_ref(&self) -> &Path {
1825:         Path::new(self)
1831:     fn as_ref(&self) -> &Path {
1857:                 <Path as PartialEq>::eq(self, other)
1864:                 <Path as PartialEq>::eq(self, other)
1871:                 <Path as PartialOrd>::partial_cmp(self, other)
1878:                 <Path as PartialOrd>::partial_cmp(self, other)
1884: impl_cmp!(PathBuf, Path);
1885: impl_cmp!(PathBuf, &'a Path);
1886: impl_cmp!(Cow<'a, Path>, Path);
1887: impl_cmp!(Cow<'a, Path>, &'b Path);
1888: impl_cmp!(Cow<'a, Path>, PathBuf);
1895:                 <Path as PartialEq>::eq(self, other.as_ref())
1902:                 <Path as PartialEq>::eq(self.as_ref(), other)
1909:                 <Path as PartialOrd>::partial_cmp(self, other.as_ref())
1916:                 <Path as PartialOrd>::partial_cmp(self.as_ref(), other)
1926: impl_cmp_os_str!(Path, OsStr);
1927: impl_cmp_os_str!(Path, &'a OsStr);
1928: impl_cmp_os_str!(Path, Cow<'a, OsStr>);
1929: impl_cmp_os_str!(Path, OsString);
1930: impl_cmp_os_str!(&'a Path, OsStr);
1931: impl_cmp_os_str!(&'a Path, Cow<'b, OsStr>);
1932: impl_cmp_os_str!(&'a Path, OsString);
1933: impl_cmp_os_str!(Cow<'a, Path>, OsStr);
1934: impl_cmp_os_str!(Cow<'a, Path>, &'b OsStr);
1935: impl_cmp_os_str!(Cow<'a, Path>, OsString);
21: //! and [`str`]), for working with paths abstractly. These types are thin wrappers
25: //! Paths can be parsed into [`Component`]s by iterating over the structure
29: //! [`PathBuf`]; note that the paths may differ syntactically by the
789: /// [`push`]: struct.PathBuf.html#method.push
790: /// [`set_extension`]: struct.PathBuf.html#method.set_extension
803:         unsafe { &mut *(self as *mut PathBuf as *mut Vec<u8>) }
806:     /// Allocates an empty `PathBuf`.
808:     pub fn new() -> PathBuf {
809:         PathBuf { inner: OsString::new() }
812:     /// Creates a new `PathBuf` with a given capacity used to create the
815:     pub fn with_capacity(capacity: usize) -> PathBuf {
816:         PathBuf { inner: OsString::with_capacity(capacity) }
879:     /// [`self.parent`]: struct.PathBuf.html#method.parent
901:     /// [`self.file_name`]: struct.PathBuf.html#method.file_name
903:     /// [`pop`]: struct.PathBuf.html#method.pop
925:     /// [`self.file_name`]: struct.PathBuf.html#method.file_name
926:     /// [`self.extension`]: struct.PathBuf.html#method.extension
956:     /// Consumes the `PathBuf`, yielding its internal [`OsString`] storage.
1057:     fn from(s: &T) -> PathBuf {
1058:         PathBuf::from(s.as_ref().to_os_string())
1063:     /// Converts a `OsString` into a `PathBuf`
1067:     fn from(s: OsString) -> PathBuf {
1068:         PathBuf { inner: s }
1072: impl From<PathBuf> for OsString {
1073:     /// Converts a `PathBuf` into a `OsString`
1082:     /// Converts a `String` into a `PathBuf`
1085:     fn from(s: String) -> PathBuf {
1086:         PathBuf::from(OsString::from(s))
1094:         Ok(PathBuf::from(s))
1099:     fn from_iter<I: IntoIterator<Item = P>>(iter: I) -> PathBuf {
1100:         let mut buf = PathBuf::new();
1134:         PathBuf::new()
1167:     /// Converts a `PathBuf` into an `Arc` by moving the `PathBuf` data into a new `Arc` buffer.
1185:     /// Converts a `PathBuf` into an `Rc` by moving the `PathBuf` data into a new `Rc` buffer.
1203:     type Owned = PathBuf;
1204:     fn to_owned(&self) -> PathBuf {
1207:     fn clone_into(&self, target: &mut PathBuf) {
1213:     fn eq(&self, other: &PathBuf) -> bool {
1227:     fn partial_cmp(&self, other: &PathBuf) -> Option<cmp::Ordering> {
1233:     fn cmp(&self, other: &PathBuf) -> cmp::Ordering {
1253: /// see [`PathBuf`].
1257: /// [`PathBuf`]: struct.PathBuf.html
1330:     /// [`PathBuf`]: struct.PathBuf.html
1334:         PathBuf::from(self.inner.to_os_string())
1505:     /// [`PathBuf`]: struct.PathBuf.html
1506:     /// [`PathBuf::push`]: struct.PathBuf.html#method.push
1518:     /// Creates an owned [`PathBuf`] like `self` but with the given file name.
1520:     /// See [`PathBuf::set_file_name`] for more details.
1522:     /// [`PathBuf`]: struct.PathBuf.html
1523:     /// [`PathBuf::set_file_name`]: struct.PathBuf.html#method.set_file_name
1525:     pub fn with_file_name<S: AsRef<OsStr>>(&self, file_name: S) -> PathBuf {
1529:     fn _with_file_name(&self, file_name: &OsStr) -> PathBuf {
1535:     /// Creates an owned [`PathBuf`] like `self` but with the given extension.
1537:     /// See [`PathBuf::set_extension`] for more details.
1539:     /// [`PathBuf`]: struct.PathBuf.html
1540:     /// [`PathBuf::set_extension`]: struct.PathBuf.html#method.set_extension
1542:     pub fn with_extension<S: AsRef<OsStr>>(&self, extension: S) -> PathBuf {
1546:     fn _with_extension(&self, extension: &OsStr) -> PathBuf {
1594:     /// Returns an object that implements [`Display`] for safely printing paths
1636:     pub fn canonicalize(&self) -> io::Result<PathBuf> {
1647:     pub fn read_link(&self) -> io::Result<PathBuf> {
1722:     /// [`PathBuf`]: struct.PathBuf.html
1726:         PathBuf { inner: OsString::from(inner) }
1742: /// Helper struct for safely printing paths with [`format!`] and `{}`.
1922: impl_cmp_os_str!(PathBuf, OsStr);
1923: impl_cmp_os_str!(PathBuf, &'a OsStr);
1924: impl_cmp_os_str!(PathBuf, Cow<'a, OsStr>);
1925: impl_cmp_os_str!(PathBuf, OsString);
github.com/apache/flex-sdk:frameworks/projects/spark/src/spark/primitives/Path.as: [ master, ]
64: public class Path extends FilledElement
82:     public function Path()
1196: class PathSegmentsCollection
1214: public function PathSegmentsCollection(value:String)
1540: public function generateGraphicsPath(graphicsPath:GraphicsPath,
1742: public function PathSegment(_x:Number = 0, _y:Number = 0)
39:  *  The Path class is a filled graphic element that draws a series of path segments.
40:  *  In vector graphics, a path is a series of points connected by straight or curved line segments. 
41:  *  Together the lines form an image. In Flex, you use the Path class to define a complex vector shape 
44:  *  <p>Typically, the first element of a path definition is a Move segment to specify the starting pen 
51:  *  point of the line. You can use multiple Move segments in the path definition to 
54:  *  <p>The syntax used by the Path class to define the shape is the same as the SVG path syntax, 
94:      *  Dirty flag to indicate when path data has changed. 
105:      *  path segment information  
116:      *  commands to draw this Path.  
118:      *  The data commands expressed in a Path's <code>data</code> 
140:      *  A string containing a compact represention of the path segments. This is an alternate
144:      *  <p>The value is a space-delimited string describing each path segment. Each
198:      *      <td>Close path</td>
201:      *      <td>Closes off the path.</td>
245:      *  Fill rule for intersecting or overlapping path segments. 
322:      *  Returns the bounding box for the path including stroke, if the path is resized
406:      *  @return Returns the axis aligned bounding box of the path when
420:         // then the non-stroked path bounds for the give size can be
556:         // slow code-path Player execution for all graphics in that DisplayObject.
708:      *  if the path is resized to the specified size.
947:         // Resize transformed path with the iterative solution
962:         // the path size as the size changes the angles of the joints.
1193:  *  Path segments.
1452:  *  A Vector of the actual path segments. May be empty, but always non-null. 
1510:     // If path is empty, it's untransformed bounding box is (0,0), so we return transformed point (0,0)
1522:  *  array and draws each path egment based on its control points. 
1524:  *  Segments are drawn from the x and y position of the path. 
1526:  *  applied to the path. 
1529:  *  path segment should be drawn
1532:  *  path segment should be drawn
1535:  *  this path segment 
1538:  *  path segment
1550:     // the path will begin at the previous pen location
1712:  *  The PathSegment class is the base class for a segment of a path.
1794:  *  Draws this path segment. You can determine the current pen position by 
1817:  *  path segment.
24: import flash.display.GraphicsPath;
55:  *  which makes it easy to convert SVG paths to Flex paths.</p>
112:     private var segments:PathSegmentsCollection;
115:      *  A GraphicsPath object that contains the drawing 
123:     mx_internal var graphicsPath:GraphicsPath = new GraphicsPath(new Vector.<int>(), new Vector.<Number>());
218:         segments = new PathSegmentsCollection(value);
392:     private function tangentIsValid(prevSegment:PathSegment, curSegment:PathSegment,
418:         var pathBBox:Rectangle;
424:             pathBBox = new Rectangle(naturalBounds.x * sx,
429:                 pathBBox.offset(m.tx, m.ty);
433:             pathBBox = this.segments.getBoundingBox(width, height, m);
439:             return pathBBox;
441:         // Always add half the stroke weight, even for miter limit paths,
445:         pathBBox.inflate(strokeExtents.right, strokeExtents.bottom);
447:         var seg:Vector.<PathSegment> = segments.data;
453:             return pathBBox;
473:                 var prevSegment:PathSegment = start > 0 ? seg[start - 1] : null;
482:             var startSegment:PathSegment = seg[start];
519:             var endSegment:PathSegment = seg[end];
531:                     pathBBox);
538:         return pathBBox;
582:     private function addMiterLimitStrokeToBounds(segment0:PathSegment,
583:                                                  segment1:PathSegment,
584:                                                  segment2:PathSegment,
939:         // We have special handling for miter-limit stroked non-transformed paths,
1098:                 segments.generateGraphicsPath(graphicsPath, drawX, drawY, sx, sy);
1102:         g.drawPath(graphicsPath.commands, graphicsPath.data, winding);
1187: //  Internal Helper Class - PathSegmentsCollection
1194:  *  Provides methods for generating GraphicsPath and calculating bounds. 
1218:         _segments = new Vector.<PathSegment>();
1222:     var newSegments:Vector.<PathSegment> = new Vector.<PathSegment>();
1418:                 _segments = new Vector.<PathSegment>();
1449: private var _segments:Vector.<PathSegment>;
1454: public function get data():Vector.<PathSegment>
1499:     var prevSegment:PathSegment;
1500:     var pathBBox:Rectangle;
1505:         var segment:PathSegment = _segments[i];
1506:         pathBBox = segment.getBoundingBox(prevSegment, sx, sy, m, pathBBox);
1511:     if (!pathBBox)
1515:         pathBBox = new Rectangle(x, y);
1517:     return pathBBox;
1546:     graphicsPath.commands = null;
1547:     graphicsPath.data = null;
1552:     graphicsPath.moveTo(tx, ty);
1554:     var curSegment:PathSegment;
1555:     var prevSegment:PathSegment;
1561:         curSegment.draw(graphicsPath, tx, ty, sx, sy, prevSegment);
1702: //  Internal Helper Class - PathSegment 
1705: import flash.display.GraphicsPath;
1721: class PathSegment extends Object
1805: public function draw(graphicsPath:GraphicsPath, dx:Number,dy:Number,sx:Number,sy:Number,prev:PathSegment):void
1824: public function getBoundingBox(prev:PathSegment, sx:Number, sy:Number, m:Matrix, rect:Rectangle):Rectangle
1839: public function getTangent(prev:PathSegment, start:Boolean, sx:Number, sy:Number, m:Matrix, result:Point):void
1853: import flash.display.GraphicsPath;
1869: class LineSegment extends PathSegment
1911: override public function draw(graphicsPath:GraphicsPath, dx:Number,dy:Number,sx:Number,sy:Number,prev:PathSegment):void
1913:     graphicsPath.lineTo(dx + x*sx, dy + y*sy);
1924: override public function getBoundingBox(prev:PathSegment, sx:Number, sy:Number, m:Matrix, rect:Rectangle):Rectangle
1952: override public function getTangent(prev:PathSegment, start:Boolean, sx:Number, sy:Number, m:Matrix, result:Point):void
1967: import flash.display.GraphicsPath;
1981: class MoveSegment extends PathSegment
2024: override public function draw(graphicsPath:GraphicsPath, dx:Number,dy:Number,sx:Number,sy:Number,prev:PathSegment):void
2026:     graphicsPath.moveTo(dx+x*sx, dy+y*sy);
2036: import flash.display.GraphicsPath;
2061: class CubicBezierSegment extends PathSegment
2198:     override public function draw(graphicsPath:GraphicsPath, dx:Number, dy:Number, sx:Number, sy:Number, prev:PathSegment):void
2202:         graphicsPath.curveTo(dx + qPts.control1.x*sx, dy+qPts.control1.y*sy, dx+qPts.anchor1.x*sx, dy+qPts.anchor1.y*sy)...(1 bytes skipped)...
2203:         graphicsPath.curveTo(dx + qPts.control2.x*sx, dy+qPts.control2.y*sy, dx+qPts.anchor2.x*sx, dy+qPts.anchor2.y*sy)...(1 bytes skipped)...
2204:         graphicsPath.curveTo(dx + qPts.control3.x*sx, dy+qPts.control3.y*sy, dx+qPts.anchor3.x*sx, dy+qPts.anchor3.y*sy)...(1 bytes skipped)...
2205:         graphicsPath.curveTo(dx + qPts.control4.x*sx, dy+qPts.control4.y*sy, dx+qPts.anchor4.x*sx, dy+qPts.anchor4.y*sy)...(1 bytes skipped)...
2216:     override public function getBoundingBox(prev:PathSegment, sx:Number, sy:Number,
2252:     override public function getTangent(prev:PathSegment, start:Boolean, sx:Number, sy:Number, m:Matrix, result:Point):void
2318:     private function getQuadraticPoints(prev:PathSegment):QuadraticPoints
2411: import flash.display.GraphicsPath;
2431: class QuadraticBezierSegment extends PathSegment
2526:     override public function draw(graphicsPath:GraphicsPath, dx:Number,dy:Number,sx:Number,sy:Number,prev:PathSegment):void
2528:         graphicsPath.curveTo(dx+control1X*sx, dy+control1Y*sy, dx+x*sx, dy+y*sy);
2574:     override public function getTangent(prev:PathSegment, start:Boolean, sx:Number, sy:Number, m:Matrix, result:Point):void
2591:     override public function getBoundingBox(prev:PathSegment, sx:Number, sy:Number,
101:     private var graphicsPathChanged:Boolean = true;
220:         graphicsPathChanged = true;
246:      *  Possible values are <code>GraphicsPathWinding.EVEN_ODD</code> or <code>GraphicsPathWinding.NON_ZERO</code>.
250:      *  @see flash.display.GraphicsPathWinding 
262:             graphicsPathChanged = true;
1085:             graphicsPathChanged = true;
1092:         if (graphicsPathChanged)
1099:             graphicsPathChanged = false;
1139:         graphicsPathChanged = true;
github.com/GNOME/gimp:tools/gimppath2svg.py: [ mainline, ]
43: class Path:
114: path = Path()
30: <path id="%s" transform="translate (%d,%d)"
55:             path.name = namematch.group(1)
59:                path.gimppoints.append ([])
61:             path.gimppoints[-1].append (map (int, pointmatch.groups()))
71:       for path in self.gimppoints:
72:          if path:
73:             start = path[0]
75:             path = path[1:]
76:             while path:
77:                curve = path [0:3]
78:                path = path[3:]
115: path.readgimpfile (infile)
116: path.makesvg()
117: path.writesvgfile (outfile)
6: gimppath2svg.py -- Converts Gimp-Paths to a SVG-File.
23: Usage: gimppath2svg.py [infile [outfile]]
46:       self.svgpath = ""
89:             self.svgpath = self.svgpath + svg
92:       if self.svgpath:
97:                               self.svgpath)
chromium.googlesource.com/infra/third_party/virtualenv:src/virtualenv/util/path/_pathlib/via_os_path.py: [ master, ]
12: class Path(object):
13:     def __init__(self, path):
14:         if isinstance(path, Path):
15:             _path = path._path
17:             _path = ensure_text(path)
19:                 _path = _path.encode("utf-8")
20:         self._path = _path
23:         return ensure_str("Path({})".format(ensure_text(self._path)))
26:         return ensure_text(self._path)
29:         return ensure_str(self._path)
32:         if isinstance(other, Path):
33:             right = other._path
38:         return Path(os.path.join(self._path, right))
44:         return self._path == (other._path if isinstance(other, Path) else None)
50:         return hash(self._path)
53:         return os.path.exists(self._path)
57:         return Path(os.path.abspath(os.path.join(self._path, os.path.pardir)))
60:         return Path(os.path.realpath(self._path))
64:         return os.path.basename(self._path)
68:         return self._path.split(os.sep)
71:         return os.path.isfile(self._path)
74:         return os.path.isdir(self._path)
78:             os.makedirs(self._path)
87:         with open(self._path, "rb") as file_handler:
91:         with open(self._path, "wb") as file_handler:
98:         for p in os.listdir(self._path):
99:             yield Path(os.path.join(self._path, p))
103:         _, ext = os.path.splitext(self.name)
108:         base, _ = os.path.splitext(self.name)
113:         with open(self._path, mode) as file_handler:
121:             result.append(Path(os.sep.join(parts[0 : i + 1])))
125:         os.remove(self._path)
131:         return os.path.islink(self._path)
134:         if not self._path.startswith(other._path):
135:             raise ValueError("{} does not start with {}".format(self._path, other._path))
136:         return Path(os.sep.join(self.parts[len(other.parts) :]))
139:         return os.stat(self._path)
142:         os.chmod(self._path, mode)
145:         return Path(os.path.abspath(self._path))
148: __all__ = ("Path",)
android.googlesource.com/platform/external/python/parse_type:tasks/_vendor/path.py: [ master, ]
176: class Path(text_type):
1717: class path(Path):
294:     def abspath(self):
302:     def normpath(self):
306:     def realpath(self):
383:     def splitpath(self):
441:     def joinpath(cls, first, *others):
475:     def relpath(self, start='.'):
1141:         def pathconf(self, name):
482:     def relpathto(self, dest):
2: # SOURCE: https://pypi.python.org/pypi/path.py
27: path.py - An object representing a path to a file or directory.
29: https://github.com/jaraco/path.py
33:     from path import Path
34:     d = Path('/home/guido/bin')
113: __all__ = ['Path', 'CaseInsensitivePattern']
126:     __version__ = pkg_resources.require('path.py')[0].version
143:     Save results for the :meth:'path.using_module' classmethod.
178:     Represents a filesystem path.
181:     counterparts in :mod:`os.path`.
185:     such that they will be bound to the Path instance. For example,
186:     ``Path(src).copy(target)`` is equivalent to
189:     the Path instance.
192:     module = os.path
193:     """ The path module to use for path operations.
195:     .. seealso:: :mod:`os.path`
200:             raise TypeError("Invalid initial value for path: None")
221:     def _always_unicode(cls, path):
223:         Ensure the path as retrieved from a Python API, such as :func:`os.listdir`,
226:         if PY3 or isinstance(path, text_type):
227:             return path
228:         return path.decode(sys.getfilesystemencoding(), 'surrogateescape')
233:         return '%s(%s)' % (type(self).__name__, super(Path, self).__repr__())
235:     # Adding a Path and a string yields a Path.
238:             return self._next_class(super(Path, self).__add__(more))
251:         Join two path components, adding a separator character if
254:         .. seealso:: :func:`os.path.join`
265:         Join two path components, adding a separator character if
268:         .. seealso:: :func:`os.path.join`
285:         """ Return the current working directory as a path object.
292:     # --- Operations on Path strings.
295:         """ .. seealso:: :func:`os.path.abspath` """
299:         """ .. seealso:: :func:`os.path.normcase` """
303:         """ .. seealso:: :func:`os.path.normpath` """
307:         """ .. seealso:: :func:`os.path.realpath` """
311:         """ .. seealso:: :func:`os.path.expanduser` """
315:         """ .. seealso:: :func:`os.path.expandvars` """
319:         """ .. seealso:: :attr:`parent`, :func:`os.path.dirname` """
323:         """ .. seealso:: :attr:`name`, :func:`os.path.basename` """
340:         ``Path('/home/guido/python.tar.gz').name == 'python.tar.gz'``,
342:         ``Path('/home/guido/python.tar.gz').namebase == 'python.tar'``.
364:         """ This path's parent directory, as a new Path object.
367:         ``Path('/usr/local/lib/libpython.so').parent ==
368:         Path('/usr/local/lib')``
370:         .. seealso:: :meth:`dirname`, :func:`os.path.dirname`
375:         """ The name of this file or directory without the full path.
378:         ``Path('/usr/local/lib/libpython.so').name == 'libpython.so'``
380:         .. seealso:: :meth:`basename`, :func:`os.path.basename`
386:         .. seealso:: :attr:`parent`, :attr:`name`, :func:`os.path.split`
394:         Split the drive specifier from this path.  If there is
396:         is simply ``(Path(''), p)``.  This is always the case on Unix.
398:         .. seealso:: :func:`os.path.splitdrive`
406:         Split the filename extension from this path and return
410:         last path segment.  This has the property that if
413:         .. seealso:: :func:`os.path.splitext`
419:         """ p.stripext() -> Remove one file extension from the path.
421:         For example, ``Path('/home/guido/python.tar.gz').stripext()``
422:         returns ``Path('/home/guido/python.tar')``.
427:         """ .. seealso:: :func:`os.path.splitunc` """
434:         The UNC mount point for this path.
443:         Join first to zero or more :class:`Path` components, adding a separator
447:         .. seealso:: :func:`os.path.join`
454:         r""" Return a list of the path components in this path.
456:         The first item in the list will be a Path.  Its value will be
458:         directory of this path (for example, ``'/'`` or ``'C:\\'``).  The
461:         ``path.Path.joinpath(*result)`` will yield the original path.
476:         """ Return this path as a relative path,
483:         """ Return a relative path from `self` to `dest`.
485:         If there is no relative path from `self` to `dest`, for example if
528:         The elements of the list are Path objects.
546:         The elements of the list are Path objects.
559:         The elements of the list are Path objects.
572:         The iterator yields Path objects naming each child item of
713:             attribute, it is applied to the name and path prior to comparison.
717:             to :meth:`os.path.normcase`.
728:         """ Return a list of Path objects that match the pattern.
730:         `pattern` - a path relative to this directory, with wildcards.
732:         For example, ``Path('/users').glob('*/bin/*')`` returns a list
766:                >>> for chunk in Path("path.py").chunks(8192, mode='rb'):
902:         By default this overwrites any existing file at this path.
956:         """ Returns a hash object for the file at the current path.
987:     # N.B. On some platforms, the os.path functions may be implemented in C
992:         """ .. seealso:: :func:`os.path.isabs` """
996:         """ .. seealso:: :func:`os.path.exists` """
1000:         """ .. seealso:: :func:`os.path.isdir` """
1004:         """ .. seealso:: :func:`os.path.isfile` """
1008:         """ .. seealso:: :func:`os.path.islink` """
1012:         """ .. seealso:: :func:`os.path.ismount` """
1016:         """ .. seealso:: :func:`os.path.samefile` """
1018:             other = Path(other).realpath().normpath().normcase()
1023:         """ .. seealso:: :attr:`atime`, :func:`os.path.getatime` """
1030:         .. seealso:: :meth:`getatime`, :func:`os.path.getatime`
1034:         """ .. seealso:: :attr:`mtime`, :func:`os.path.getmtime` """
1041:         .. seealso:: :meth:`getmtime`, :func:`os.path.getmtime`
1045:         """ .. seealso:: :attr:`ctime`, :func:`os.path.getctime` """
1052:         .. seealso:: :meth:`getctime`, :func:`os.path.getctime`
1056:         """ .. seealso:: :attr:`size`, :func:`os.path.getsize` """
1063:         .. seealso:: :meth:`getsize`, :func:`os.path.getsize`
1068:             """ Return ``True`` if current user has access to this path.
1078:         """ Perform a ``stat()`` system call on this path.
1134:             """ Perform a ``statvfs()`` system call on this path.
1322:             """ Return the path to which this symbolic link points.
1324:             The result may be an absolute or a relative path.
1331:             """ Return the path to which this symbolic link points.
1333:             The result is always an absolute path.
1345:     # Path(name).copy(target) will invoke shutil.copy(name, target)
1432:             p = Path(filename)
1506:             dir = Path.special().user.config
1514:             dir = Path.special("My App").user.config.makedirs_p()
1531:     def __init__(self, path_class, *args, **kwargs):
1539:             path_class=path_class,
1549:         result wrapped in self.path_class
1553:         MultiPath = Multi.for_class(self.path_class)
1559:     A mix-in for a Path which may contain multiple Path separated by pathsep.
1562:     def for_class(cls, path_cls):
1563:         name = 'Multi' + path_cls.__name__
1566:         return type(name, (cls, path_cls), {})
1590: class tempdir(Path):
1598:             # do stuff with the Path object "d"
1608:         return Path
1707:         from path import Path, CaseInsensitivePattern as ci
1708:         Path('.').files(ci('*.py'))
1719:         msg = "path is deprecated. Use Path instead."
1721:         return Path.__new__(cls, *args, **kwargs)
1724: __all__ += ['path']
247:     # The / operator joins Paths.
249:         """ fp.__div__(rel) == fp / rel == fp.joinpath(rel)
261:     # The / operator joins Paths the other way around
296:         return self._next_class(self.module.abspath(self))
304:         return self._next_class(self.module.normpath(self))
308:         return self._next_class(self.module.realpath(self))
328:         :meth:`expanduser()`, and :meth:`normpath()` on it.
333:         return self.expandvars().expanduser().normpath()
384:         """ p.splitpath() -> Return ``(p.parent, p.name)``.
435:         This is empty for paths on local drives.
467:             loc, child = prev.splitpath()
487:         ``dest.abspath()``.
489:         origin = self.abspath()
490:         dest = self._next_class(dest).abspath()
500:         # Find the location where the two paths start to differ.
507:         # Now i is the point where the two paths diverge.
515:             relpath = os.curdir
517:             relpath = self.module.join(*segments)
518:         return self._next_class(relpath)
1019:             return self.realpath().normpath().normcase() == other
1140:     if hasattr(os, 'pathconf'):
1142:             """ .. seealso:: :func:`os.pathconf` """
1143:             return os.pathconf(self, name)
1303:         def link(self, newpath):
1304:             """ Create a hard link at `newpath`, pointing to this file.
1308:             os.link(self, newpath)
1309:             return self._next_class(newpath)
1341:                 return (self.parent / p).abspath()
1510:         the paths in a platform-friendly way.
1524:         def __init__(self, paths, scope):
1525:             self.paths = paths
1529:             return self.paths.get_dir(self.scope, class_)
1554:         return MultiPath.detect(value)
1570:         if os.pathsep not in input:
1575:         return iter(map(self._next_class, self.split(os.pathsep)))
1713:         return __import__('ntpath').normcase
480:         return cwd.relpathto(self)
github.com/google/go-cmp:cmp/path.go: [ master, ]
26: type Path []PathStep
34: type PathStep interface {
153: type pathStep struct {
174: 	pathStep
213: 	pathStep
258: 	pathStep
272: 	pathStep
282: 	pathStep
292: 	pathStep
337: type pointerPath struct {
17: // Path is a list of PathSteps describing the sequence of operations to get
19: // The first Path element is always an operation-less PathStep that exists
37: 	// Type is the resulting type after performing the path step.
40: 	// Values is the resulting values after performing the path step.
65: func (pa *Path) push(s PathStep) {
69: func (pa *Path) pop() {
73: // Last returns the last PathStep in the Path.
74: // If the path is empty, this returns a non-nil PathStep that reports a nil Type.
75: func (pa Path) Last() PathStep {
79: // Index returns the ith step in the Path and supports negative indexing.
80: // A negative index starts counting from the tail of the Path such that -1
83: func (pa Path) Index(i int) PathStep {
93: // String returns the simplified path to a node.
94: // The simplified path only contains struct field accesses.
99: func (pa Path) String() string {
109: // GoString returns the path to a specific node using Go syntax.
114: func (pa Path) GoString() string {
331: // Path for whether px was ever encountered in the Path history of x, and
336: // in O(1) instead of O(N) where N is len(Path).
28: // PathStep is a union-type for specific operations to traverse
57: 	_ PathStep = StructField{}
58: 	_ PathStep = SliceIndex{}
59: 	_ PathStep = MapIndex{}
60: 	_ PathStep = Indirect{}
61: 	_ PathStep = TypeAssertion{}
62: 	_ PathStep = Transform{}
82: // If index is invalid, this returns a non-nil PathStep that reports a nil Type.
88: 		return pathStep{}
118: 		var nextStep PathStep
158: func (ps pathStep) Type() reflect.Type             { return ps.typ }
159: func (ps pathStep) Values() (vx, vy reflect.Value) { return ps.vx, ps.vy }
160: func (ps pathStep) String() string {
310: // pointerPath represents a dual-stack of pointers encountered when
315: // The pointerPath uses a map to represent a stack; where descension into a
333: // equal if both px and py have a cycle resulting from the same PathStep.
344: func (p *pointerPath) Init() {
356: func (p pointerPath) Push(vx, vy reflect.Value) (equal, visited bool) {
371: func (p pointerPath) Pop(vx, vy reflect.Value) {
android.googlesource.com/platform/external/go-cmp:cmp/path.go: [ master, ] Duplicate result
android.googlesource.com/platform/tools/gpu:service/path/path_binary.go: [ master, ]
6: package path
76: 		o.Array = obj.(Path)
113: 	Package: "path",
116: 		{Declared: "Array", Type: &schema.Interface{Name: "Path"}},
163: 	Package: "path",
218: 	Package: "path",
284: 	Package: "path",
334: 	Package: "path",
383: 	Package: "path",
412: 		o.Struct = obj.(Path)
449: 	Package: "path",
452: 		{Declared: "Struct", Type: &schema.Interface{Name: "Path"}},
505: 	Package: "path",
554: 	Package: "path",
592: 		o.Map = obj.(Path)
633: 	Package: "path",
636: 		{Declared: "Map", Type: &schema.Interface{Name: "Path"}},
722: 	Package: "path",
780: 	Package: "path",
812: 		o.Array = obj.(Path)
857: 	Package: "path",
860: 		{Declared: "Array", Type: &schema.Interface{Name: "Path"}},
914: 	Package: "path",
963: 	Package: "path",
chromium.googlesource.com/arc/arc:third_party/chromium-ppapi/third_party/blink/web_tests/paint/invalidation/clip/clip-path-in-mask-layer.html: [ master, ]
5:     <path id="path" d="M0 0 L1 1 L0 1 Z"/>
8: <div style="width: 200px; height: 200px; background: blue; clip-path: url(#clip); will-change: transform"></div>
11:   path.setAttribute('d', 'M0 0 L1 0 L1 1 L0 1 Z');
4: 	<clipPath id="clip" clipPathUnits='objectBoundingBox'>
6: 	</clipPath>
github.com/yeoman/doctor:lib/rules/node-path.js: [ master, ]
3: const path = require('path');
14:   pathMismatch(npmRoot) {
29: function fixPath(filepath) {
48:   const nodePaths = (process.env.NODE_PATH || '').split(path.delimiter).map(fixPath);
7: exports.description = 'NODE_PATH matches the npm root';
11:     return message.get('node-path-npm-failure', {});
15:     let msgPath = 'node-path-path-mismatch';
22:       path: process.env.NODE_PATH,
30:   let fixedPath = path.resolve(path.normalize(filepath.trim()));
44:   if (process.env.NODE_PATH === undefined) {
18:       msgPath += '-windows';
21:     return message.get(msgPath, {
33:     fixedPath = fs.realpathSync(fixedPath);
40:   return fixedPath;
52:     const npmRoot = fixPath(stdout);
55:       return errors.pathMismatch(npmRoot);
54:     if (nodePaths.indexOf(npmRoot) < 0) {
github.com/apache/flex-whiteboard:cframpton/adobe.next/frameworks/projects/spark/src/spark/primitives/Path.as: [ trunk, ] Duplicate result
github.com/apache/flex-whiteboard:espenskogen/frameworks/projects/spark/src/spark/primitives/Path.as: [ trunk, ] Duplicate result
android.googlesource.com/platform/packages/modules/common:proto/classpaths.proto: [ master, ]
31:   string path = 1;
19: enum Classpath {
21:   BOOTCLASSPATH = 1;
22:   SYSTEMSERVERCLASSPATH = 2;
23:   DEX2OATBOOTCLASSPATH = 3;
35:   Classpath classpath = 2;
51: message ExportedClasspathsJars {
30:   // Path on the filesystem for the jar.
27: // Individual entry in a classpath variable.
33:   // Environ classpath variable this jar belongs to.
34:   // Must be set to a known classpath.
37:   // Minimum API level required for the jar to be included on the classpath.
39:   // attribute, the jar will not be included in the classpath.
45:   // attribute, the jar will not be included in the classpath.
53:   // All jars that are exported as part of any classpath environ variable
android.googlesource.com/platform/external/go-etree:path.go: [ master, ]
84: type Path struct {
89: type ErrPath string
98: func CompilePath(path string) (Path, error) {
111: func MustCompilePath(path string) Path {
148: type pather struct {
211: func (c *compiler) parsePath(path string) []segment {
235: func splitPath(path string) []string {
163: func newPather() *pather {
13: A Path is a string that represents a search path through an etree starting
17: A Path consists of a series of slash-separated "selectors", each of which may
22: Although etree Path strings are structurally and behaviorally similar to XPath
31:     /               Select the root element when used at the start of a path.
54: Below are some examples of etree path strings.
88: // ErrPath is returned by path functions when an invalid etree path is provided.
91: // Error returns the string describing a path error.
100: 	segments := comp.parsePath(path)
102: 		return Path{nil}, comp.err
104: 	return Path{segments}, nil
109: // occurs.  Use this function to create Paths when you know the path is
112: 	p, err := CompilePath(path)
119: // A segment is a portion of a path between "/" characters.
134: // path traversal.
140: // on a path filter in [brackets].
146: // a Path object.  It collects and deduplicates all elements matching
147: // the path query.
156: // A node represents an element and the remaining path segments that
172: // traverse follows the path from the element e, collecting
173: // and then returning all elements that match the path's selectors
175: func (p *pather) traverse(e *Element, path Path) []*Element {
176: 	for p.queue.add(node{e, path.segments}); p.queue.len() > 0; {
182: // eval evalutes the current path node by applying the remaining
183: // path's selector rules against the node's element.
203: // A compiler generates a compiled path from a path string.
208: // parsePath parses an XPath-like string describing a path
212: 	// If path ends with //, fix it
213: 	if strings.HasSuffix(path, "//") {
214: 		path += "*"
219: 	// Check for an absolute path
220: 	if strings.HasPrefix(path, "/") {
222: 		path = path[1:]
225: 	// Split path into segments
226: 	for _, s := range splitPath(path) {
239: 	for i := 0; i+1 <= len(path); i++ {
240: 		if path[i] == '\'' {
242: 		} else if path[i] == '/' && !inquote {
243: 			pieces = append(pieces, path[start:i])
247: 	return append(pieces, path[start:])
250: // parseSegment parses a path segment between / characters.
251: func (c *compiler) parseSegment(path string) segment {
252: 	pieces := strings.Split(path, "[")
260: 			c.err = ErrPath("path has invalid filter [brackets].")
268: // parseSelector parses a selector at the start of a path segment.
269: func (c *compiler) parseSelector(path string) selector {
270: 	switch path {
280: 		return newSelectChildrenByTag(path)
292: // parseFilter parses a path filter contained within [brackets].
293: func (c *compiler) parseFilter(path string) filter {
294: 	if len(path) == 0 {
295: 		c.err = ErrPath("path contains an empty filter expression.")
300: 	eqindex := strings.Index(path, "='")
302: 		rindex := nextIndex(path, "'", eqindex+2)
303: 		if rindex != len(path)-1 {
304: 			c.err = ErrPath("path has mismatched filter quotes.")
308: 		key := path[:eqindex]
309: 		value := path[eqindex+2 : rindex]
319: 			c.err = ErrPath("path has unknown function " + name)
328: 	case path[0] == '@':
329: 		return newFilterAttr(path[1:])
330: 	case strings.HasSuffix(path, "()"):
331: 		name := path[:len(path)-2]
335: 		c.err = ErrPath("path has unknown function " + name)
337: 	case isInteger(path):
338: 		pos, _ := strconv.Atoi(path)
346: 		return newFilterChild(path)
412: func newSelectChildrenByTag(path string) *selectChildrenByTag {
413: 	s, l := spaceDecompose(path)
14: from the document root or an arbitrary element. Paths are used with the
23: strings (https://www.w3.org/TR/1999/REC-xpath-19991116/), they have a more
26: The following selectors are supported by etree paths:
92: func (err ErrPath) Error() string {
96: // CompilePath creates an optimized version of an XPath-like string that
101: 	if comp.err != ErrPath("") {
107: // MustCompilePath creates an optimized version of an XPath-like string that
126: func (seg *segment) apply(e *Element, p *pather) {
136: 	apply(e *Element, p *pather)
142: 	apply(p *pather)
145: // A pather is helper object that traverses an element tree using
157: // should be applied against it by the pather.
164: 	return &pather{
184: func (p *pather) eval(n node) {
205: 	err ErrPath
228: 		if c.err != ErrPath("") {
258: 		fpath := pieces[i]
259: 		if fpath[len(fpath)-1] != ']' {
263: 		seg.filters = append(seg.filters, c.parseFilter(fpath[:len(fpath)-1]))
353: func (s *selectSelf) apply(e *Element, p *pather) {
360: func (s *selectRoot) apply(e *Element, p *pather) {
371: func (s *selectParent) apply(e *Element, p *pather) {
381: func (s *selectChildren) apply(e *Element, p *pather) {
393: func (s *selectDescendants) apply(e *Element, p *pather) {
417: func (s *selectChildrenByTag) apply(e *Element, p *pather) {
435: func (f *filterPos) apply(p *pather) {
459: func (f *filterAttr) apply(p *pather) {
482: func (f *filterAttrVal) apply(p *pather) {
504: func (f *filterFunc) apply(p *pather) {
524: func (f *filterFuncVal) apply(p *pather) {
544: func (f *filterChild) apply(p *pather) {
568: func (f *filterChildText) apply(p *pather) {
github.com/apache/ode-console:src/vendor/jquery.xpath.js: [ master, ]
2981: cXSAnyURI.prototype.path		= null;
6341: oObject.xpath	= function(oQuery, sExpression, fNSResolver) {
6307: function fXPath_evaluate(oQuery, sExpression, fNSResolver) {
1879: function cPathExpr() {
1885: function fPathExpr_parse (oLexer, oStaticContext) {
72: oException_messages["XPTY0018"]	= "The result of the last step in a path expression contains both nodes and atomic values";
73: oException_messages["XPTY0019"]	= "The result of a step (other than the last step) in a path expression contains an atomic value.";
1905: 					, "Expected path step expression"
1917: 					, "Expected path step expression"
2970: 	this.path		= sPath;
2988: 			+ (this.path ? this.path : '')
4951: 				if (oUri.path.charAt(0) != '/') {
4952: 			var aUriSegments		= oUri.path.split('/'),
4953: 				aBaseUriSegments	= oBaseUri.path.split('/');
4972: 						oUri.path	= aBaseUriSegments.join('/');
2:  * jQuery XPath plugin v0.2.5
3:  * https://github.com/ilinsky/jquery-xpath
7:  * Includes xpath.js - XPath 2.0 implementation in JavaScript
8:  * https://github.com/ilinsky/xpath.js
47: 	sNS_XPF	= "http://www.w3.org/2005/xpath-functions",
2967: function cXSAnyURI(sScheme, sAuthority, sPath, sQuery, sFragment) {
6079: 			fResolveUri	= oLXDOMAdapter_staticContext.getFunction('{' + "http://www.w3.org/2005/xpath-functions" + '}' + "resolve-uri"),
6302: oHTMLStaticContext.defaultFunctionNamespace	= "http://www.w3.org/2005/xpath-functions";
6342: 	return fXPath_evaluate(oQuery instanceof cQuery ? oQuery : new cQuery(oQuery), sExpression, fNSResolver);
6347: oObject.xpath	= function(sExpression, fNSResolver) {
6348: 	return fXPath_evaluate(this, sExpression, fNSResolver);
1569: 	return fPathExpr_parse(oLexer, oStaticContext);
1883: cPathExpr.prototype.items	= null;
1891: 	var oPathExpr	= new cPathExpr(),
1896: 		oPathExpr.items.push(new cFunctionCall(null, "root", sNS_XPF));
1898: 			oPathExpr.items.push(new cAxisStep("descendant-or-self", new cKindTest("node")));
1903: 			return oPathExpr.items[0];			if (sSlash == sDoubleSlash)
1909: 	oPathExpr.items.push(oExpr);
1913: 			oPathExpr.items.push(new cAxisStep("descendant-or-self", new cKindTest("node")));
1919: 				oPathExpr.items.push(oExpr);
1922: 	if (oPathExpr.items.length == 1)
1923: 		return oPathExpr.items[0];
1925: 		return oPathExpr;
1928: cPathExpr.prototype.evaluate	= function (oContext) {
github.com/sourcegraph/srclib-javascript:lib/define-path-info.js: [ master, ]
3: var path = require("path");
453:                 path: scope,
522:                 path: "",
62: function resolveScopeCountPath(scope) {
142: var pathVisitor = walk.make({
557: module.exports.mapLinesPathToScopePath = function(ternServer, defInfo) {
607: module.exports.getPath = function(node) {
47: function getFilePathName(fileName) {
19:  * @property {string} scope - scope path
28:  * @property {string} path - path to class
36:  * @return {string} path to given node in given file
100:  * required parent properties and adjusting path
102:  * @param {string} scope new scope (path)
316:             if (def && def.path) {
317:                 pathMap[formPathForScope(fileName, node.object)] = def.path;
318:                 newScope = def.path;
326:                 if (def && def.path) {
327:                     pathMap[formPathForScope(fileName, node.object)] = def.path;
328:                     newScope = def.path;
341:                     newScope = util.formPath(def.path, "fn", '+' + node.property.name);
344:                     newScope = util.formPath(def.path, "fn", '-' + node.property.name);
347:                     newScope = util.formPath(def.path, "fn", node.property.name);
350:                     newScope = util.formPath(classDefinitions[currentClass].path, "prop", node.property.name);
438:             // append /class/NAME to path being built
443:                 classDefinitions[currentClass].path = scope;
605:  * @returns {string} computed path to given node
39:     return util.formPath(fileName, data.start, data.end);
48:     fileName = util.normalizePath(fileName);
69:         return util.formPath(scope, scopeCountRes);
73: module.exports.pathMap = pathMap = {};
154:             var newScope = util.formPath(scopeInfo.scope, "obj_def_prop");
158:                 newScope = util.formPath(newScope, obj.name);
160:                 newScope = util.formPath(newScope, property.value);
164:             pathMap[key] = resolveScopeCountPath(newScope);
179:         var newScope = util.formPath(scopeInfo.scope, "import");
185:                     newScope = resolveScopeCountPath(util.formPath(newScope, id.name));
186:                     pathMap[key] = newScope;
204:         var newScope = util.formPath(scopeInfo.scope, "fn");
223:             newScope = resolveScopeCountPath(util.formPath(newScope, name));
224:             pathMap[formPathForScope(fileName, identNode)] = newScope;
228:             newScope = resolveScopeCountPath(newScope);
240:             var paramScope = resolveScopeCountPath(util.formPath(newScope, "param", param.name));
241:             pathMap[formPathForScope(fileName, param)] = paramScope;
267:                 var newScope = resolveScopeCountPath(util.formPath(scopeInfo.scope, "var", decl.name));
268:                 pathMap[key] = newScope;
309:             newScope = resolveScopeCountPath(util.formPath(scopeInfo.scope, "obj", node.object.name));
310:             pathMap[formPathForScope(fileName, node.object)] = newScope;
353:                 newScope = resolveScopeCountPath(util.formPath(newScope, "prop", node.property.name));
356:             pathMap[keyProp] = newScope;
371:         var newScope = util.formPath(scopeInfo.scope, "obj");
375:                 objScope = util.formPath(objScope, "objType", node.objType.name);
378:             var keyScope = util.formPath(objScope, "obj_key");
382:                 keyScope = resolveScopeCountPath(util.formPath(keyScope, node.properties[i].key.name));
383:                 pathMap[keyKey] = keyScope;
387:                 keyScope = resolveScopeCountPath(util.formPath(keyScope, node.properties[i].key.value));
388:                 pathMap[keyKey] = keyScope;
395:                 valScope = resolveScopeCountPath(util.formPath(valScope, "obj_val", node.properties[i].value.name));
396:                 pathMap[key_val] = valScope;
436:         var scope = util.formPath(scopeInfo.scope, "class");
439:             scope = resolveScopeCountPath(util.formPath(scope, node.id.name));
440:             pathMap[formPathForScope(node.sourceFile.name, node.id)] = scope;
446:             scope = resolveScopeCountPath(scope);
457:             pathMap[util.formPath(node.sourceFile.name, node.start, node.start + "class".length)] = scope;
513:     var visitor = extend({}, pathVisitor);
530:         pathVisitor.ClassDeclaration(node, state, cb);
543:         pathVisitor.MethodDefinition(node, state, cb);
562:     var mapRes = pathMap[key];
577:                     methods: pathVisitor
578:                 }, null, pathVisitor);
608:     return pathMap[formPathForScope(node.sourceFile.name, node)];
38: module.exports.formPathForScope = formPathForScope = function(fileName, data) {
163:             var key = formPathForScope(fileName, property);
184:                     var key = formPathForScope(fileName, id);
266:                 var key = formPathForScope(fileName, decl);
355:             keyProp = formPathForScope(fileName, node.property);
381:                 keyKey = formPathForScope(fileName, node.properties[i].key);
386:                 keyKey = formPathForScope(fileName, node.properties[i].key);
394:                 var key_val = formPathForScope(fileName, node.properties[i].value);
508: module.exports.initLocalFilesScopePaths = function(ternServer, localFiles) {
550:                 scope: getFilePathName(file.name),
558:     var key = formPathForScope(defInfo.file, {
575:                     scope: getFilePathName(file.name),
android.googlesource.com/platform/external/perf_data_converter:src/quipper/scoped_temp_path.h: [ master, ]
22:   const string& path() const { return path_; }
25:   string path_;
17: class ScopedTempPath {
19:   ScopedTempPath() {}
6: #define CHROMIUMOS_WIDE_PROFILING_SCOPED_TEMP_PATH_H_
5: #ifndef CHROMIUMOS_WIDE_PROFILING_SCOPED_TEMP_PATH_H_
20:   // The temporary path will be removed when the object is destroyed.
33:   // Create a temporary file.  If successful, the path will be stored in
34:   // |path_|.  If not, |path_| will be an empty string.
43:   // Create a temporary directory.  If successful, the path will be stored in
44:   // |path_|.  If not, |path_| will be an empty string.
53: #endif  // CHROMIUMOS_WIDE_PROFILING_SCOPED_TEMP_PATH_H_
21:   virtual ~ScopedTempPath();
28:   DISALLOW_COPY_AND_ASSIGN(ScopedTempPath);
31: class ScopedTempFile : public ScopedTempPath {
41: class ScopedTempDir : public ScopedTempPath {
github.com/google/capture-thread:example/paths.cc: [ current, ]
60: class Path : public ThreadCapture<Path> {
56:   std::ostringstream path_;
34: class PathBuilder {
85:   static std::string DelegateRootPath(const Path& path) {
89:   static void DelegateLocalPath(const Path& path, PathBuilder* builder) {
95: class InRootPath : public Path {
97:   InRootPath(const std::string& root_path)
101:   std::string RootPath() const override { return root_path_; }
103:   void AppendLocalPath(PathBuilder* builder) const override {
116: class InLocalPath : public Path {
118:   InLocalPath(const std::string& local_path)
122:   std::string RootPath() const override {
127:   void AppendLocalPath(PathBuilder* builder) const override {
111:   const std::string root_path_;
137:   const std::string local_path_;
36:   std::string String() const { return path_.str(); }
41:         path_.str("");
42:         path_ << component;
45:           path_ << '/';
47:         path_ << component;
86:     return path.RootPath();
90:     path.AppendLocalPath(builder);
94: // Sets the root path, which persists while the instance is in scope.
98:       : root_path_(root_path), capture_to_(this) {}
115: // Sets the local path relative to the current root + local path.
119:       : local_path_(local_path), capture_to_(this) {}
133:     builder->Add(local_path_);
143:   InLocalPath path("bin");
146:     std::cerr << "Installing binary " << Path::Working() << std::endl;
152:   InLocalPath path("lib");
155:     std::cerr << "Installing library " << Path::Working() << std::endl;
160: void InstallProjectIn(const std::string& path) {
161:   InRootPath root(path);
162:   std::cerr << "Installing project in " << Path::Root() << std::endl;
33: // A helper class for building paths from components.
38:   PathBuilder& Add(const std::string& component) {
59: // Tracks persistent root and local paths.
64:       return GetCurrent()->RootPath();
72:       PathBuilder builder;
74:       GetCurrent()->AppendLocalPath(&builder);
82:   virtual std::string RootPath() const = 0;
83:   virtual void AppendLocalPath(PathBuilder* builder) const = 0;
106:       DelegateLocalPath(*previous, builder);
124:     return previous ? DelegateRootPath(*previous) : "";
131:       DelegateLocalPath(*previous, builder);
145:     InLocalPath file(target);
154:     InLocalPath file(target);
github.com/apache/flex-whiteboard:rduartes/frameworks/projects/spark/src/spark/primitives/Path.as: [ trunk, ] Duplicate result
github.com/google/go-structeditor:structeditor/path.go: [ master, ]
24: type Path struct {
39: func StringToPath(s string) (*Path, error) {
49: func sliceToPath(slice []string) (*Path, error) {
69: func encodePath(s string) (*Path, error) {
23: // Path to a specific variable
29: 	// Name of struct field in path
33: 	// if nil, this Path refers to the top-level element
34: 	Next *Path
37: // Converts a string to a Path pointer. If the pointer is nil,
38: // the Path refers to the top-level ("current") element.
47: // Converts a string slice to a Path pointer. If the pointer is nil,
48: // the Path refers to the top-level ("current") element.
50: 	var first *Path
51: 	var cur *Path
68: // Encodes path part
75: 		return &Path{
80: 	return &Path{
85: // Appends the specified newElement to the path and
86: // returns the new root of the path.
87: func (p *Path) Append(newElement *Path) *Path {
88: 	var prevEl *Path
89: 	var curEl *Path
100: // Removes the last element from the path and returns
101: // the new root of the path
102: func (p *Path) RemoveLast() *Path {
106: 	var prevEl *Path
107: 	var curEl *Path
114: type VisitingFunc func(updatedPath *Path)
116: // Attaches the specified element to the path, runs the specified function, and
119: func (p *Path) Visiting(element *Path, doing VisitingFunc) {
125: func (p *Path) String() string {
44: 	return sliceToPath(sliced)
53: 		pathEl, err := encodePath(elt)
58: 			first = pathEl
60: 			cur.Next = pathEl
62: 		cur = pathEl
129: 	subpath := p.Next.String()
134: 	if subpath == "" {
137: 		return elt + "." + subpath
github.com/apache/incubator-retired-hdt:site/lib/path.pm: [ master, ]
1: package path;
github.com/Polymer/polymer-css-build:lib/pathresolver.js: [ master, ]
13: const path = require('path').posix;
35:       const pathname = path.relative(
36:         path.dirname(parsedFrom.pathname), parsedTo.pathname);
54:       let path = match.replace(/["']/g, "").slice(4, -1);
55:       path = this.rewriteRelPath(importUrl, mainDocUrl, path);
56:       return 'url("' + path + '")';
12: // Adapted from vulcanize's pathResolver, but only used for css text
26:   rewriteRelPath: function rewriteRelPath(importUrl, mainDocUrl, relUrl) {
38:         pathname,
github.com/kythe/llvmbzlgen:path/path.go: [ master, ]
18: package path
26: type Path []string
44: func ToPaths(paths []string) []Path {
17: // Package path implements path manipulation routines used by cmaketobzl.
21: 	"path/filepath"
25: // Path is a slice of string segments, representing a filesystem path.
28: // Split cleans and splits the system-delimited filesystem path.
29: func New(s string) Path {
35: 		return Path{"/"}
37: 		return append(Path{"/"}, strings.Split(s[1:], "/")...)
45: 	split := make([]Path, len(paths))
53: func (p Path) LessThan(o Path) bool {
66: // String returns the properly platform-delimited form of the path.
67: func (p Path) String() string {
74: // Append appends additional elements to the end of path, disregarding
76: func Append(p Path, ps ...Path) Path {
87: // AppendString appends additional string elements to the end of path.
88: func AppendString(p Path, elem ...string) Path {
93: func Join(p Path, ps ...Path) Path {
100: // JoinString joins path and any number of additional string elements, returning the result.
101: func JoinString(p Path, elem ...string) Path {
106: // path and returns that along with each path stripped of that prefix.
107: func SplitCommonRoot(paths []Path) (Path, []Path) {
112: 	result := make([]Path, len(paths))
120: // path and returns that along with each path stripped of that prefix as /-delimited strings.
130: // LongestCommonPrefix returns the longest shared Path prefix of all of the paths.
131: func LongestCommonPrefix(paths []Path) Path {
30: 	s = filepath.ToSlash(filepath.Clean(s))
43: // ToPaths cleans and splits each of the system-delimited filesystem paths.
46: 	for i, p := range paths {
52: // LessThan provides lexicographic ordering of Paths.
71: 	return filepath.Join([]string(p)...)
78: 		// Drop the leading '/' when appending/joining fully qualified paths.
92: // Join joins any number of paths and returns the result.
108: 	root := LongestCommonPrefix(paths)
110: 		return root, paths
113: 	for i, p := range paths {
121: func SplitCommonRootString(paths []string) (string, []string) {
122: 	root, stripped := SplitCommonRoot(ToPaths(paths))
132: 	switch len(paths) {
136: 		return paths[0]
138: 	min, max := paths[0], paths[0]
139: 	for _, p := range paths[1:] {
89: 	return Append(p, ToPaths(elem)...)
102: 	return Join(p, ToPaths(elem)...)
github.com/kubernetes/kubernetes:api/swagger-spec/v1.json: [ master, ]
12:     "path": "/api/v1/namespaces/{namespace}/bindings",
75:     "path": "/api/v1/componentstatuses",
178:     "path": "/api/v1/componentstatuses/{name}",
223:     "path": "/api/v1/namespaces/{namespace}/configmaps",
494:     "path": "/api/v1/watch/namespaces/{namespace}/configmaps",
605:     "path": "/api/v1/namespaces/{namespace}/configmaps/{name}",
870:     "path": "/api/v1/watch/namespaces/{namespace}/configmaps/{name}",
989:     "path": "/api/v1/configmaps",
1092:     "path": "/api/v1/watch/configmaps",
1195:     "path": "/api/v1/namespaces/{namespace}/endpoints",
1466:     "path": "/api/v1/watch/namespaces/{namespace}/endpoints",
1577:     "path": "/api/v1/namespaces/{namespace}/endpoints/{name}",
1842:     "path": "/api/v1/watch/namespaces/{namespace}/endpoints/{name}",
1961:     "path": "/api/v1/endpoints",
2064:     "path": "/api/v1/watch/endpoints",
2167:     "path": "/api/v1/namespaces/{namespace}/events",
2438:     "path": "/api/v1/watch/namespaces/{namespace}/events",
2549:     "path": "/api/v1/namespaces/{namespace}/events/{name}",
2814:     "path": "/api/v1/watch/namespaces/{namespace}/events/{name}",
2933:     "path": "/api/v1/events",
3036:     "path": "/api/v1/watch/events",
3139:     "path": "/api/v1/namespaces/{namespace}/limitranges",
3410:     "path": "/api/v1/watch/namespaces/{namespace}/limitranges",
3521:     "path": "/api/v1/namespaces/{namespace}/limitranges/{name}",
3786:     "path": "/api/v1/watch/namespaces/{namespace}/limitranges/{name}",
3905:     "path": "/api/v1/limitranges",
4008:     "path": "/api/v1/watch/limitranges",
4111:     "path": "/api/v1/namespaces",
4263:     "path": "/api/v1/watch/namespaces",
4366:     "path": "/api/v1/namespaces/{name}",
4599:     "path": "/api/v1/watch/namespaces/{name}",
4710:     "path": "/api/v1/namespaces/{name}/finalize",
4768:     "path": "/api/v1/namespaces/{name}/status",
4914:     "path": "/api/v1/nodes",
5161:     "path": "/api/v1/watch/nodes",
5264:     "path": "/api/v1/nodes/{name}",
5497:     "path": "/api/v1/watch/nodes/{name}",
5608:     "path": "/api/v1/proxy/nodes/{name}/{path}",
5824:     "path": "/api/v1/proxy/nodes/{name}",
5984:     "path": "/api/v1/nodes/{name}/proxy",
6200:     "path": "/api/v1/nodes/{name}/proxy/{path}",
6472:     "path": "/api/v1/nodes/{name}/status",
6618:     "path": "/api/v1/namespaces/{namespace}/persistentvolumeclaims",
6889:     "path": "/api/v1/watch/namespaces/{namespace}/persistentvolumeclaims",
7000:     "path": "/api/v1/namespaces/{namespace}/persistentvolumeclaims/{name}",
7265:     "path": "/api/v1/watch/namespaces/{namespace}/persistentvolumeclaims/{name}",
7384:     "path": "/api/v1/persistentvolumeclaims",
7487:     "path": "/api/v1/watch/persistentvolumeclaims",
7590:     "path": "/api/v1/namespaces/{namespace}/persistentvolumeclaims/{name}/status",
7760:     "path": "/api/v1/persistentvolumes",
8007:     "path": "/api/v1/watch/persistentvolumes",
8110:     "path": "/api/v1/persistentvolumes/{name}",
8343:     "path": "/api/v1/watch/persistentvolumes/{name}",
8454:     "path": "/api/v1/persistentvolumes/{name}/status",
8600:     "path": "/api/v1/namespaces/{namespace}/pods",
8871:     "path": "/api/v1/watch/namespaces/{namespace}/pods",
8982:     "path": "/api/v1/namespaces/{namespace}/pods/{name}",
9247:     "path": "/api/v1/watch/namespaces/{namespace}/pods/{name}",
9366:     "path": "/api/v1/proxy/namespaces/{namespace}/pods/{name}/{path}",
9638:     "path": "/api/v1/proxy/namespaces/{namespace}/pods/{name}",
9854:     "path": "/api/v1/pods",
9957:     "path": "/api/v1/watch/pods",
10060:     "path": "/api/v1/namespaces/{namespace}/pods/{name}/attach",
10206:     "path": "/api/v1/namespaces/{namespace}/pods/{name}/binding",
10277:     "path": "/api/v1/namespaces/{namespace}/pods/{name}/eviction",
10348:     "path": "/api/v1/namespaces/{namespace}/pods/{name}/exec",
10510:     "path": "/api/v1/namespaces/{namespace}/pods/{name}/log",
10620:     "path": "/api/v1/namespaces/{namespace}/pods/{name}/portforward",
10702:     "path": "/api/v1/namespaces/{namespace}/pods/{name}/proxy",
10974:     "path": "/api/v1/namespaces/{namespace}/pods/{name}/proxy/{path}",
11302:     "path": "/api/v1/namespaces/{namespace}/pods/{name}/status",
11472:     "path": "/api/v1/namespaces/{namespace}/podtemplates",
11743:     "path": "/api/v1/watch/namespaces/{namespace}/podtemplates",
11854:     "path": "/api/v1/namespaces/{namespace}/podtemplates/{name}",
12119:     "path": "/api/v1/watch/namespaces/{namespace}/podtemplates/{name}",
12238:     "path": "/api/v1/podtemplates",
12341:     "path": "/api/v1/watch/podtemplates",
12444:     "path": "/api/v1/namespaces/{namespace}/replicationcontrollers",
12715:     "path": "/api/v1/watch/namespaces/{namespace}/replicationcontrollers",
12826:     "path": "/api/v1/namespaces/{namespace}/replicationcontrollers/{name}",
13091:     "path": "/api/v1/watch/namespaces/{namespace}/replicationcontrollers/{name}",
13210:     "path": "/api/v1/replicationcontrollers",
13313:     "path": "/api/v1/watch/replicationcontrollers",
13416:     "path": "/api/v1/namespaces/{namespace}/replicationcontrollers/{name}/scale",
13586:     "path": "/api/v1/namespaces/{namespace}/replicationcontrollers/{name}/status",
13756:     "path": "/api/v1/namespaces/{namespace}/resourcequotas",
14027:     "path": "/api/v1/watch/namespaces/{namespace}/resourcequotas",
14138:     "path": "/api/v1/namespaces/{namespace}/resourcequotas/{name}",
14403:     "path": "/api/v1/watch/namespaces/{namespace}/resourcequotas/{name}",
14522:     "path": "/api/v1/resourcequotas",
14625:     "path": "/api/v1/watch/resourcequotas",
14728:     "path": "/api/v1/namespaces/{namespace}/resourcequotas/{name}/status",
14898:     "path": "/api/v1/namespaces/{namespace}/secrets",
15169:     "path": "/api/v1/watch/namespaces/{namespace}/secrets",
15280:     "path": "/api/v1/namespaces/{namespace}/secrets/{name}",
15545:     "path": "/api/v1/watch/namespaces/{namespace}/secrets/{name}",
15664:     "path": "/api/v1/secrets",
15767:     "path": "/api/v1/watch/secrets",
15870:     "path": "/api/v1/namespaces/{namespace}/serviceaccounts",
16141:     "path": "/api/v1/watch/namespaces/{namespace}/serviceaccounts",
16252:     "path": "/api/v1/namespaces/{namespace}/serviceaccounts/{name}",
16517:     "path": "/api/v1/watch/namespaces/{namespace}/serviceaccounts/{name}",
16636:     "path": "/api/v1/serviceaccounts",
16739:     "path": "/api/v1/watch/serviceaccounts",
16842:     "path": "/api/v1/namespaces/{namespace}/services",
17010:     "path": "/api/v1/watch/namespaces/{namespace}/services",
17121:     "path": "/api/v1/namespaces/{namespace}/services/{name}",
17354:     "path": "/api/v1/watch/namespaces/{namespace}/services/{name}",
17473:     "path": "/api/v1/proxy/namespaces/{namespace}/services/{name}/{path}",
17745:     "path": "/api/v1/proxy/namespaces/{namespace}/services/{name}",
17961:     "path": "/api/v1/services",
18064:     "path": "/api/v1/watch/services",
18167:     "path": "/api/v1/namespaces/{namespace}/services/{name}/proxy",
18439:     "path": "/api/v1/namespaces/{namespace}/services/{name}/proxy/{path}",
18767:     "path": "/api/v1/namespaces/{namespace}/services/{name}/status",
18937:     "path": "/api/v1",
4:   "basePath": "https://10.10.10.10:6443",
5:   "resourcePath": "/api/v1",
39:         "paramType": "path",
197:         "paramType": "path",
306:         "paramType": "path",
355:         "paramType": "path",
468:         "paramType": "path",
577:         "paramType": "path",
640:         "paramType": "path",
648:         "paramType": "path",
695:         "paramType": "path",
703:         "paramType": "path",
755:         "paramType": "path",
763:         "paramType": "path",
836:         "paramType": "path",
844:         "paramType": "path",
953:         "paramType": "path",
961:         "paramType": "path",
1278:         "paramType": "path",
1327:         "paramType": "path",
1440:         "paramType": "path",
1549:         "paramType": "path",
1612:         "paramType": "path",
1620:         "paramType": "path",
1667:         "paramType": "path",
1675:         "paramType": "path",
1727:         "paramType": "path",
1735:         "paramType": "path",
1808:         "paramType": "path",
1816:         "paramType": "path",
1925:         "paramType": "path",
1933:         "paramType": "path",
2250:         "paramType": "path",
2299:         "paramType": "path",
2412:         "paramType": "path",
2521:         "paramType": "path",
2584:         "paramType": "path",
2592:         "paramType": "path",
2639:         "paramType": "path",
2647:         "paramType": "path",
2699:         "paramType": "path",
2707:         "paramType": "path",
2780:         "paramType": "path",
2788:         "paramType": "path",
2897:         "paramType": "path",
2905:         "paramType": "path",
3222:         "paramType": "path",
3271:         "paramType": "path",
3384:         "paramType": "path",
3493:         "paramType": "path",
3556:         "paramType": "path",
3564:         "paramType": "path",
3611:         "paramType": "path",
3619:         "paramType": "path",
3671:         "paramType": "path",
3679:         "paramType": "path",
3752:         "paramType": "path",
3760:         "paramType": "path",
3869:         "paramType": "path",
3877:         "paramType": "path",
4401:         "paramType": "path",
4448:         "paramType": "path",
4500:         "paramType": "path",
4573:         "paramType": "path",
4682:         "paramType": "path",
4737:         "paramType": "path",
4787:         "paramType": "path",
4834:         "paramType": "path",
4886:         "paramType": "path",
5299:         "paramType": "path",
5346:         "paramType": "path",
5398:         "paramType": "path",
5471:         "paramType": "path",
5580:         "paramType": "path",
5619:         "paramType": "path",
5627:         "paramType": "path",
5628:         "name": "path",
5629:         "description": "path to the resource",
5649:         "paramType": "path",
5657:         "paramType": "path",
5658:         "name": "path",
5659:         "description": "path to the resource",
5679:         "paramType": "path",
5687:         "paramType": "path",
5688:         "name": "path",
5689:         "description": "path to the resource",
5709:         "paramType": "path",
5717:         "paramType": "path",
5718:         "name": "path",
5719:         "description": "path to the resource",
5739:         "paramType": "path",
5747:         "paramType": "path",
5748:         "name": "path",
5749:         "description": "path to the resource",
5769:         "paramType": "path",
5777:         "paramType": "path",
5778:         "name": "path",
5779:         "description": "path to the resource",
5799:         "paramType": "path",
5807:         "paramType": "path",
5808:         "name": "path",
5809:         "description": "path to the resource",
5835:         "paramType": "path",
5857:         "paramType": "path",
5879:         "paramType": "path",
5901:         "paramType": "path",
5923:         "paramType": "path",
5945:         "paramType": "path",
5967:         "paramType": "path",
5996:         "name": "path",
5997:         "description": "Path is the URL path to use for the current proxy request to node.",
6003:         "paramType": "path",
6026:         "name": "path",
6027:         "description": "Path is the URL path to use for the current proxy request to node.",
6033:         "paramType": "path",
6056:         "name": "path",
6057:         "description": "Path is the URL path to use for the current proxy request to node.",
6063:         "paramType": "path",
6086:         "name": "path",
6087:         "description": "Path is the URL path to use for the current proxy request to node.",
6093:         "paramType": "path",
6116:         "name": "path",
6117:         "description": "Path is the URL path to use for the current proxy request to node.",
6123:         "paramType": "path",
6146:         "name": "path",
6147:         "description": "Path is the URL path to use for the current proxy request to node.",
6153:         "paramType": "path",
6176:         "name": "path",
6177:         "description": "Path is the URL path to use for the current proxy request to node.",
6183:         "paramType": "path",
6212:         "name": "path",
6213:         "description": "Path is the URL path to use for the current proxy request to node.",
6219:         "paramType": "path",
6227:         "paramType": "path",
6228:         "name": "path",
6229:         "description": "path to the resource",
6250:         "name": "path",
6251:         "description": "Path is the URL path to use for the current proxy request to node.",
6257:         "paramType": "path",
6265:         "paramType": "path",
6266:         "name": "path",
6267:         "description": "path to the resource",
6288:         "name": "path",
6289:         "description": "Path is the URL path to use for the current proxy request to node.",
6295:         "paramType": "path",
6303:         "paramType": "path",
6304:         "name": "path",
6305:         "description": "path to the resource",
6326:         "name": "path",
6327:         "description": "Path is the URL path to use for the current proxy request to node.",
6333:         "paramType": "path",
6341:         "paramType": "path",
6342:         "name": "path",
6343:         "description": "path to the resource",
6364:         "name": "path",
6365:         "description": "Path is the URL path to use for the current proxy request to node.",
6371:         "paramType": "path",
6379:         "paramType": "path",
6380:         "name": "path",
6381:         "description": "path to the resource",
6402:         "name": "path",
6403:         "description": "Path is the URL path to use for the current proxy request to node.",
6409:         "paramType": "path",
6417:         "paramType": "path",
6418:         "name": "path",
6419:         "description": "path to the resource",
6440:         "name": "path",
6441:         "description": "Path is the URL path to use for the current proxy request to node.",
6447:         "paramType": "path",
6455:         "paramType": "path",
6456:         "name": "path",
6457:         "description": "path to the resource",
6491:         "paramType": "path",
6538:         "paramType": "path",
6590:         "paramType": "path",
6701:         "paramType": "path",
6750:         "paramType": "path",
6863:         "paramType": "path",
6972:         "paramType": "path",
7035:         "paramType": "path",
7043:         "paramType": "path",
7090:         "paramType": "path",
7098:         "paramType": "path",
7150:         "paramType": "path",
7158:         "paramType": "path",
7231:         "paramType": "path",
7239:         "paramType": "path",
7348:         "paramType": "path",
7356:         "paramType": "path",
7609:         "paramType": "path",
7617:         "paramType": "path",
7664:         "paramType": "path",
7672:         "paramType": "path",
7724:         "paramType": "path",
7732:         "paramType": "path",
8145:         "paramType": "path",
8192:         "paramType": "path",
8244:         "paramType": "path",
8317:         "paramType": "path",
8426:         "paramType": "path",
8473:         "paramType": "path",
8520:         "paramType": "path",
8572:         "paramType": "path",
8683:         "paramType": "path",
8732:         "paramType": "path",
8845:         "paramType": "path",
8954:         "paramType": "path",
9017:         "paramType": "path",
9025:         "paramType": "path",
9072:         "paramType": "path",
9080:         "paramType": "path",
9132:         "paramType": "path",
9140:         "paramType": "path",
9213:         "paramType": "path",
9221:         "paramType": "path",
9330:         "paramType": "path",
9338:         "paramType": "path",
9377:         "paramType": "path",
9385:         "paramType": "path",
9393:         "paramType": "path",
9394:         "name": "path",
9395:         "description": "path to the resource",
9415:         "paramType": "path",
9423:         "paramType": "path",
9431:         "paramType": "path",
9432:         "name": "path",
9433:         "description": "path to the resource",