aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/native/windows/file.h
diff options
context:
space:
mode:
authorGravatar Laszlo Csomor <laszlocsomor@google.com>2018-07-13 01:58:15 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-07-13 01:59:26 -0700
commit87bd94787f459a52ebe8bf395d4877cdb8d1929b (patch)
treec9843626da589a807d81856b7128f9a5de3c8510 /src/main/native/windows/file.h
parent75bc18a6290f9112077884460d61f34bec325814 (diff)
Windows,JNI: graceful error-handling
CreateJunction and DeletePath are now more resilient to errors: - CreateJunction opens the junction path to check its target requesting fewer rights and with greater sharing permission. This way it can check junction targets even if the junction name is opened by another process with no sharing. - DeletePath attempts to call FindFirstFileW if GetFileAttributesW fails with ERROR_ACCESS_DENIED. There's hardly any info about this error mode online, except for a code comment in the .NET CoreFX library. (See new code comments in this commit.) Also: - Change the error codes for DeletePath. - Wrap the DeletPath error codes in a struct for better readability. Fixes https://github.com/bazelbuild/bazel/issues/5433 Change-Id: I5b6e0f27b5b22c1cf00da90104495eda84178283 Closes #5590. Change-Id: I5b6e0f27b5b22c1cf00da90104495eda84178283 PiperOrigin-RevId: 204438994
Diffstat (limited to 'src/main/native/windows/file.h')
-rw-r--r--src/main/native/windows/file.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/main/native/windows/file.h b/src/main/native/windows/file.h
index ce13908140..e16b03bd23 100644
--- a/src/main/native/windows/file.h
+++ b/src/main/native/windows/file.h
@@ -42,12 +42,14 @@ enum {
};
// Keep in sync with j.c.g.devtools.build.lib.windows.WindowsFileOperations
-enum {
- DELETE_PATH_SUCCESS = 0,
- DELETE_PATH_DOES_NOT_EXIST = 1,
- DELETE_PATH_DIRECTORY_NOT_EMPTY = 2,
- DELETE_PATH_ACCESS_DENIED = 3,
- DELETE_PATH_ERROR = 4,
+struct DeletePathResult {
+ enum {
+ kSuccess = 0,
+ kError = 1,
+ kDoesNotExist = 2,
+ kDirectoryNotEmpty = 3,
+ kAccessDenied = 4,
+ };
};
struct CreateJunctionResult {