@@ -49,31 +49,71 @@ pub fn PosixPath(s: &str) -> PosixPath {
4949}
5050
5151pub trait GenericPath {
52+ /// Converts a string to a Path
5253 fn from_str ( & str ) -> Self ;
5354
55+ /// Returns the directory component of `self`, as a string
5456 fn dirname ( & self ) -> ~str ;
57+ /// Returns the file component of `self`, as a string option.
58+ /// Returns None if `self` names a directory.
5559 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.
5664 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.
5769 fn filetype ( & self ) -> Option < ~str > ;
5870
71+ /// Returns a new path consisting of `self` with the parent directory component replaced
72+ /// with the given string.
5973 fn with_dirname ( & self , ( & str ) ) -> Self ;
74+ /// Returns a new path consisting of `self` with the file component replaced
75+ /// with the given string.
6076 fn with_filename ( & self , ( & str ) ) -> Self ;
77+ /// Returns a new path consisting of `self` with the file stem replaced
78+ /// with the given string.
6179 fn with_filestem ( & self , ( & str ) ) -> Self ;
80+ /// Returns a new path consisting of `self` with the file type replaced
81+ /// with the given string.
6282 fn with_filetype ( & self , ( & str ) ) -> Self ;
6383
84+ /// Returns the directory component of `self`, as a new path.
85+ /// If `self` has no parent, returns `self`.
6486 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.
6589 fn file_path ( & self ) -> Self ;
6690
91+ /// Returns a new Path whose parent directory is `self` and whose
92+ /// file component is the given string.
6793 fn push ( & self , ( & str ) ) -> Self ;
94+ /// Returns a new Path consisting of the given path, made relative to `self`.
6895 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`.
6998 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.
70101 fn pop ( & self ) -> Self ;
71102
103+ /// The same as `push_rel`, except that the directory argument must not
104+ /// contain directory separators in any of its components.
72105 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`
73109 fn is_restricted ( & self ) -> bool ;
74110
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.
75114 fn normalize ( & self ) -> Self ;
76115
116+ /// Returns `true` if `self` is an absolute path.
77117 fn is_absolute ( & self ) -> bool ;
78118}
79119
0 commit comments