Add file access modes to sk_exists.
Both Windows and Posix 'access' calls take a mode parameter which,
in addition to checking existence, checks access modes.
This change exposes this functionality.
R=mtklein@google.com, reed@google.com
Author: bungeman@google.com
Review URL: https://codereview.chromium.org/384903002
diff --git a/src/ports/SkOSFile_win.cpp b/src/ports/SkOSFile_win.cpp
index a084891..1430d7f 100644
--- a/src/ports/SkOSFile_win.cpp
+++ b/src/ports/SkOSFile_win.cpp
@@ -13,6 +13,17 @@
#include <stdio.h>
#include <sys/stat.h>
+bool sk_exists(const char *path, SkFILE_Flags flags) {
+ int mode = 0; // existence
+ if (flags & kRead_SkFILE_Flag) {
+ mode |= 4; // read
+ }
+ if (flags & kWrite_SkFILE_Flag) {
+ mode |= 2; // write
+ }
+ return (0 == _access(path, mode));
+}
+
typedef struct {
ULONGLONG fVolume;
ULONGLONG fLsbSize;