|
8 | 8 | * Copyright (C) 2009 Appcelerator Inc. |
9 | 9 | * Copyright (C) 2009 Brent Fulgham <bfulgham@webkit.org> |
10 | 10 | * Copyright (C) 2013 Peter Gal <galpeter@inf.u-szeged.hu>, University of Szeged |
| 11 | + * Copyright (C) 2013 Alex Christensen <achristensen@webkit.org> |
11 | 12 | * All rights reserved. |
12 | 13 | * |
13 | 14 | * Redistribution and use in source and binary forms, with or without |
|
44 | 45 | #include "ResourceError.h" |
45 | 46 | #include "ResourceHandle.h" |
46 | 47 | #include "ResourceHandleInternal.h" |
| 48 | + |
47 | 49 | #if OS(WINDOWS) |
48 | 50 | #include "WebCoreBundleWin.h" |
| 51 | +#include <shlobj.h> |
| 52 | +#include <shlwapi.h> |
| 53 | +#else |
| 54 | +#include <sys/param.h> |
| 55 | +#define MAX_PATH MAXPATHLEN |
49 | 56 | #endif |
50 | 57 |
|
51 | 58 | #include <errno.h> |
|
57 | 64 | #include <wtf/Vector.h> |
58 | 65 | #include <wtf/text/CString.h> |
59 | 66 |
|
60 | | -#if !OS(WINDOWS) |
61 | | -#include <sys/param.h> |
62 | | -#define MAX_PATH MAXPATHLEN |
63 | | -#endif |
64 | 67 |
|
65 | 68 | namespace WebCore { |
66 | 69 |
|
@@ -96,7 +99,30 @@ static char* cookieJarPath() |
96 | 99 | if (cookieJarPath) |
97 | 100 | return fastStrDup(cookieJarPath); |
98 | 101 |
|
| 102 | +#if OS(WINDOWS) |
| 103 | + char executablePath[MAX_PATH]; |
| 104 | + char appDataDirectory[MAX_PATH]; |
| 105 | + char cookieJarFullPath[MAX_PATH]; |
| 106 | + char cookieJarDirectory[MAX_PATH]; |
| 107 | + |
| 108 | + if (FAILED(::SHGetFolderPathA(0, CSIDL_LOCAL_APPDATA | CSIDL_FLAG_CREATE, 0, 0, appDataDirectory)) |
| 109 | + || FAILED(::GetModuleFileNameA(0, executablePath, MAX_PATH))) |
| 110 | + return fastStrDup("cookies.dat"); |
| 111 | + |
| 112 | + ::PathRemoveExtensionA(executablePath); |
| 113 | + LPSTR executableName = ::PathFindFileNameA(executablePath); |
| 114 | + sprintf_s(cookieJarDirectory, MAX_PATH, "%s/%s", appDataDirectory, executableName); |
| 115 | + sprintf_s(cookieJarFullPath, MAX_PATH, "%s/cookies.dat", cookieJarDirectory); |
| 116 | + |
| 117 | + if (::SHCreateDirectoryExA(0, cookieJarDirectory, 0) != ERROR_SUCCESS |
| 118 | + && ::GetLastError() != ERROR_FILE_EXISTS |
| 119 | + && ::GetLastError() != ERROR_ALREADY_EXISTS) |
| 120 | + return fastStrDup("cookies.dat"); |
| 121 | + |
| 122 | + return fastStrDup(cookieJarFullPath); |
| 123 | +#else |
99 | 124 | return fastStrDup("cookies.dat"); |
| 125 | +#endif |
100 | 126 | } |
101 | 127 |
|
102 | 128 | static Mutex* sharedResourceMutex(curl_lock_data data) { |
|
0 commit comments