Advertisement
Guest User

Cygwin + OS X SMB reparse point test 1

a guest
Oct 21st, 2015
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. #include <windows.h>
  2. #include <stdio.h>
  3.  
  4. int main()
  5. {
  6.     HANDLE handle = CreateFile ("P:\\", GENERIC_READ, 0, 0,
  7.             OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
  8.     if (handle == INVALID_HANDLE_VALUE) {
  9.         LPTSTR pcMsg = 0;
  10.         FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
  11.                 FORMAT_MESSAGE_ALLOCATE_BUFFER, 0, GetLastError(),
  12.                 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
  13.                 (LPTSTR)&pcMsg, 0, 0);
  14.         printf("Bad handle: %s (0x%x)\n", pcMsg, GetLastError());
  15.         return 0;
  16.     }
  17.     DWORD attributes = GetFileAttributes (handle);
  18.     if (attributes != (DWORD) -1
  19.             && (attributes & FILE_ATTRIBUTE_REPARSE_POINT)) {
  20.         char buf[32000];
  21.         DWORD len;
  22.  
  23.         if (!DeviceIoControl(handle,
  24.                 FSCTL_GET_REPARSE_POINT, NULL, 0,
  25.                 buf, 32000, &len, NULL)) {
  26.             printf("error %u\n", GetLastError());
  27.         }
  28.         else {
  29.             printf("No error\n");
  30.         }
  31.     }
  32.     else {
  33.         printf("Reparse flag not set\n");
  34.     }
  35.  
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement