libstd: refine dynamic memory allocations in os::getcwd() and os::change_dir()

Unless it's a serious violation to the coding rule, I'd like to use the `OK` constant since it makes me feel insecure to branch on the result of a function which returns a boolean but isn't a logical predicate.  Does `true` mean "I can proceed", or does it mean "I should handle an error"?  `if let` with `Result` would nice here...