diff options
Diffstat (limited to 'src/dutil/uncutil.cpp')
| -rw-r--r-- | src/dutil/uncutil.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/dutil/uncutil.cpp b/src/dutil/uncutil.cpp index 6deb43bd..415ea198 100644 --- a/src/dutil/uncutil.cpp +++ b/src/dutil/uncutil.cpp | |||
| @@ -2,6 +2,21 @@ | |||
| 2 | 2 | ||
| 3 | #include "precomp.h" | 3 | #include "precomp.h" |
| 4 | 4 | ||
| 5 | |||
| 6 | // Exit macros | ||
| 7 | #define UncExitOnLastError(x, s, ...) ExitOnLastErrorSource(DUTIL_SOURCE_UNCUTIL, x, s, __VA_ARGS__) | ||
| 8 | #define UncExitOnLastErrorDebugTrace(x, s, ...) ExitOnLastErrorDebugTraceSource(DUTIL_SOURCE_UNCUTIL, x, s, __VA_ARGS__) | ||
| 9 | #define UncExitWithLastError(x, s, ...) ExitWithLastErrorSource(DUTIL_SOURCE_UNCUTIL, x, s, __VA_ARGS__) | ||
| 10 | #define UncExitOnFailure(x, s, ...) ExitOnFailureSource(DUTIL_SOURCE_UNCUTIL, x, s, __VA_ARGS__) | ||
| 11 | #define UncExitOnRootFailure(x, s, ...) ExitOnRootFailureSource(DUTIL_SOURCE_UNCUTIL, x, s, __VA_ARGS__) | ||
| 12 | #define UncExitOnFailureDebugTrace(x, s, ...) ExitOnFailureDebugTraceSource(DUTIL_SOURCE_UNCUTIL, x, s, __VA_ARGS__) | ||
| 13 | #define UncExitOnNull(p, x, e, s, ...) ExitOnNullSource(DUTIL_SOURCE_UNCUTIL, p, x, e, s, __VA_ARGS__) | ||
| 14 | #define UncExitOnNullWithLastError(p, x, s, ...) ExitOnNullWithLastErrorSource(DUTIL_SOURCE_UNCUTIL, p, x, s, __VA_ARGS__) | ||
| 15 | #define UncExitOnNullDebugTrace(p, x, e, s, ...) ExitOnNullDebugTraceSource(DUTIL_SOURCE_UNCUTIL, p, x, e, s, __VA_ARGS__) | ||
| 16 | #define UncExitOnInvalidHandleWithLastError(p, x, s, ...) ExitOnInvalidHandleWithLastErrorSource(DUTIL_SOURCE_UNCUTIL, p, x, s, __VA_ARGS__) | ||
| 17 | #define UncExitOnWin32Error(e, x, s, ...) ExitOnWin32ErrorSource(DUTIL_SOURCE_UNCUTIL, e, x, s, __VA_ARGS__) | ||
| 18 | #define UncExitOnGdipFailure(g, x, s, ...) ExitOnGdipFailureSource(DUTIL_SOURCE_UNCUTIL, g, x, s, __VA_ARGS__) | ||
| 19 | |||
| 5 | DAPI_(HRESULT) UncConvertFromMountedDrive( | 20 | DAPI_(HRESULT) UncConvertFromMountedDrive( |
| 6 | __inout LPWSTR *psczUNCPath, | 21 | __inout LPWSTR *psczUNCPath, |
| 7 | __in LPCWSTR sczMountedDrivePath | 22 | __in LPCWSTR sczMountedDrivePath |
| @@ -14,7 +29,7 @@ DAPI_(HRESULT) UncConvertFromMountedDrive( | |||
| 14 | 29 | ||
| 15 | // Only copy drive letter and colon | 30 | // Only copy drive letter and colon |
| 16 | hr = StrAllocString(&sczDrive, sczMountedDrivePath, 2); | 31 | hr = StrAllocString(&sczDrive, sczMountedDrivePath, 2); |
| 17 | ExitOnFailure(hr, "Failed to copy drive"); | 32 | UncExitOnFailure(hr, "Failed to copy drive"); |
| 18 | 33 | ||
| 19 | // ERROR_NOT_CONNECTED means it's not a mapped drive | 34 | // ERROR_NOT_CONNECTED means it's not a mapped drive |
| 20 | er = ::WNetGetConnectionW(sczDrive, NULL, &dwLength); | 35 | er = ::WNetGetConnectionW(sczDrive, NULL, &dwLength); |
| @@ -23,7 +38,7 @@ DAPI_(HRESULT) UncConvertFromMountedDrive( | |||
| 23 | er = ERROR_SUCCESS; | 38 | er = ERROR_SUCCESS; |
| 24 | 39 | ||
| 25 | hr = StrAlloc(psczUNCPath, dwLength); | 40 | hr = StrAlloc(psczUNCPath, dwLength); |
| 26 | ExitOnFailure(hr, "Failed to allocate string to get raw UNC path of length %u", dwLength); | 41 | UncExitOnFailure(hr, "Failed to allocate string to get raw UNC path of length %u", dwLength); |
| 27 | 42 | ||
| 28 | er = ::WNetGetConnectionW(sczDrive, *psczUNCPath, &dwLength); | 43 | er = ::WNetGetConnectionW(sczDrive, *psczUNCPath, &dwLength); |
| 29 | if (ERROR_CONNECTION_UNAVAIL == er) | 44 | if (ERROR_CONNECTION_UNAVAIL == er) |
| @@ -31,11 +46,11 @@ DAPI_(HRESULT) UncConvertFromMountedDrive( | |||
| 31 | // This means the drive is remembered but not currently connected, this can mean the location is accessible via UNC path but not via mounted drive path | 46 | // This means the drive is remembered but not currently connected, this can mean the location is accessible via UNC path but not via mounted drive path |
| 32 | er = ERROR_SUCCESS; | 47 | er = ERROR_SUCCESS; |
| 33 | } | 48 | } |
| 34 | ExitOnWin32Error(er, hr, "::WNetGetConnectionW() failed with buffer provided on drive %ls", sczDrive); | 49 | UncExitOnWin32Error(er, hr, "::WNetGetConnectionW() failed with buffer provided on drive %ls", sczDrive); |
| 35 | 50 | ||
| 36 | // Skip drive letter and colon | 51 | // Skip drive letter and colon |
| 37 | hr = StrAllocConcat(psczUNCPath, sczMountedDrivePath + 2, 0); | 52 | hr = StrAllocConcat(psczUNCPath, sczMountedDrivePath + 2, 0); |
| 38 | ExitOnFailure(hr, "Failed to copy rest of database path"); | 53 | UncExitOnFailure(hr, "Failed to copy rest of database path"); |
| 39 | } | 54 | } |
| 40 | else | 55 | else |
| 41 | { | 56 | { |
| @@ -44,7 +59,7 @@ DAPI_(HRESULT) UncConvertFromMountedDrive( | |||
| 44 | er = ERROR_NO_DATA; | 59 | er = ERROR_NO_DATA; |
| 45 | } | 60 | } |
| 46 | 61 | ||
| 47 | ExitOnWin32Error(er, hr, "::WNetGetConnectionW() failed on drive %ls", sczDrive); | 62 | UncExitOnWin32Error(er, hr, "::WNetGetConnectionW() failed on drive %ls", sczDrive); |
| 48 | } | 63 | } |
| 49 | 64 | ||
| 50 | LExit: | 65 | LExit: |
