File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -566,6 +566,31 @@ impl Path {
566
566
fs:: read_link ( self ) . await
567
567
}
568
568
569
+ /// Determines whether `base` is a prefix of `self`.
570
+ ///
571
+ /// Only considers whole path components to match.
572
+ ///
573
+ /// # Examples
574
+ ///
575
+ /// ```
576
+ /// use async_std::path::Path;
577
+ ///
578
+ /// let path = Path::new("/etc/passwd");
579
+ ///
580
+ /// assert!(path.starts_with("/etc"));
581
+ /// assert!(path.starts_with("/etc/"));
582
+ /// assert!(path.starts_with("/etc/passwd"));
583
+ /// assert!(path.starts_with("/etc/passwd/"));
584
+ ///
585
+ /// assert!(!path.starts_with("/e"));
586
+ /// ```
587
+ pub fn starts_with < P : AsRef < Path > > ( & self , base : P ) -> bool
588
+ where
589
+ P : std:: convert:: AsRef < std:: path:: Path > ,
590
+ {
591
+ self . inner . starts_with ( base)
592
+ }
593
+
569
594
/// Queries the metadata about a file without following symlinks.
570
595
///
571
596
/// This is an alias to [`fs::symlink_metadata`].
You can’t perform that action at this time.
0 commit comments