diff --git a/base/path.jl b/base/path.jl index 5091c4b1b1286..46e61cc4d241a 100644 --- a/base/path.jl +++ b/base/path.jl @@ -9,6 +9,7 @@ splitdrive(path::String) = ("",path) user_homedir() = ENV["HOME"] user_prefdir() = user_homedir() + user_documentsdir() = @osx ? joinpath(user_homedir(),"Documents") : user_homedir() end @windows_only begin const path_separator = "\\" @@ -23,7 +24,18 @@ end bytestring(m.captures[1]), bytestring(m.captures[2]) end user_homedir() = get(ENV,"HOME",joinpath(ENV["HOMEDRIVE"],ENV["HOMEPATH"])) - user_prefdir() = get(ENV,"HOME",joinpath(ENV["AppData"],"Julia")) + 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 end isabspath(path::String) = ismatch(path_absolute_re, path) diff --git a/base/pkg/dir.jl b/base/pkg/dir.jl index 02ace1ac095e8..92111e37f0f8e 100644 --- a/base/pkg/dir.jl +++ b/base/pkg/dir.jl @@ -3,8 +3,7 @@ module Dir import Base.Git import ..Pkg: DEFAULT_META, META_BRANCH -@unix_only const DIR_NAME = ".julia" -@windows_only const DIR_NAME = "packages" +const DIR_NAME = ".julia" function path() b = abspath(get(ENV,"JULIA_PKGDIR",joinpath(Base.user_prefdir(),DIR_NAME))) diff --git a/ui/repl-readline.c b/ui/repl-readline.c index 2e8e5bbd0863b..6d3538a4d7c2d 100644 --- a/ui/repl-readline.c +++ b/ui/repl-readline.c @@ -21,6 +21,7 @@ #ifdef __WIN32__ # define WIN32_LEAN_AND_MEAN # include +# include #endif extern int asprintf(char **strp, const char *fmt, ...); @@ -58,9 +59,10 @@ static void init_history(void) if (!home) return; asprintf(&history_file, "%s/.julia_history", home); #else - char *home = getenv("AppData"); - if (!home) return; - asprintf(&history_file, "%s/julia/history", home); + char *homedrive = getenv("HOMEDRIVE"); + char *homepath = getenv("HOMEPATH"); + if (!homedrive || !homepath) return; + asprintf(&history_file, "%s/%s/.julia_history", homedrive, homepath); #endif } }