Skip to content

Commit

Permalink
Merge branch 'master' of github.com:JuliaLang/julia
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed May 21, 2012
2 parents f4b93ef + 08cc377 commit 6bd3cfc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
2 changes: 1 addition & 1 deletion base/error.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ end
errno() = ccall(:jl_errno, Int32, ())
strerror(e::Integer) = ccall(:jl_strerror, Any, (Int32,), e)::ByteString
strerror() = strerror(errno())
system_error(p, b::Bool) = b ? error(SystemError(string(p))) : nothing
system_error(p, b::Bool) = b ? throw(SystemError(cstring(p))) : nothing

## assertion functions and macros ##

Expand Down
11 changes: 2 additions & 9 deletions base/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,11 @@
function cwd()
b = Array(Uint8,1024)
p = ccall(:getcwd, Ptr{Uint8}, (Ptr{Uint8}, Uint), b, length(b))
if p == C_NULL
error("current directory has been deleted (or has a really long name)")
end
system_error("cwd", p==C_NULL)
cstring(p)
end

function cd(dir::String)
if ccall(:chdir, Int32, (Ptr{Uint8},), dir) == -1
throw(SystemError("cd"))
end
cwd()
end
cd(dir::String) = (system_error("cd", ccall(:chdir, Int32, (Ptr{Uint8},), dir)==-1); cwd())

# do stuff in a directory, then return to current directory

Expand Down

0 comments on commit 6bd3cfc

Please sign in to comment.