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