Explicitly use CreateFileA in readlink
authorAndrew Krieger <andrew.krieger@oculus.com>
Fri, 14 Apr 2017 02:23:50 +0000 (19:23 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 14 Apr 2017 02:34:50 +0000 (19:34 -0700)
Summary:
In Unicode enabled projects, this errors because CreateFile aliases
CreateFileW, which takes wchar_t* not char*.

Reviewed By: Orvid, yfeldblum

Differential Revision: D4878424

fbshipit-source-id: b44b369c0533e74163f68d95c2bf353584033731

folly/portability/Unistd.cpp

index 4d387b0..a587ba6 100755 (executable)
@@ -205,13 +205,14 @@ ssize_t readlink(const char* path, char* buf, size_t buflen) {
     return -1;
   }
 
-  HANDLE h = CreateFile(path,
-                        GENERIC_READ,
-                        FILE_SHARE_READ,
-                        nullptr,
-                        OPEN_EXISTING,
-                        FILE_FLAG_BACKUP_SEMANTICS,
-                        nullptr);
+  HANDLE h = CreateFileA(
+      path,
+      GENERIC_READ,
+      FILE_SHARE_READ,
+      nullptr,
+      OPEN_EXISTING,
+      FILE_FLAG_BACKUP_SEMANTICS,
+      nullptr);
   if (h == INVALID_HANDLE_VALUE) {
     return -1;
   }