| 1 | /*
|
|---|
| 2 | * Path Functions
|
|---|
| 3 | *
|
|---|
| 4 | * Many of this functions are in SHLWAPI.DLL also
|
|---|
| 5 | *
|
|---|
| 6 | */
|
|---|
| 7 | #include <string.h>
|
|---|
| 8 | #include <ctype.h>
|
|---|
| 9 | #include <odin.h>
|
|---|
| 10 |
|
|---|
| 11 | #define ICOM_CINTERFACE 1
|
|---|
| 12 | #define CINTERFACE 1
|
|---|
| 13 |
|
|---|
| 14 | #include "debugtools.h"
|
|---|
| 15 | #include "winnls.h"
|
|---|
| 16 | #include "winversion.h"
|
|---|
| 17 | #include "winreg.h"
|
|---|
| 18 | #include "crtdll.h"
|
|---|
| 19 |
|
|---|
| 20 | #include "shlobj.h"
|
|---|
| 21 | #include "shell32_main.h"
|
|---|
| 22 |
|
|---|
| 23 | #include <misc.h>
|
|---|
| 24 |
|
|---|
| 25 | DEFAULT_DEBUG_CHANNEL(shell)
|
|---|
| 26 |
|
|---|
| 27 | /*************************************************************************
|
|---|
| 28 | * PathIsRoot [SHELL32.29]
|
|---|
| 29 | */
|
|---|
| 30 | BOOL WINAPI PathIsRootA(LPCSTR x)
|
|---|
| 31 | { TRACE("%s\n",x);
|
|---|
| 32 | if (*(x+1)==':' && *(x+2)=='\\') /* "X:\" */
|
|---|
| 33 | return 1;
|
|---|
| 34 | if (*x=='\\') /* "\" */
|
|---|
| 35 | return 0;
|
|---|
| 36 | if (x[0]=='\\' && x[1]=='\\') /* UNC "\\<xx>\" */
|
|---|
| 37 | { int foundbackslash = 0;
|
|---|
| 38 | x=x+2;
|
|---|
| 39 | while (*x)
|
|---|
| 40 | { if (*x++=='\\')
|
|---|
| 41 | foundbackslash++;
|
|---|
| 42 | }
|
|---|
| 43 | if (foundbackslash<=1) /* max 1 \ more ... */
|
|---|
| 44 | return 1;
|
|---|
| 45 | }
|
|---|
| 46 | return 0;
|
|---|
| 47 | }
|
|---|
| 48 | BOOL WINAPI PathIsRootW(LPCWSTR x)
|
|---|
| 49 | { TRACE("%s\n",debugstr_w(x));
|
|---|
| 50 | if (*(x+1)==':' && *(x+2)=='\\') /* "X:\" */
|
|---|
| 51 | return 1;
|
|---|
| 52 | if (*x == (WCHAR) '\\') /* "\" */
|
|---|
| 53 | return 0;
|
|---|
| 54 | if (x[0]==(WCHAR)'\\' && x[1]==(WCHAR)'\\') /* UNC "\\<xx>\" */
|
|---|
| 55 | { int foundbackslash = 0;
|
|---|
| 56 | x=x+2;
|
|---|
| 57 | while (*x)
|
|---|
| 58 | { if (*x++==(WCHAR)'\\')
|
|---|
| 59 | foundbackslash++;
|
|---|
| 60 | }
|
|---|
| 61 | if (foundbackslash<=1) /* max 1 \ more ... */
|
|---|
| 62 | return 1;
|
|---|
| 63 | }
|
|---|
| 64 | return 0;
|
|---|
| 65 | }
|
|---|
| 66 | BOOL WINAPI PathIsRootAW(LPCVOID x)
|
|---|
| 67 | { if (VERSION_OsIsUnicode())
|
|---|
| 68 | return PathIsRootW(x);
|
|---|
| 69 | return PathIsRootA(x);
|
|---|
| 70 |
|
|---|
| 71 | }
|
|---|
| 72 | /*************************************************************************
|
|---|
| 73 | * PathBuildRoot [SHELL32.30]
|
|---|
| 74 | */
|
|---|
| 75 | LPSTR WINAPI PathBuildRootA(LPSTR root,BYTE drive) {
|
|---|
| 76 | TRACE("%p %i\n",root, drive);
|
|---|
| 77 | strcpy(root,"A:\\");
|
|---|
| 78 | root[0]+=drive;
|
|---|
| 79 | return root;
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | /*************************************************************************
|
|---|
| 83 | * PathFindExtension [SHELL32.31]
|
|---|
| 84 | *
|
|---|
| 85 | * NOTES
|
|---|
| 86 | * returns pointer to last . in last pathcomponent or at \0.
|
|---|
| 87 | */
|
|---|
| 88 | LPCSTR WINAPI PathFindExtensionA(LPCSTR path)
|
|---|
| 89 | { LPCSTR lastpoint = NULL;
|
|---|
| 90 | TRACE("%p %s\n",path,path);
|
|---|
| 91 | while (*path)
|
|---|
| 92 | { if (*path=='\\'||*path==' ')
|
|---|
| 93 | lastpoint=NULL;
|
|---|
| 94 | if (*path=='.')
|
|---|
| 95 | lastpoint=path;
|
|---|
| 96 | path++;
|
|---|
| 97 | }
|
|---|
| 98 | return lastpoint?lastpoint:path;
|
|---|
| 99 | }
|
|---|
| 100 | LPCWSTR WINAPI PathFindExtensionW(LPCWSTR path)
|
|---|
| 101 | { LPCWSTR lastpoint = NULL;
|
|---|
| 102 | TRACE("%p L%s\n",path,debugstr_w(path));
|
|---|
| 103 | while (*path)
|
|---|
| 104 | { if (*path==(WCHAR)'\\'||*path==(WCHAR)' ')
|
|---|
| 105 | lastpoint=NULL;
|
|---|
| 106 | if (*path==(WCHAR)'.')
|
|---|
| 107 | lastpoint=path;
|
|---|
| 108 | path++;
|
|---|
| 109 | }
|
|---|
| 110 | return lastpoint?lastpoint:path;
|
|---|
| 111 | }
|
|---|
| 112 | LPCVOID WINAPI PathFindExtensionAW(LPCVOID path)
|
|---|
| 113 | { if (VERSION_OsIsUnicode())
|
|---|
| 114 | return PathFindExtensionW(path);
|
|---|
| 115 | return PathFindExtensionA(path);
|
|---|
| 116 |
|
|---|
| 117 | }
|
|---|
| 118 |
|
|---|
| 119 | /*************************************************************************
|
|---|
| 120 | * PathAddBackslash [SHELL32.32]
|
|---|
| 121 | *
|
|---|
| 122 | * NOTES
|
|---|
| 123 | * append \ if there is none
|
|---|
| 124 | */
|
|---|
| 125 | LPSTR WINAPI PathAddBackslashA(LPSTR path)
|
|---|
| 126 | { int len;
|
|---|
| 127 | TRACE("%p->%s\n",path,path);
|
|---|
| 128 |
|
|---|
| 129 | len = strlen(path);
|
|---|
| 130 | if (len && path[len-1]!='\\')
|
|---|
| 131 | { path[len] = '\\';
|
|---|
| 132 | path[len+1]= 0x00;
|
|---|
| 133 | return path+len+1;
|
|---|
| 134 | }
|
|---|
| 135 | return path+len;
|
|---|
| 136 | }
|
|---|
| 137 | LPWSTR WINAPI PathAddBackslashW(LPWSTR path)
|
|---|
| 138 | { int len;
|
|---|
| 139 | TRACE("%p->%s\n",path,debugstr_w(path));
|
|---|
| 140 |
|
|---|
| 141 | len = CRTDLL_wcslen(path);
|
|---|
| 142 | if (len && path[len-1]!=(WCHAR)'\\')
|
|---|
| 143 | { path[len] = (WCHAR)'\\';
|
|---|
| 144 | path[len+1]= 0x00;
|
|---|
| 145 | return path+len+1;
|
|---|
| 146 | }
|
|---|
| 147 | return path+len;
|
|---|
| 148 | }
|
|---|
| 149 | LPVOID WINAPI PathAddBackslashAW(LPVOID path)
|
|---|
| 150 | { if(VERSION_OsIsUnicode())
|
|---|
| 151 | return PathAddBackslashW(path);
|
|---|
| 152 | return PathAddBackslashA(path);
|
|---|
| 153 | }
|
|---|
| 154 |
|
|---|
| 155 | /*************************************************************************
|
|---|
| 156 | * PathRemoveBlanks [SHELL32.33]
|
|---|
| 157 | *
|
|---|
| 158 | * NOTES
|
|---|
| 159 | * remove spaces from beginning and end of passed string
|
|---|
| 160 | */
|
|---|
| 161 | LPSTR WINAPI PathRemoveBlanksA(LPSTR str)
|
|---|
| 162 | { LPSTR x = str;
|
|---|
| 163 | TRACE("%s\n",str);
|
|---|
| 164 | while (*x==' ') x++;
|
|---|
| 165 | if (x!=str)
|
|---|
| 166 | strcpy(str,x);
|
|---|
| 167 | if (!*str)
|
|---|
| 168 | return str;
|
|---|
| 169 | x=str+strlen(str)-1;
|
|---|
| 170 | while (*x==' ')
|
|---|
| 171 | x--;
|
|---|
| 172 | if (*x==' ')
|
|---|
| 173 | *x='\0';
|
|---|
| 174 | return x;
|
|---|
| 175 | }
|
|---|
| 176 | LPWSTR WINAPI PathRemoveBlanksW(LPWSTR str)
|
|---|
| 177 | { LPWSTR x = str;
|
|---|
| 178 | TRACE("%s\n",debugstr_w(str));
|
|---|
| 179 | while (*x==' ') x++;
|
|---|
| 180 | if (x!=str)
|
|---|
| 181 | CRTDLL_wcscpy(str,x);
|
|---|
| 182 | if (!*str)
|
|---|
| 183 | return str;
|
|---|
| 184 | x=str+CRTDLL_wcslen(str)-1;
|
|---|
| 185 | while (*x==' ')
|
|---|
| 186 | x--;
|
|---|
| 187 | if (*x==' ')
|
|---|
| 188 | *x='\0';
|
|---|
| 189 | return x;
|
|---|
| 190 | }
|
|---|
| 191 | LPVOID WINAPI PathRemoveBlanksAW(LPVOID str)
|
|---|
| 192 | { if(VERSION_OsIsUnicode())
|
|---|
| 193 | return PathRemoveBlanksW(str);
|
|---|
| 194 | return PathRemoveBlanksA(str);
|
|---|
| 195 | }
|
|---|
| 196 |
|
|---|
| 197 |
|
|---|
| 198 |
|
|---|
| 199 | /*************************************************************************
|
|---|
| 200 | * PathFindFilename [SHELL32.34]
|
|---|
| 201 | *
|
|---|
| 202 | * NOTES
|
|---|
| 203 | * basename(char *fn);
|
|---|
| 204 | */
|
|---|
| 205 | LPCSTR WINAPI PathFindFilenameA(LPCSTR aptr)
|
|---|
| 206 | { LPCSTR aslash;
|
|---|
| 207 | aslash = aptr;
|
|---|
| 208 |
|
|---|
| 209 | TRACE("%s\n",aslash);
|
|---|
| 210 | while (aptr[0])
|
|---|
| 211 | { if (((aptr[0]=='\\') || (aptr[0]==':')) && aptr[1] && aptr[1]!='\\')
|
|---|
| 212 | aslash = aptr+1;
|
|---|
| 213 | aptr++;
|
|---|
| 214 | }
|
|---|
| 215 | return aslash;
|
|---|
| 216 |
|
|---|
| 217 | }
|
|---|
| 218 | LPCWSTR WINAPI PathFindFilenameW(LPCWSTR wptr)
|
|---|
| 219 | { LPCWSTR wslash;
|
|---|
| 220 | wslash = wptr;
|
|---|
| 221 |
|
|---|
| 222 | TRACE("L%s\n",debugstr_w(wslash));
|
|---|
| 223 | while (wptr[0])
|
|---|
| 224 | { if (((wptr[0]=='\\') || (wptr[0]==':')) && wptr[1] && wptr[1]!='\\')
|
|---|
| 225 | wslash = wptr+1;
|
|---|
| 226 | wptr++;
|
|---|
| 227 | }
|
|---|
| 228 | return wslash;
|
|---|
| 229 | }
|
|---|
| 230 | LPCVOID WINAPI PathFindFilenameAW(LPCVOID fn)
|
|---|
| 231 | {
|
|---|
| 232 | if(VERSION_OsIsUnicode())
|
|---|
| 233 | return PathFindFilenameW(fn);
|
|---|
| 234 | return PathFindFilenameA(fn);
|
|---|
| 235 | }
|
|---|
| 236 |
|
|---|
| 237 | /*************************************************************************
|
|---|
| 238 | * PathRemoveFileSpec [SHELL32.35]
|
|---|
| 239 | *
|
|---|
| 240 | * NOTES
|
|---|
| 241 | * bool getpath(char *pathname); truncates passed argument to a valid path
|
|---|
| 242 | * returns if the string was modified or not.
|
|---|
| 243 | * "\foo\xx\foo"-> "\foo\xx"
|
|---|
| 244 | * "\" -> "\"
|
|---|
| 245 | * "a:\foo" -> "a:\"
|
|---|
| 246 | */
|
|---|
| 247 | DWORD WINAPI PathRemoveFileSpecA(LPSTR fn) {
|
|---|
| 248 | LPSTR x,cutplace;
|
|---|
| 249 | TRACE("%s\n",fn);
|
|---|
| 250 | if (!fn[0])
|
|---|
| 251 | return 0;
|
|---|
| 252 | x=fn;
|
|---|
| 253 | cutplace = fn;
|
|---|
| 254 | while (*x) {
|
|---|
| 255 | if (*x=='\\') {
|
|---|
| 256 | cutplace=x++;
|
|---|
| 257 | continue;
|
|---|
| 258 | }
|
|---|
| 259 | if (*x==':') {
|
|---|
| 260 | x++;
|
|---|
| 261 | if (*x=='\\')
|
|---|
| 262 | cutplace=++x;
|
|---|
| 263 | continue; /* already x++ed */
|
|---|
| 264 | }
|
|---|
| 265 | x++;
|
|---|
| 266 | }
|
|---|
| 267 | if (!*cutplace)
|
|---|
| 268 | return 0;
|
|---|
| 269 | if (cutplace==fn) {
|
|---|
| 270 | if (fn[0]=='\\') {
|
|---|
| 271 | if (!fn[1])
|
|---|
| 272 | return 0;
|
|---|
| 273 | fn[0]='\0';
|
|---|
| 274 | return 1;
|
|---|
| 275 | }
|
|---|
| 276 | }
|
|---|
| 277 | *cutplace='\0';
|
|---|
| 278 | return 1;
|
|---|
| 279 | }
|
|---|
| 280 |
|
|---|
| 281 | /*************************************************************************
|
|---|
| 282 | * PathAppend [SHELL32.36]
|
|---|
| 283 | *
|
|---|
| 284 | * NOTES
|
|---|
| 285 | * concat_paths(char*target,const char*add);
|
|---|
| 286 | * concats "target\\add" and writes them to target
|
|---|
| 287 | */
|
|---|
| 288 | LPSTR WINAPI PathAppendA(LPSTR x1,LPSTR x2) {
|
|---|
| 289 | TRACE("%s %s\n",x1,x2);
|
|---|
| 290 | while (x2[0]=='\\') x2++;
|
|---|
| 291 | return PathCombineA(x1,x1,x2);
|
|---|
| 292 | }
|
|---|
| 293 |
|
|---|
| 294 | /*************************************************************************
|
|---|
| 295 | * PathCombine [SHELL32.37]
|
|---|
| 296 | *
|
|---|
| 297 | * NOTES
|
|---|
| 298 | * if lpszFile='.' skip it
|
|---|
| 299 | * szDest can be equal to lpszFile. Thats why we use sTemp
|
|---|
| 300 | */
|
|---|
| 301 | LPSTR WINAPI PathCombineA(LPSTR szDest, LPCSTR lpszDir, LPCSTR lpszFile)
|
|---|
| 302 | { char sTemp[MAX_PATH];
|
|---|
| 303 | TRACE("%p %p->%s %p->%s\n",szDest, lpszDir, lpszDir, lpszFile, lpszFile);
|
|---|
| 304 |
|
|---|
| 305 |
|
|---|
| 306 | if (!lpszFile || !lpszFile[0] || (lpszFile[0]=='.' && !lpszFile[1]) )
|
|---|
| 307 | { strcpy(szDest,lpszDir);
|
|---|
| 308 | return szDest;
|
|---|
| 309 | }
|
|---|
| 310 |
|
|---|
| 311 | /* if lpszFile is a complete path don't care about lpszDir */
|
|---|
| 312 | if (PathIsRootA(lpszFile))
|
|---|
| 313 | { strcpy(szDest,lpszFile);
|
|---|
| 314 | }
|
|---|
| 315 | else
|
|---|
| 316 | { strcpy(sTemp,lpszDir);
|
|---|
| 317 | PathAddBackslashA(sTemp);
|
|---|
| 318 | strcat(sTemp,lpszFile);
|
|---|
| 319 | strcpy(szDest,sTemp);
|
|---|
| 320 | }
|
|---|
| 321 | return szDest;
|
|---|
| 322 | }
|
|---|
| 323 | LPWSTR WINAPI PathCombineW(LPWSTR szDest, LPCWSTR lpszDir, LPCWSTR lpszFile)
|
|---|
| 324 | { WCHAR sTemp[MAX_PATH];
|
|---|
| 325 | TRACE("%p %p->%s %p->%s\n",szDest, lpszDir, debugstr_w(lpszDir),
|
|---|
| 326 | lpszFile, debugstr_w(lpszFile));
|
|---|
| 327 |
|
|---|
| 328 |
|
|---|
| 329 | if (!lpszFile || !lpszFile[0] || (lpszFile[0]==(WCHAR)'.' && !lpszFile[1]) )
|
|---|
| 330 | { CRTDLL_wcscpy(szDest,lpszDir);
|
|---|
| 331 | return szDest;
|
|---|
| 332 | }
|
|---|
| 333 |
|
|---|
| 334 | /* if lpszFile is a complete path don't care about lpszDir */
|
|---|
| 335 | if (PathIsRootW(lpszFile))
|
|---|
| 336 | { CRTDLL_wcscpy(szDest,lpszFile);
|
|---|
| 337 | }
|
|---|
| 338 | else
|
|---|
| 339 | { CRTDLL_wcscpy(sTemp,lpszDir);
|
|---|
| 340 | PathAddBackslashW(sTemp);
|
|---|
| 341 | CRTDLL_wcscat(sTemp,lpszFile);
|
|---|
| 342 | CRTDLL_wcscpy(szDest,sTemp);
|
|---|
| 343 | }
|
|---|
| 344 | return szDest;
|
|---|
| 345 | }
|
|---|
| 346 | LPVOID WINAPI PathCombineAW(LPVOID szDest, LPCVOID lpszDir, LPCVOID lpszFile)
|
|---|
| 347 | { if (VERSION_OsIsUnicode())
|
|---|
| 348 | return PathCombineW( szDest, lpszDir, lpszFile );
|
|---|
| 349 | return PathCombineA( szDest, lpszDir, lpszFile );
|
|---|
| 350 | }
|
|---|
| 351 |
|
|---|
| 352 | /*************************************************************************
|
|---|
| 353 | * PathIsUNC [SHELL32.39]
|
|---|
| 354 | *
|
|---|
| 355 | * NOTES
|
|---|
| 356 | * PathIsUNC(char*path);
|
|---|
| 357 | */
|
|---|
| 358 | BOOL WINAPI PathIsUNCA(LPCSTR path)
|
|---|
| 359 | { TRACE("%s\n",path);
|
|---|
| 360 |
|
|---|
| 361 | if ((path[0]=='\\') && (path[1]=='\\'))
|
|---|
| 362 | return TRUE;
|
|---|
| 363 | return FALSE;
|
|---|
| 364 | }
|
|---|
| 365 | BOOL WINAPI PathIsUNCW(LPCWSTR path)
|
|---|
| 366 | { TRACE("%s\n",debugstr_w(path));
|
|---|
| 367 |
|
|---|
| 368 | if ((path[0]=='\\') && (path[1]=='\\'))
|
|---|
| 369 | return TRUE;
|
|---|
| 370 | return FALSE;
|
|---|
| 371 | }
|
|---|
| 372 | BOOL WINAPI PathIsUNCAW (LPCVOID path)
|
|---|
| 373 | { if (VERSION_OsIsUnicode())
|
|---|
| 374 | return PathIsUNCW( path );
|
|---|
| 375 | return PathIsUNCA( path );
|
|---|
| 376 | }
|
|---|
| 377 | /*************************************************************************
|
|---|
| 378 | * PathIsRelativ [SHELL32.40]
|
|---|
| 379 | *
|
|---|
| 380 | */
|
|---|
| 381 | BOOL WINAPI PathIsRelativeA (LPCSTR path)
|
|---|
| 382 | { TRACE("path=%s\n",path);
|
|---|
| 383 |
|
|---|
| 384 | if (path && (path[0]!='\\' && path[1]==':'))
|
|---|
| 385 | return TRUE;
|
|---|
| 386 | return FALSE;
|
|---|
| 387 | }
|
|---|
| 388 | BOOL WINAPI PathIsRelativeW (LPCWSTR path)
|
|---|
| 389 | { TRACE("path=%s\n",debugstr_w(path));
|
|---|
| 390 |
|
|---|
| 391 | if (path && (path[0]!='\\' && path[1]==':'))
|
|---|
| 392 | return TRUE;
|
|---|
| 393 | return FALSE;
|
|---|
| 394 | }
|
|---|
| 395 | BOOL WINAPI PathIsRelativeAW (LPCVOID path)
|
|---|
| 396 | { if (VERSION_OsIsUnicode())
|
|---|
| 397 | return PathIsRelativeW( path );
|
|---|
| 398 | return PathIsRelativeA( path );
|
|---|
| 399 | }
|
|---|
| 400 | /*************************************************************************
|
|---|
| 401 | * PathIsExe [SHELL32.43]
|
|---|
| 402 | *
|
|---|
| 403 | */
|
|---|
| 404 | BOOL WINAPI PathIsExeA (LPCSTR path)
|
|---|
| 405 | { FIXME("path=%s\n",path);
|
|---|
| 406 | return FALSE;
|
|---|
| 407 | }
|
|---|
| 408 | BOOL WINAPI PathIsExeW (LPCWSTR path)
|
|---|
| 409 | { FIXME("path=%s\n",debugstr_w(path));
|
|---|
| 410 | return FALSE;
|
|---|
| 411 | }
|
|---|
| 412 | BOOL WINAPI PathIsExeAW (LPCVOID path)
|
|---|
| 413 | { if (VERSION_OsIsUnicode())
|
|---|
| 414 | return PathIsExeW (path);
|
|---|
| 415 | return PathIsExeA(path);
|
|---|
| 416 | }
|
|---|
| 417 |
|
|---|
| 418 | /*************************************************************************
|
|---|
| 419 | * PathFileExists [SHELL32.45]
|
|---|
| 420 | *
|
|---|
| 421 | * NOTES
|
|---|
| 422 | * file_exists(char *fn);
|
|---|
| 423 | */
|
|---|
| 424 | BOOL WINAPI PathFileExistsA(LPSTR fn) {
|
|---|
| 425 | TRACE("%s\n",fn);
|
|---|
| 426 | if (GetFileAttributesA(fn)==-1)
|
|---|
| 427 | return FALSE;
|
|---|
| 428 | else
|
|---|
| 429 | return TRUE;
|
|---|
| 430 | }
|
|---|
| 431 | /*************************************************************************
|
|---|
| 432 | * PathMatchSpec [SHELL32.46]
|
|---|
| 433 | *
|
|---|
| 434 | * NOTES
|
|---|
| 435 | * used from COMDLG32
|
|---|
| 436 | */
|
|---|
| 437 |
|
|---|
| 438 | BOOL WINAPI PathMatchSpecA(LPCSTR name, LPCSTR mask)
|
|---|
| 439 | { LPCSTR _name;
|
|---|
| 440 |
|
|---|
| 441 | TRACE("%s %s stub\n",name,mask);
|
|---|
| 442 |
|
|---|
| 443 | _name = name;
|
|---|
| 444 | while (*_name && *mask)
|
|---|
| 445 | { if (*mask ==';')
|
|---|
| 446 | { mask++;
|
|---|
| 447 | _name = name;
|
|---|
| 448 | }
|
|---|
| 449 | else if (*mask == '*')
|
|---|
| 450 | { mask++;
|
|---|
| 451 | while (*mask == '*') mask++; /* Skip consecutive '*' */
|
|---|
| 452 | if (!*mask || *mask==';') return TRUE; /* '*' matches everything */
|
|---|
| 453 | while (*_name && (toupper(*_name) != toupper(*mask))) _name++;
|
|---|
| 454 | if (!*_name)
|
|---|
| 455 | { while ( *mask && *mask != ';') mask++;
|
|---|
| 456 | _name = name;
|
|---|
| 457 | }
|
|---|
| 458 | }
|
|---|
| 459 | else if ( (*mask == '?') || (toupper(*mask) == toupper(*_name)) )
|
|---|
| 460 | { mask++;
|
|---|
| 461 | _name++;
|
|---|
| 462 | }
|
|---|
| 463 | else
|
|---|
| 464 | { while ( *mask && *mask != ';') mask++;
|
|---|
| 465 | }
|
|---|
| 466 | }
|
|---|
| 467 | return (!*_name && (!*mask || *mask==';'));
|
|---|
| 468 | }
|
|---|
| 469 | BOOL WINAPI PathMatchSpecW(LPCWSTR name, LPCWSTR mask)
|
|---|
| 470 | { WCHAR stemp[4];
|
|---|
| 471 | LPCWSTR _name;
|
|---|
| 472 |
|
|---|
| 473 | TRACE("%s %s stub\n",debugstr_w(name),debugstr_w(mask));
|
|---|
| 474 |
|
|---|
| 475 | lstrcpyAtoW(stemp,"*.*");
|
|---|
| 476 | if (!lstrcmpW( mask, stemp )) return 1;
|
|---|
| 477 |
|
|---|
| 478 | _name = name;
|
|---|
| 479 | while (*_name && *mask)
|
|---|
| 480 | { if (*mask ==';')
|
|---|
| 481 | { mask++;
|
|---|
| 482 | _name = name;
|
|---|
| 483 | }
|
|---|
| 484 | else if (*mask == '*')
|
|---|
| 485 | { mask++;
|
|---|
| 486 | while (*mask == '*') mask++; /* Skip consecutive '*' */
|
|---|
| 487 | if (!*mask || *mask==';') return TRUE; /* '*' matches everything */
|
|---|
| 488 | while (*_name && (towupper(*_name) != towupper(*mask))) _name++;
|
|---|
| 489 | if (!*_name)
|
|---|
| 490 | { while ( *mask && *mask != ';') mask++;
|
|---|
| 491 | _name = name;
|
|---|
| 492 | }
|
|---|
| 493 | }
|
|---|
| 494 | else if ( (*mask == '?') || (towupper(*mask) == towupper(*_name)) )
|
|---|
| 495 | { mask++;
|
|---|
| 496 | _name++;
|
|---|
| 497 | }
|
|---|
| 498 | else
|
|---|
| 499 | { while ( *mask && *mask != ';') mask++;
|
|---|
| 500 | }
|
|---|
| 501 | }
|
|---|
| 502 | return (!*_name && (!*mask || *mask==';'));
|
|---|
| 503 | }
|
|---|
| 504 | BOOL WINAPI PathMatchSpecAW(LPVOID name, LPVOID mask)
|
|---|
| 505 | { if (VERSION_OsIsUnicode())
|
|---|
| 506 | return PathMatchSpecW( name, mask );
|
|---|
| 507 | return PathMatchSpecA( name, mask );
|
|---|
| 508 | }
|
|---|
| 509 | /*************************************************************************
|
|---|
| 510 | * PathSetDlgItemPathAW [SHELL32.48]
|
|---|
| 511 | * NOTES
|
|---|
| 512 | * use PathCompactPath to make sure, the path fits into the control
|
|---|
| 513 | */
|
|---|
| 514 |
|
|---|
| 515 | BOOL WINAPI PathSetDlgItemPathA(HWND hDlg, int id, LPCSTR pszPath)
|
|---|
| 516 | { TRACE("%x %x %s\n",hDlg, id, pszPath);
|
|---|
| 517 | return SetDlgItemTextA(hDlg, id, pszPath);
|
|---|
| 518 | }
|
|---|
| 519 | BOOL WINAPI PathSetDlgItemPathW(HWND hDlg, int id, LPCWSTR pszPath)
|
|---|
| 520 | { TRACE("%x %x %s\n",hDlg, id, debugstr_w(pszPath));
|
|---|
| 521 | return SetDlgItemTextW(hDlg, id, pszPath);
|
|---|
| 522 | }
|
|---|
| 523 | BOOL WINAPI PathSetDlgItemPathAW(HWND hDlg, int id, LPCVOID pszPath)
|
|---|
| 524 | { if (VERSION_OsIsUnicode())
|
|---|
| 525 | return PathSetDlgItemPathW(hDlg, id, pszPath);
|
|---|
| 526 | return PathSetDlgItemPathA(hDlg, id, pszPath);
|
|---|
| 527 | }
|
|---|
| 528 |
|
|---|
| 529 | /*************************************************************************
|
|---|
| 530 | * PathQualifyAW [SHELL32.49]
|
|---|
| 531 | */
|
|---|
| 532 |
|
|---|
| 533 | BOOL WINAPI PathQualifyA(LPCSTR pszPath)
|
|---|
| 534 | { FIXME("%s\n",pszPath);
|
|---|
| 535 | return 0;
|
|---|
| 536 | }
|
|---|
| 537 | BOOL WINAPI PathQualifyW(LPCWSTR pszPath)
|
|---|
| 538 | { FIXME("%s\n",debugstr_w(pszPath));
|
|---|
| 539 | return 0;
|
|---|
| 540 | }
|
|---|
| 541 | BOOL WINAPI PathQualifyAW(LPCVOID pszPath)
|
|---|
| 542 | { if (VERSION_OsIsUnicode())
|
|---|
| 543 | return PathQualifyW(pszPath);
|
|---|
| 544 | return PathQualifyA(pszPath);
|
|---|
| 545 | }
|
|---|
| 546 |
|
|---|
| 547 | /*************************************************************************
|
|---|
| 548 | * PathResolve [SHELL32.51]
|
|---|
| 549 | */
|
|---|
| 550 | DWORD WINAPI PathResolve(LPCSTR s,DWORD x2,DWORD x3) {
|
|---|
| 551 | FIXME("(%s,0x%08lx,0x%08lx),stub!\n",s,x2,x3);
|
|---|
| 552 | return 0;
|
|---|
| 553 | }
|
|---|
| 554 |
|
|---|
| 555 | /*************************************************************************
|
|---|
| 556 | * PathGetArgs [SHELL32.52]
|
|---|
| 557 | *
|
|---|
| 558 | * NOTES
|
|---|
| 559 | * look for next arg in string. handle "quoted" strings
|
|---|
| 560 | * returns pointer to argument *AFTER* the space. Or to the \0.
|
|---|
| 561 | */
|
|---|
| 562 | LPCSTR WINAPI PathGetArgsA(LPCSTR cmdline)
|
|---|
| 563 | { BOOL qflag = FALSE;
|
|---|
| 564 |
|
|---|
| 565 | TRACE("%s\n",cmdline);
|
|---|
| 566 |
|
|---|
| 567 | while (*cmdline)
|
|---|
| 568 | { if ((*cmdline==' ') && !qflag)
|
|---|
| 569 | return cmdline+1;
|
|---|
| 570 | if (*cmdline=='"')
|
|---|
| 571 | qflag=!qflag;
|
|---|
| 572 | cmdline++;
|
|---|
| 573 | }
|
|---|
| 574 | return cmdline;
|
|---|
| 575 |
|
|---|
| 576 | }
|
|---|
| 577 | LPCWSTR WINAPI PathGetArgsW(LPCWSTR cmdline)
|
|---|
| 578 | { BOOL qflag = FALSE;
|
|---|
| 579 |
|
|---|
| 580 | TRACE("%sL\n",debugstr_w(cmdline));
|
|---|
| 581 |
|
|---|
| 582 | while (*cmdline)
|
|---|
| 583 | { if ((*cmdline==' ') && !qflag)
|
|---|
| 584 | return cmdline+1;
|
|---|
| 585 | if (*cmdline=='"')
|
|---|
| 586 | qflag=!qflag;
|
|---|
| 587 | cmdline++;
|
|---|
| 588 | }
|
|---|
| 589 | return cmdline;
|
|---|
| 590 | }
|
|---|
| 591 | LPCVOID WINAPI PathGetArgsAW(LPVOID cmdline)
|
|---|
| 592 | { if (VERSION_OsIsUnicode())
|
|---|
| 593 | return PathGetArgsW(cmdline);
|
|---|
| 594 | return PathGetArgsA(cmdline);
|
|---|
| 595 | }
|
|---|
| 596 | /*************************************************************************
|
|---|
| 597 | * PathQuoteSpaces [SHELL32.55]
|
|---|
| 598 | *
|
|---|
| 599 | * NOTES
|
|---|
| 600 | * basename(char *fn);
|
|---|
| 601 | */
|
|---|
| 602 | LPSTR WINAPI PathQuoteSpacesA(LPCSTR aptr)
|
|---|
| 603 | { FIXME("%s\n",aptr);
|
|---|
| 604 | return 0;
|
|---|
| 605 |
|
|---|
| 606 | }
|
|---|
| 607 | LPWSTR WINAPI PathQuoteSpacesW(LPCWSTR wptr)
|
|---|
| 608 | { FIXME("L%s\n",debugstr_w(wptr));
|
|---|
| 609 | return 0;
|
|---|
| 610 | }
|
|---|
| 611 | LPVOID WINAPI PathQuoteSpacesAW (LPCVOID fn)
|
|---|
| 612 | { if(VERSION_OsIsUnicode())
|
|---|
| 613 | return PathQuoteSpacesW(fn);
|
|---|
| 614 | return PathQuoteSpacesA(fn);
|
|---|
| 615 | }
|
|---|
| 616 |
|
|---|
| 617 |
|
|---|
| 618 | /*************************************************************************
|
|---|
| 619 | * PathUnquoteSpaces [SHELL32.56]
|
|---|
| 620 | *
|
|---|
| 621 | * NOTES
|
|---|
| 622 | * unquote string (remove ")
|
|---|
| 623 | */
|
|---|
| 624 | VOID WINAPI PathUnquoteSpacesA(LPSTR str)
|
|---|
| 625 | { DWORD len = lstrlenA(str);
|
|---|
| 626 | TRACE("%s\n",str);
|
|---|
| 627 | if (*str!='"')
|
|---|
| 628 | return;
|
|---|
| 629 | if (str[len-1]!='"')
|
|---|
| 630 | return;
|
|---|
| 631 | str[len-1]='\0';
|
|---|
| 632 | lstrcpyA(str,str+1);
|
|---|
| 633 | return;
|
|---|
| 634 | }
|
|---|
| 635 | VOID WINAPI PathUnquoteSpacesW(LPWSTR str)
|
|---|
| 636 | { DWORD len = CRTDLL_wcslen(str);
|
|---|
| 637 |
|
|---|
| 638 | TRACE("%s\n",debugstr_w(str));
|
|---|
| 639 |
|
|---|
| 640 | if (*str!='"')
|
|---|
| 641 | return;
|
|---|
| 642 | if (str[len-1]!='"')
|
|---|
| 643 | return;
|
|---|
| 644 | str[len-1]='\0';
|
|---|
| 645 | CRTDLL_wcscpy(str,str+1);
|
|---|
| 646 | return;
|
|---|
| 647 | }
|
|---|
| 648 | VOID WINAPI PathUnquoteSpacesAW(LPVOID str)
|
|---|
| 649 | { if(VERSION_OsIsUnicode())
|
|---|
| 650 | PathUnquoteSpacesW(str);
|
|---|
| 651 | PathUnquoteSpacesA(str);
|
|---|
| 652 | }
|
|---|
| 653 |
|
|---|
| 654 |
|
|---|
| 655 | /*************************************************************************
|
|---|
| 656 | * PathGetDriveNumber32 [SHELL32.57]
|
|---|
| 657 | *
|
|---|
| 658 | */
|
|---|
| 659 | HRESULT WINAPI PathGetDriveNumber(LPSTR u)
|
|---|
| 660 | { FIXME("%s stub\n",debugstr_a(u));
|
|---|
| 661 | return 0;
|
|---|
| 662 | }
|
|---|
| 663 |
|
|---|
| 664 | /*************************************************************************
|
|---|
| 665 | * PathYetAnotherMakeUniqueName [SHELL32.75]
|
|---|
| 666 | *
|
|---|
| 667 | * NOTES
|
|---|
| 668 | * exported by ordinal
|
|---|
| 669 | */
|
|---|
| 670 | BOOL WINAPI PathYetAnotherMakeUniqueNameA(LPDWORD x,LPDWORD y) {
|
|---|
| 671 | FIXME("(%p,%p):stub.\n",x,y);
|
|---|
| 672 | return TRUE;
|
|---|
| 673 | }
|
|---|
| 674 |
|
|---|
| 675 | /*************************************************************************
|
|---|
| 676 | * IsLFNDrive [SHELL32.119]
|
|---|
| 677 | *
|
|---|
| 678 | * NOTES
|
|---|
| 679 | * exported by ordinal Name
|
|---|
| 680 | */
|
|---|
| 681 | BOOL WINAPI IsLFNDriveA(LPCSTR path) {
|
|---|
| 682 | DWORD fnlen;
|
|---|
| 683 |
|
|---|
| 684 | if (!GetVolumeInformationA(path,NULL,0,NULL,&fnlen,NULL,NULL,0))
|
|---|
| 685 | return FALSE;
|
|---|
| 686 | return fnlen>12;
|
|---|
| 687 | }
|
|---|
| 688 | /*************************************************************************
|
|---|
| 689 | * PathFindOnPath [SHELL32.145]
|
|---|
| 690 | */
|
|---|
| 691 | BOOL WINAPI PathFindOnPathA(LPSTR sFile, LPCSTR sOtherDirs)
|
|---|
| 692 | { FIXME("%s %s\n",sFile, sOtherDirs);
|
|---|
| 693 | return FALSE;
|
|---|
| 694 | }
|
|---|
| 695 | BOOL WINAPI PathFindOnPathW(LPWSTR sFile, LPCWSTR sOtherDirs)
|
|---|
| 696 | { FIXME("%s %s\n",debugstr_w(sFile), debugstr_w(sOtherDirs));
|
|---|
| 697 | return FALSE;
|
|---|
| 698 | }
|
|---|
| 699 | BOOL WINAPI PathFindOnPathAW(LPVOID sFile, LPCVOID sOtherDirs)
|
|---|
| 700 | { if (VERSION_OsIsUnicode())
|
|---|
| 701 | return PathFindOnPathW(sFile, sOtherDirs);
|
|---|
| 702 | return PathFindOnPathA(sFile, sOtherDirs);
|
|---|
| 703 | }
|
|---|
| 704 |
|
|---|
| 705 | /*************************************************************************
|
|---|
| 706 | * PathGetExtension [SHELL32.158]
|
|---|
| 707 | *
|
|---|
| 708 | * NOTES
|
|---|
| 709 | * exported by ordinal
|
|---|
| 710 | */
|
|---|
| 711 | LPCSTR WINAPI PathGetExtensionA(LPCSTR path,DWORD y,DWORD z)
|
|---|
| 712 | { TRACE("(%s,%08lx,%08lx)\n",path,y,z);
|
|---|
| 713 | path = PathFindExtensionA(path);
|
|---|
| 714 | return *path?(path+1):path;
|
|---|
| 715 | }
|
|---|
| 716 | LPCWSTR WINAPI PathGetExtensionW(LPCWSTR path,DWORD y,DWORD z)
|
|---|
| 717 | { TRACE("(L%s,%08lx,%08lx)\n",debugstr_w(path),y,z);
|
|---|
| 718 | path = PathFindExtensionW(path);
|
|---|
| 719 | return *path?(path+1):path;
|
|---|
| 720 | }
|
|---|
| 721 | LPCVOID WINAPI PathGetExtensionAW(LPCVOID path,DWORD y,DWORD z)
|
|---|
| 722 | { if (VERSION_OsIsUnicode())
|
|---|
| 723 | return PathGetExtensionW(path,y,z);
|
|---|
| 724 | return PathGetExtensionA(path,y,z);
|
|---|
| 725 | }
|
|---|
| 726 |
|
|---|
| 727 | /*************************************************************************
|
|---|
| 728 | * PathCleanupSpec [SHELL32.171]
|
|---|
| 729 | *
|
|---|
| 730 | */
|
|---|
| 731 | DWORD WINAPI PathCleanupSpecA(LPSTR x, LPSTR y)
|
|---|
| 732 | {
|
|---|
| 733 | FIXME("%p(%s) %p(%s) stub\n",x,x,y,y);
|
|---|
| 734 | return TRUE;
|
|---|
| 735 | }
|
|---|
| 736 |
|
|---|
| 737 | DWORD WINAPI PathCleanupSpecW(LPWSTR x, LPWSTR y)
|
|---|
| 738 | {
|
|---|
| 739 | FIXME("%p(%s) %p(%s) stub\n",x,debugstr_w(x),y,debugstr_w(y));
|
|---|
| 740 | return TRUE;
|
|---|
| 741 | }
|
|---|
| 742 |
|
|---|
| 743 | DWORD WINAPI PathCleanupSpecAW (LPVOID x, LPVOID y)
|
|---|
| 744 | {
|
|---|
| 745 | if (VERSION_OsIsUnicode())
|
|---|
| 746 | return PathCleanupSpecW(x,y);
|
|---|
| 747 | return PathCleanupSpecA(x,y);
|
|---|
| 748 | }
|
|---|
| 749 |
|
|---|
| 750 | /*************************************************************************
|
|---|
| 751 | * SheGetDirW [SHELL32.281]
|
|---|
| 752 | *
|
|---|
| 753 | */
|
|---|
| 754 | HRESULT WINAPI SheGetDirW(LPWSTR u, LPWSTR v)
|
|---|
| 755 | { FIXME("%p %p stub\n",u,v);
|
|---|
| 756 | return 0;
|
|---|
| 757 | }
|
|---|
| 758 |
|
|---|
| 759 | /*************************************************************************
|
|---|
| 760 | * SheChangeDirW [SHELL32.274]
|
|---|
| 761 | *
|
|---|
| 762 | */
|
|---|
| 763 | HRESULT WINAPI SheChangeDirW(LPWSTR u)
|
|---|
| 764 | { FIXME("(%s),stub\n",debugstr_w(u));
|
|---|
| 765 | return 0;
|
|---|
| 766 | }
|
|---|
| 767 |
|
|---|
| 768 | /*************************************************************************
|
|---|
| 769 | * PathProcessCommand [SHELL32.653]
|
|---|
| 770 | */
|
|---|
| 771 | HRESULT WINAPI PathProcessCommandA (LPSTR lpCommand, LPSTR v, DWORD w, DWORD x)
|
|---|
| 772 | {
|
|---|
| 773 | FIXME("%p(%s) %p 0x%04lx 0x%04lx stub\n",
|
|---|
| 774 | lpCommand, lpCommand, v, w,x );
|
|---|
| 775 | return 0;
|
|---|
| 776 | }
|
|---|
| 777 |
|
|---|
| 778 | HRESULT WINAPI PathProcessCommandW (LPWSTR lpCommand, LPSTR v, DWORD w, DWORD x)
|
|---|
| 779 | {
|
|---|
| 780 | FIXME("%p(%s) %p 0x%04lx 0x%04lx stub\n",
|
|---|
| 781 | lpCommand, debugstr_w(lpCommand), v, w,x );
|
|---|
| 782 | return 0;
|
|---|
| 783 | }
|
|---|
| 784 |
|
|---|
| 785 | HRESULT WINAPI PathProcessCommandAW (LPVOID lpCommand, LPSTR v, DWORD w, DWORD x)
|
|---|
| 786 | {
|
|---|
| 787 | if (VERSION_OsIsUnicode())
|
|---|
| 788 | return PathProcessCommandW(lpCommand, v, w, x);
|
|---|
| 789 | return PathProcessCommandA(lpCommand, v, w, x);
|
|---|
| 790 | }
|
|---|
| 791 |
|
|---|
| 792 | /*************************************************************************
|
|---|
| 793 | * SHGetSpecialFolderPath [SHELL32.175]
|
|---|
| 794 | *
|
|---|
| 795 | * converts csidl to path
|
|---|
| 796 | *
|
|---|
| 797 | */
|
|---|
| 798 |
|
|---|
| 799 | static char * szSHFolders = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders";
|
|---|
| 800 |
|
|---|
| 801 | BOOL WINAPI SHGetSpecialFolderPathA (
|
|---|
| 802 | HWND hwndOwner,
|
|---|
| 803 | LPSTR szPath,
|
|---|
| 804 | DWORD csidl,
|
|---|
| 805 | BOOL bCreate)
|
|---|
| 806 | {
|
|---|
| 807 | CHAR szValueName[MAX_PATH], szDefaultPath[MAX_PATH];
|
|---|
| 808 | HKEY hRootKey, hKey;
|
|---|
| 809 | BOOL bRelative = TRUE;
|
|---|
| 810 | DWORD dwType, dwDisp, dwPathLen = MAX_PATH;
|
|---|
| 811 |
|
|---|
| 812 | TRACE("0x%04x,%p,csidl=%lu,0x%04x\n", hwndOwner,szPath,csidl,bCreate);
|
|---|
| 813 |
|
|---|
| 814 | /* build default values */
|
|---|
| 815 | switch(csidl)
|
|---|
| 816 | {
|
|---|
| 817 | case CSIDL_APPDATA:
|
|---|
| 818 | hRootKey = HKEY_CURRENT_USER;
|
|---|
| 819 | strcpy (szValueName, "AppData");
|
|---|
| 820 | strcpy (szDefaultPath, "AppData");
|
|---|
| 821 | break;
|
|---|
| 822 |
|
|---|
| 823 | case CSIDL_COOKIES:
|
|---|
| 824 | hRootKey = HKEY_CURRENT_USER;
|
|---|
| 825 | strcpy (szValueName, "Cookies");
|
|---|
| 826 | strcpy(szDefaultPath, "Cookies");
|
|---|
| 827 | break;
|
|---|
| 828 |
|
|---|
| 829 | case CSIDL_DESKTOPDIRECTORY:
|
|---|
| 830 | hRootKey = HKEY_CURRENT_USER;
|
|---|
| 831 | strcpy(szValueName, "Desktop");
|
|---|
| 832 | strcpy(szDefaultPath, "Desktop");
|
|---|
| 833 | break;
|
|---|
| 834 |
|
|---|
| 835 | case CSIDL_COMMON_DESKTOPDIRECTORY:
|
|---|
| 836 | hRootKey = HKEY_LOCAL_MACHINE;
|
|---|
| 837 | strcpy(szValueName, "Common Desktop");
|
|---|
| 838 | strcpy(szDefaultPath, "Desktop");
|
|---|
| 839 | break;
|
|---|
| 840 |
|
|---|
| 841 | case CSIDL_FAVORITES:
|
|---|
| 842 | hRootKey = HKEY_CURRENT_USER;
|
|---|
| 843 | strcpy(szValueName, "Favorites");
|
|---|
| 844 | strcpy(szDefaultPath, "Favorites");
|
|---|
| 845 | break;
|
|---|
| 846 |
|
|---|
| 847 | case CSIDL_FONTS:
|
|---|
| 848 | hRootKey = HKEY_CURRENT_USER;
|
|---|
| 849 | strcpy(szValueName, "Fonts");
|
|---|
| 850 | strcpy(szDefaultPath, "Fonts");
|
|---|
| 851 | break;
|
|---|
| 852 |
|
|---|
| 853 | case CSIDL_HISTORY:
|
|---|
| 854 | hRootKey = HKEY_CURRENT_USER;
|
|---|
| 855 | strcpy(szValueName, "History");
|
|---|
| 856 | strcpy(szDefaultPath, "History");
|
|---|
| 857 | break;
|
|---|
| 858 |
|
|---|
| 859 | case CSIDL_NETHOOD:
|
|---|
| 860 | hRootKey = HKEY_CURRENT_USER;
|
|---|
| 861 | strcpy(szValueName, "NetHood");
|
|---|
| 862 | strcpy(szDefaultPath, "NetHood");
|
|---|
| 863 | break;
|
|---|
| 864 |
|
|---|
| 865 | case CSIDL_INTERNET_CACHE:
|
|---|
| 866 | hRootKey = HKEY_CURRENT_USER;
|
|---|
| 867 | strcpy(szValueName, "Cache");
|
|---|
| 868 | strcpy(szDefaultPath, "Temporary Internet Files");
|
|---|
| 869 | break;
|
|---|
| 870 |
|
|---|
| 871 | case CSIDL_PERSONAL:
|
|---|
| 872 | hRootKey = HKEY_CURRENT_USER;
|
|---|
| 873 | strcpy(szValueName, "Personal");
|
|---|
| 874 | strcpy(szDefaultPath, "My Own Files");
|
|---|
| 875 | bRelative = FALSE;
|
|---|
| 876 | break;
|
|---|
| 877 |
|
|---|
| 878 | case CSIDL_PRINTHOOD:
|
|---|
| 879 | hRootKey = HKEY_CURRENT_USER;
|
|---|
| 880 | strcpy(szValueName, "PrintHood");
|
|---|
| 881 | strcpy(szDefaultPath, "PrintHood");
|
|---|
| 882 | break;
|
|---|
| 883 |
|
|---|
| 884 | case CSIDL_PROGRAMS:
|
|---|
| 885 | hRootKey = HKEY_CURRENT_USER;
|
|---|
| 886 | strcpy(szValueName, "Programs");
|
|---|
| 887 | strcpy(szDefaultPath, "StatrMenu\\Programs");
|
|---|
| 888 | break;
|
|---|
| 889 |
|
|---|
| 890 | case CSIDL_COMMON_PROGRAMS:
|
|---|
| 891 | hRootKey = HKEY_LOCAL_MACHINE;
|
|---|
| 892 | strcpy(szValueName, "Common Programs");
|
|---|
| 893 | strcpy(szDefaultPath, "");
|
|---|
| 894 | break;
|
|---|
| 895 |
|
|---|
| 896 | case CSIDL_RECENT:
|
|---|
| 897 | hRootKey = HKEY_CURRENT_USER;
|
|---|
| 898 | strcpy(szValueName, "Recent");
|
|---|
| 899 | strcpy(szDefaultPath, "Recent");
|
|---|
| 900 | break;
|
|---|
| 901 |
|
|---|
| 902 | case CSIDL_SENDTO:
|
|---|
| 903 | hRootKey = HKEY_CURRENT_USER;
|
|---|
| 904 | strcpy(szValueName, "SendTo");
|
|---|
| 905 | strcpy(szDefaultPath, "SendTo");
|
|---|
| 906 | break;
|
|---|
| 907 |
|
|---|
| 908 | case CSIDL_STARTMENU:
|
|---|
| 909 | hRootKey = HKEY_CURRENT_USER;
|
|---|
| 910 | strcpy(szValueName, "StartMenu");
|
|---|
| 911 | strcpy(szDefaultPath, "StartMenu");
|
|---|
| 912 | break;
|
|---|
| 913 |
|
|---|
| 914 | case CSIDL_COMMON_STARTMENU:
|
|---|
| 915 | hRootKey = HKEY_LOCAL_MACHINE;
|
|---|
| 916 | strcpy(szValueName, "Common StartMenu");
|
|---|
| 917 | strcpy(szDefaultPath, "StartMenu");
|
|---|
| 918 | break;
|
|---|
| 919 |
|
|---|
| 920 | case CSIDL_STARTUP:
|
|---|
| 921 | hRootKey = HKEY_CURRENT_USER;
|
|---|
| 922 | strcpy(szValueName, "Startup");
|
|---|
| 923 | strcpy(szDefaultPath, "StartMenu\\Programs\\Startup");
|
|---|
| 924 | break;
|
|---|
| 925 |
|
|---|
| 926 | case CSIDL_COMMON_STARTUP:
|
|---|
| 927 | hRootKey = HKEY_LOCAL_MACHINE;
|
|---|
| 928 | strcpy(szValueName, "Common Startup");
|
|---|
| 929 | strcpy(szDefaultPath, "StartMenu\\Programs\\Startup");
|
|---|
| 930 | break;
|
|---|
| 931 |
|
|---|
| 932 | case CSIDL_TEMPLATES:
|
|---|
| 933 | hRootKey = HKEY_CURRENT_USER;
|
|---|
| 934 | strcpy(szValueName, "Templates");
|
|---|
| 935 | strcpy(szDefaultPath, "ShellNew");
|
|---|
| 936 | break;
|
|---|
| 937 |
|
|---|
| 938 | default:
|
|---|
| 939 | ERR("folder unknown or not allowed\n");
|
|---|
| 940 | return FALSE;
|
|---|
| 941 | }
|
|---|
| 942 |
|
|---|
| 943 | if (RegCreateKeyExA(hRootKey,szSHFolders,0,NULL,REG_OPTION_NON_VOLATILE,KEY_WRITE,NULL,&hKey,&dwDisp))
|
|---|
| 944 | {
|
|---|
| 945 | return FALSE;
|
|---|
| 946 | }
|
|---|
| 947 |
|
|---|
| 948 | if (RegQueryValueExA(hKey,szValueName,NULL,&dwType,(LPBYTE)szPath,&dwPathLen))
|
|---|
| 949 | {
|
|---|
| 950 | /* value not existing */
|
|---|
| 951 | if (bRelative)
|
|---|
| 952 | {
|
|---|
| 953 | GetWindowsDirectoryA(szPath, MAX_PATH);
|
|---|
| 954 | PathAddBackslashA(szPath);
|
|---|
| 955 | strcat(szPath, szDefaultPath);
|
|---|
| 956 | }
|
|---|
| 957 | else
|
|---|
| 958 | {
|
|---|
| 959 | strcpy(szPath, szDefaultPath);
|
|---|
| 960 | }
|
|---|
| 961 | if (bCreate)
|
|---|
| 962 | {
|
|---|
| 963 | CreateDirectoryA(szPath,NULL);
|
|---|
| 964 | }
|
|---|
| 965 | RegSetValueExA(hKey,szValueName,0,REG_SZ,(LPBYTE)szPath,strlen(szPath)+1);
|
|---|
| 966 | }
|
|---|
| 967 | RegCloseKey(hKey);
|
|---|
| 968 |
|
|---|
| 969 | return TRUE;
|
|---|
| 970 | }
|
|---|
| 971 | BOOL WINAPI SHGetSpecialFolderPathW (
|
|---|
| 972 | HWND hwndOwner,
|
|---|
| 973 | LPWSTR szPath,
|
|---|
| 974 | DWORD csidl,
|
|---|
| 975 | BOOL bCreate)
|
|---|
| 976 | {
|
|---|
| 977 | char szTemp[MAX_PATH];
|
|---|
| 978 |
|
|---|
| 979 | if (SHGetSpecialFolderPathA(hwndOwner, szTemp, csidl, bCreate))
|
|---|
| 980 | {
|
|---|
| 981 | lstrcpynAtoW(szPath, szTemp, MAX_PATH);
|
|---|
| 982 | }
|
|---|
| 983 |
|
|---|
| 984 | TRACE("0x%04x,%p,csidl=%lu,0x%04x\n", hwndOwner,szPath,csidl,bCreate);
|
|---|
| 985 |
|
|---|
| 986 | return TRUE;
|
|---|
| 987 | }
|
|---|
| 988 | BOOL WINAPI SHGetSpecialFolderPathAW (
|
|---|
| 989 | HWND hwndOwner,
|
|---|
| 990 | LPVOID szPath,
|
|---|
| 991 | DWORD csidl,
|
|---|
| 992 | BOOL bCreate)
|
|---|
| 993 |
|
|---|
| 994 | {
|
|---|
| 995 | if (VERSION_OsIsUnicode())
|
|---|
| 996 | return SHGetSpecialFolderPathW (hwndOwner, szPath, csidl, bCreate);
|
|---|
| 997 | return SHGetSpecialFolderPathA (hwndOwner, szPath, csidl, bCreate);
|
|---|
| 998 | }
|
|---|