From 0e200da1880af4e07dab9490c382f1471633e608 Mon Sep 17 00:00:00 2001 From: Stefan Karpinski Date: Fri, 1 Nov 2013 11:56:59 -0500 Subject: [PATCH] home(): no more user_{home,pref,documents}dir(). --- base/client.jl | 2 +- base/deprecated.jl | 4 ++++ base/file.jl | 4 ++-- base/path.jl | 22 ++++------------------ base/pkg/dir.jl | 2 +- etc/juliarc.jl | 2 +- 6 files changed, 13 insertions(+), 23 deletions(-) diff --git a/base/client.jl b/base/client.jl index 5e2162552bf26..b69ba4d76f2e0 100644 --- a/base/client.jl +++ b/base/client.jl @@ -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 diff --git a/base/deprecated.jl b/base/deprecated.jl index fce51d43c4e88..8f0ef6fcd358c 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -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 diff --git a/base/file.jl b/base/file.jl index 13709979b0f92..42672f9bc641d 100644 --- a/base/file.jl +++ b/base/file.jl @@ -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) @@ -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) diff --git a/base/path.jl b/base/path.jl index 743a8ce259254..44509396fcd8d 100644 --- a/base/path.jl +++ b/base/path.jl @@ -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 = "\\" @@ -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) @@ -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 diff --git a/base/pkg/dir.jl b/base/pkg/dir.jl index 0fbcfed9c6117..9ad5e491de459 100644 --- a/base/pkg/dir.jl +++ b/base/pkg/dir.jl @@ -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 diff --git a/etc/juliarc.jl b/etc/juliarc.jl index 332677d5ee25c..6c2664ff635c3 100644 --- a/etc/juliarc.jl +++ b/etc/juliarc.jl @@ -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