about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorAxel Viala <axel.viala@darnuria.eu>2014-06-04 16:33:25 +0200
committerAxel Viala <axel.viala@darnuria.eu>2014-06-05 11:39:01 +0200
commitf377dfe5acfd7023d535a94cfe9466276affc6da (patch)
treefb86aafbf762e77c63e993b0f4069568950d7f9b /src/libstd
parent650909244eee51b4fd70389538c6b784ccf005c7 (diff)
downloadrust-f377dfe5acfd7023d535a94cfe9466276affc6da.tar.gz
rust-f377dfe5acfd7023d535a94cfe9466276affc6da.zip
Adding examples and possible failures for getcwd.
For both window and unix platforms.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/os.rs38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/libstd/os.rs b/src/libstd/os.rs
index 15fd2cb8f12..eae4ca42201 100644
--- a/src/libstd/os.rs
+++ b/src/libstd/os.rs
@@ -66,7 +66,24 @@ pub fn close(fd: int) -> int {
 pub static TMPBUF_SZ : uint = 1000u;
 static BUF_BYTES : uint = 2048u;
 
-/// Returns the current working directory.
+/// Returns the current working directory as a Path.
+///
+/// # Failure
+///
+/// Fails if the current working directory value is invalid:
+/// Possibles cases:
+///
+/// * Current directory does not exist.
+/// * There are insufficient permissions to access the current directory.
+///
+/// # Example
+///
+/// ```rust
+/// // We assume that we are in a valid directory like "/home".
+/// let current_working_directory = std::os::getcwd();
+/// println!("The current directory is {}", current_working_directory.display());
+/// // /home
+/// ```
 #[cfg(unix)]
 pub fn getcwd() -> Path {
     use c_str::CString;
@@ -80,7 +97,24 @@ pub fn getcwd() -> Path {
     }
 }
 
-/// Returns the current working directory.
+/// Returns the current working directory as a Path.
+///
+/// # Failure
+///
+/// Fails if the current working directory value is invalid.
+/// Possibles cases:
+///
+/// * Current directory does not exist.
+/// * There are insufficient permissions to access the current directory.
+///
+/// # Example
+///
+/// ```rust
+/// // We assume that we are in a valid directory like "C:\\Windows".
+/// let current_working_directory = std::os::getcwd();
+/// println!("The current directory is {}", current_working_directory.display());
+/// // C:\\Windows
+/// ```
 #[cfg(windows)]
 pub fn getcwd() -> Path {
     use libc::DWORD;