Skip to content

Commit

Permalink
home(): no more user_{home,pref,documents}dir().
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKarpinski committed Nov 1, 2013
1 parent 355b627 commit 0e200da
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 23 deletions.
2 changes: 1 addition & 1 deletion base/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ function load_juliarc()
else
try_include(abspath(JULIA_HOME,"..","etc","julia","juliarc.jl"))
end
try_include(abspath(user_prefdir(),".juliarc.jl"))
try_include(abspath(home(),".juliarc.jl"))
end


Expand Down
4 changes: 4 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ end

@deprecate memio(args...) IOBuffer()

@deprecate user_homedir home
@deprecate user_prefdir home
@deprecate user_documentsdir home

# note removed macros: str, B_str, I_str, E_str, L_str, L_mstr, I_mstr, E_mstr

const ref = getindex
Expand Down
4 changes: 2 additions & 2 deletions base/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function cd(dir::String)
@windows_only systemerror("chdir $dir", ccall(:_chdir,Int32,(Ptr{Uint8},),dir) == -1)
@unix_only systemerror("chdir $dir", ccall(:chdir,Int32,(Ptr{Uint8},),dir) == -1)
end
cd() = cd(user_homedir())
cd() = cd(home())

@unix_only function cd(f::Function, dir::String, args...)
fd = ccall(:open,Int32,(Ptr{Uint8},Int32),".",0)
Expand All @@ -34,7 +34,7 @@ end
cd(old)
end
end
cd(f::Function) = cd(f, user_homedir())
cd(f::Function) = cd(f, home())

function mkdir(path::String, mode::Unsigned=0o777)
@unix_only ret = ccall(:mkdir, Int32, (Ptr{Uint8},Uint32), bytestring(path), mode)
Expand Down
22 changes: 4 additions & 18 deletions base/path.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
const path_ext_splitter = r"^((?:.*/)?(?:\.|[^/\.])[^/]*?)(\.[^/\.]*|)$"

splitdrive(path::String) = ("",path)
user_homedir() = ENV["HOME"]
user_prefdir() = user_homedir()
user_documentsdir() = @osx ? joinpath(user_homedir(),"Documents") : user_homedir()
home() = ENV["HOME"]
end
@windows_only begin
const path_separator = "\\"
Expand All @@ -23,19 +21,7 @@ end
m = match(r"^(\w+:|\\\\\w+\\\w+|\\\\\?\\UNC\\\w+\\\w+|\\\\\?\\\w+:|)(.*)$", path)
bytestring(m.captures[1]), bytestring(m.captures[2])
end
user_homedir() = get(ENV,"HOME",joinpath(ENV["HOMEDRIVE"],ENV["HOMEPATH"]))
user_prefdir() = user_homedir()
function user_documentsdir()
#HRESULT result = SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, my_documents);
path = Array(Uint8,260)
result = ccall((:SHGetFolderPathA,:shell32),stdcall,Cint,
(Ptr{Void},Cint,Ptr{Void},Cint,Ptr{Uint8}),0,0x0005,0,0,path)
if result == 0
return bytestring(path[1:findfirst(path,0)-1])
else
return user_homedir()
end
end
home() = get(ENV,"HOME",joinpath(ENV["HOMEDRIVE"],ENV["HOMEPATH"]))
end

isabspath(path::String) = ismatch(path_absolute_re, path)
Expand Down Expand Up @@ -149,8 +135,8 @@ end
i = start(path)
c, i = next(path,i)
if c != '~' return path end
if done(path,i) return ENV["HOME"] end
if done(path,i) return home() end
c, j = next(path,i)
if c == '/' return ENV["HOME"]*path[i:end] end
if c == '/' return home()*path[i:end] end
error("~user tilde expansion not yet implemented")
end
2 changes: 1 addition & 1 deletion base/pkg/dir.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import ..Pkg: DEFAULT_META, META_BRANCH
const DIR_NAME = ".julia"

function path()
b = abspath(get(ENV,"JULIA_PKGDIR",joinpath(Base.user_prefdir(),DIR_NAME)))
b = abspath(get(ENV,"JULIA_PKGDIR",joinpath(Base.home(),DIR_NAME)))
x, y = VERSION.major, VERSION.minor
d = joinpath(b,"v$x.$y")
isdir(d) && return d
Expand Down
2 changes: 1 addition & 1 deletion etc/juliarc.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This file should contain site-specific commands to be executed on Julia startup
# Users should store their own personal commands in user_prefdir(), in a file named .juliarc.jl
# Users should store their own personal commands in home(), in a file named .juliarc.jl

0 comments on commit 0e200da

Please sign in to comment.