Skip to content

Commit a963262

Browse files
committed
Merge branch 'jn/mydocuments'
2 parents 14feaa0 + f291b85 commit a963262

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

base/path.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
splitdrive(path::String) = ("",path)
1010
user_homedir() = ENV["HOME"]
1111
user_prefdir() = user_homedir()
12+
user_documentsdir() = @osx ? joinpath(user_homedir(),"Documents") : user_homedir()
1213
end
1314
@windows_only begin
1415
const path_separator = "\\"
@@ -23,7 +24,18 @@ end
2324
bytestring(m.captures[1]), bytestring(m.captures[2])
2425
end
2526
user_homedir() = get(ENV,"HOME",joinpath(ENV["HOMEDRIVE"],ENV["HOMEPATH"]))
26-
user_prefdir() = get(ENV,"HOME",joinpath(ENV["AppData"],"Julia"))
27+
user_prefdir() = user_homedir()
28+
function user_documentsdir()
29+
#HRESULT result = SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, my_documents);
30+
path = Array(Uint8,260)
31+
result = ccall((:SHGetFolderPathA,:shell32),stdcall,Cint,
32+
(Ptr{Void},Cint,Ptr{Void},Cint,Ptr{Uint8}),0,0x0005,0,0,path)
33+
if result == 0
34+
return bytestring(path[1:findfirst(path,0)-1])
35+
else
36+
return user_homedir()
37+
end
38+
end
2739
end
2840

2941
isabspath(path::String) = ismatch(path_absolute_re, path)

base/pkg/dir.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ module Dir
33
import Base.Git
44
import ..Pkg: DEFAULT_META, META_BRANCH
55

6-
@unix_only const DIR_NAME = ".julia"
7-
@windows_only const DIR_NAME = "packages"
6+
const DIR_NAME = ".julia"
87

98
function path()
109
b = abspath(get(ENV,"JULIA_PKGDIR",joinpath(Base.user_prefdir(),DIR_NAME)))

ui/repl-readline.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#ifdef __WIN32__
2222
# define WIN32_LEAN_AND_MEAN
2323
# include <windows.h>
24+
# include <shlobj.h>
2425
#endif
2526

2627
extern int asprintf(char **strp, const char *fmt, ...);
@@ -58,9 +59,10 @@ static void init_history(void)
5859
if (!home) return;
5960
asprintf(&history_file, "%s/.julia_history", home);
6061
#else
61-
char *home = getenv("AppData");
62-
if (!home) return;
63-
asprintf(&history_file, "%s/julia/history", home);
62+
char *homedrive = getenv("HOMEDRIVE");
63+
char *homepath = getenv("HOMEPATH");
64+
if (!homedrive || !homepath) return;
65+
asprintf(&history_file, "%s/%s/.julia_history", homedrive, homepath);
6466
#endif
6567
}
6668
}

0 commit comments

Comments
 (0)