On 9/2/07, Dmitry Timoshkov <[EMAIL PROTECTED]> wrote: > "Vincent Povirk" <[EMAIL PROTECTED]> wrote: > > >> Why there is no check for SHCreateDirectoryExW return value? > > The return value of SHCreateDirectoryExW doesn't matter. All that > > matters is whether the directory exists when the function returns. It > > may or may not have existed when the function was called > > (SHCreateDirectoryExW fails when that happens, but > > SHPathPrepareForWrite should not fail). > > > > I could check the SHCreateDirectoryExW return value and probably > > decide on a result based on that, but I think it's better to write the > > result-deciding logic only once. > > By checking return value of SHCreateDirectoryExW you can make a shortcut > in the deciding logic, in both cases: when the function fails you exit > right away (returning *correct* error to the caller and not a guessed one), > in the case of success GetFileAttributes call is redundant and you exit > right away again.
After looking into this a bit more, yes, one of those calls will always be sufficient to do the work and determine what the result should be, at least in the cases I tested. Which one depends on flags and whether the path is relative (to my knowledge no apps actually use relative paths). -- Vincent Povirk