File tree Expand file tree Collapse file tree 1 file changed +36
-2
lines changed Expand file tree Collapse file tree 1 file changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,24 @@ pub fn close(fd: int) -> int {
66
66
pub static TMPBUF_SZ : uint = 1000 u;
67
67
static BUF_BYTES : uint = 2048 u;
68
68
69
- /// Returns the current working directory.
69
+ /// Returns the current working directory as a Path.
70
+ ///
71
+ /// # Failure
72
+ ///
73
+ /// Fails if the current working directory value is invalid:
74
+ /// Possibles cases:
75
+ ///
76
+ /// * Current directory does not exist.
77
+ /// * There are insufficient permissions to access the current directory.
78
+ ///
79
+ /// # Example
80
+ ///
81
+ /// ```rust
82
+ /// // We assume that we are in a valid directory like "/home".
83
+ /// let current_working_directory = std::os::getcwd();
84
+ /// println!("The current directory is {}", current_working_directory.display());
85
+ /// // /home
86
+ /// ```
70
87
#[ cfg( unix) ]
71
88
pub fn getcwd ( ) -> Path {
72
89
use c_str:: CString ;
@@ -80,7 +97,24 @@ pub fn getcwd() -> Path {
80
97
}
81
98
}
82
99
83
- /// Returns the current working directory.
100
+ /// Returns the current working directory as a Path.
101
+ ///
102
+ /// # Failure
103
+ ///
104
+ /// Fails if the current working directory value is invalid.
105
+ /// Possibles cases:
106
+ ///
107
+ /// * Current directory does not exist.
108
+ /// * There are insufficient permissions to access the current directory.
109
+ ///
110
+ /// # Example
111
+ ///
112
+ /// ```rust
113
+ /// // We assume that we are in a valid directory like "C:\\Windows".
114
+ /// let current_working_directory = std::os::getcwd();
115
+ /// println!("The current directory is {}", current_working_directory.display());
116
+ /// // C:\\Windows
117
+ /// ```
84
118
#[ cfg( windows) ]
85
119
pub fn getcwd ( ) -> Path {
86
120
use libc:: DWORD ;
You can’t perform that action at this time.
0 commit comments