Created
December 6, 2011 07:38
-
-
Save ebith/1437221 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <windows.h> | |
#define BUFSIZE MAX_PATH | |
int main (int argc, char *argv[]) | |
{ | |
HANDLE hFind; | |
HANDLE hFile; | |
WIN32_FIND_DATA fd; | |
DWORD dwRet; | |
CHAR Path[BUFSIZE]; | |
if (argc == 1) { | |
printf("error,Need argument"); | |
return; | |
} | |
hFind = FindFirstFile(argv[1], &fd); | |
if (hFind == INVALID_HANDLE_VALUE) { | |
printf("error,%d %s", GetLastError(), argv[1]); | |
return; | |
} | |
if (fd.dwReserved0 == IO_REPARSE_TAG_SYMLINK) { | |
hFile = CreateFile(argv[1], GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); | |
dwRet = GetFinalPathNameByHandle(hFile, Path, BUFSIZE, VOLUME_NAME_DOS); | |
printf("true,%s", &Path[4]); | |
CloseHandle(hFile); | |
} else { | |
printf("false,"); | |
} | |
FindClose(hFind); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
autocmd BufRead * call s:IsSymlink() | |
function! s:IsSymlink() | |
let s:res = split(vimproc#system('isSymlink.exe "' . expand('%:p') . '"'), ',') | |
if (s:res[0] == 'true') | |
let s:filetype = &filetype | |
edit `=s:res[1]` | |
let &syntax = s:filetype | |
elseif (s:res[0] == 'error') | |
echoerr 'isSymlink : ' . s:res[1] | |
endif | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment