@@ -44,31 +44,71 @@ pub fn PosixPath(s: &str) -> PosixPath {
44
44
}
45
45
46
46
pub trait GenericPath {
47
+ /// Converts a string to a Path
47
48
fn from_str ( & str ) -> Self ;
48
49
50
+ /// Returns the directory component of `self`, as a string
49
51
fn dirname ( & self ) -> ~str ;
52
+ /// Returns the file component of `self`, as a string option.
53
+ /// Returns None if `self` names a directory.
50
54
fn filename ( & self ) -> Option < ~str > ;
55
+ /// Returns the stem of the file component of `self`, as a string option.
56
+ /// The stem is the slice of a filename starting at 0 and ending just before
57
+ /// the last '.' in the name.
58
+ /// Returns None if `self` names a directory.
51
59
fn filestem ( & self ) -> Option < ~str > ;
60
+ /// Returns the type of the file component of `self`, as a string option.
61
+ /// The file type is the slice of a filename starting just after the last
62
+ /// '.' in the name and ending at the last index in the filename.
63
+ /// Returns None if `self` names a directory.
52
64
fn filetype ( & self ) -> Option < ~str > ;
53
65
66
+ /// Returns a new path consisting of `self` with the parent directory component replaced
67
+ /// with the given string.
54
68
fn with_dirname ( & self , ( & str ) ) -> Self ;
69
+ /// Returns a new path consisting of `self` with the file component replaced
70
+ /// with the given string.
55
71
fn with_filename ( & self , ( & str ) ) -> Self ;
72
+ /// Returns a new path consisting of `self` with the file stem replaced
73
+ /// with the given string.
56
74
fn with_filestem ( & self , ( & str ) ) -> Self ;
75
+ /// Returns a new path consisting of `self` with the file type replaced
76
+ /// with the given string.
57
77
fn with_filetype ( & self , ( & str ) ) -> Self ;
58
78
79
+ /// Returns the directory component of `self`, as a new path.
80
+ /// If `self` has no parent, returns `self`.
59
81
fn dir_path ( & self ) -> Self ;
82
+ /// Returns the file component of `self`, as a new path.
83
+ /// If `self` names a directory, returns the empty path.
60
84
fn file_path ( & self ) -> Self ;
61
85
86
+ /// Returns a new Path whose parent directory is `self` and whose
87
+ /// file component is the given string.
62
88
fn push ( & self , ( & str ) ) -> Self ;
89
+ /// Returns a new Path consisting of the given path, made relative to `self`.
63
90
fn push_rel ( & self , ( & Self ) ) -> Self ;
91
+ /// Returns a new Path consisting of the path given by the given vector
92
+ /// of strings, relative to `self`.
64
93
fn push_many ( & self , ( & [ ~str ] ) ) -> Self ;
94
+ /// Identical to `dir_path` except in the case where `self` has only one
95
+ /// component. In this case, `pop` returns the empty path.
65
96
fn pop ( & self ) -> Self ;
66
97
98
+ /// The same as `push_rel`, except that the directory argument must not
99
+ /// contain directory separators in any of its components.
67
100
fn unsafe_join ( & self , ( & Self ) ) -> Self ;
101
+ /// On Unix, always returns false. On Windows, returns true iff `self`'s
102
+ /// file stem is one of: `con` `aux` `com1` `com2` `com3` `com4`
103
+ /// `lpt1` `lpt2` `lpt3` `prn` `nul`
68
104
fn is_restricted ( & self ) -> bool ;
69
105
106
+ /// Returns a new path that names the same file as `self`, without containing
107
+ /// any '.', '..', or empty components. On Windows, uppercases the drive letter
108
+ /// as well.
70
109
fn normalize ( & self ) -> Self ;
71
110
111
+ /// Returns `true` if `self` is an absolute path.
72
112
fn is_absolute ( & self ) -> bool ;
73
113
}
74
114
0 commit comments