[prev in list] [next in list] [prev in thread] [next in thread]
List: wine-devel
Subject: Re: MakeSureDirectoryPathExists improvement
From: Alexandre Julliard <julliard () winehq ! org>
Date: 2004-09-28 3:01:44
Message-ID: 877jqf2j1j.fsf () mail ! wine ! dyndns ! org
[Download RAW message or body]
Wolfgang Schwotzer <wolfgang.schwotzer@gmx.net> writes:
> @@ -91,13 +91,28 @@
> */
> BOOL WINAPI MakeSureDirectoryPathExists(LPCSTR DirPath)
> {
> - if (CreateDirectoryA(DirPath, NULL)) return TRUE;
> - if (GetLastError() == ERROR_ALREADY_EXISTS)
> + char path[MAX_PATH];
> + const char *p = DirPath;
> + int n;
> +
> + if (strchr(p, ':') != NULL)
> + p = strchr(p, ':');
> + while ((p = strchr(p, '\\')) != NULL)
> {
> - SetLastError(ERROR_SUCCESS);
> - return TRUE;
> + n = p - DirPath + 1;
> + strncpy(path, DirPath, n);
> + path[n] = '\0';
> + if( !CreateDirectoryA(path, NULL) &&
> + (GetLastError() != ERROR_ACCESS_DENIED) &&
> + (GetLastError() != ERROR_ALREADY_EXISTS))
> + return FALSE;
> + p++;
> }
> - return FALSE;
> + if (GetLastError() == ERROR_ACCESS_DENIED ||
> + (GetLastError() == ERROR_ALREADY_EXISTS))
> + SetLastError(ERROR_SUCCESS);
> +
> + return TRUE;
I don't think you want to simply ignore ERROR_ACCESS_DENIED. You
should fix your algorithm to not try to create the drive root and then
ignore only ERROR_ALREADY_EXISTS.
--
Alexandre Julliard
julliard@winehq.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic