You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/04/23 13:34:33 UTC
svn commit: r767893 -
/commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c
Author: mturk
Date: Thu Apr 23 11:34:32 2009
New Revision: 767893
URL: http://svn.apache.org/viewvc?rev=767893&view=rev
Log:
Use a name used to create a symlink when reading it
Modified:
commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c?rev=767893&r1=767892&r2=767893&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c Thu Apr 23 11:34:32 2009
@@ -173,7 +173,7 @@
if (buf) {
HANDLE sh = CreateFileW(J2W(lnkname),
GENERIC_READ,
- FILE_SHARE_DELETE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
NULL,
OPEN_EXISTING,
FILE_FLAG_OPEN_REPARSE_POINT,
@@ -182,6 +182,8 @@
DWORD dl;
PREPARSE_DATA_BUFFER repb;
char *pb;
+ size_t noff;
+ size_t nlen;
DeviceIoControl(sh,
FSCTL_GET_REPARSE_POINT,
NULL,
@@ -194,13 +196,28 @@
switch (repb->ReparseTag) {
case IO_REPARSE_TAG_MOUNT_POINT:
pb = (char *)repb->MountPointReparseBuffer.PathBuffer;
- rv = (*_E)->NewString(_E, (const jchar *)(pb + repb->MountPointReparseBuffer.SubstituteNameOffset),
- repb->MountPointReparseBuffer.SubstituteNameLength / sizeof(WCHAR));
+ nlen = repb->MountPointReparseBuffer.PrintNameLength;
+ if (!nlen) {
+ nlen = repb->MountPointReparseBuffer.SubstituteNameLength;
+ noff = repb->MountPointReparseBuffer.SubstituteNameOffset;
+ }
+ else
+ noff = repb->MountPointReparseBuffer.PrintNameOffset;
+ rv = (*_E)->NewString(_E, (const jchar *)(pb + noff), nlen / sizeof(WCHAR));
break;
case IO_REPARSE_TAG_SYMLINK:
pb = (char *)repb->SymbolicLinkReparseBuffer.PathBuffer;
- rv = (*_E)->NewString(_E, (const jchar *)(pb + repb->SymbolicLinkReparseBuffer.SubstituteNameOffset),
- repb->SymbolicLinkReparseBuffer.SubstituteNameLength / sizeof(WCHAR));
+ nlen = repb->SymbolicLinkReparseBuffer.PrintNameLength;
+ if (!nlen) {
+ nlen = repb->SymbolicLinkReparseBuffer.SubstituteNameLength;
+ noff = repb->SymbolicLinkReparseBuffer.SubstituteNameOffset;
+ }
+ else
+ noff = repb->SymbolicLinkReparseBuffer.PrintNameOffset;
+ rv = (*_E)->NewString(_E, (const jchar *)(pb + noff), nlen / sizeof(WCHAR));
+ break;
+ default:
+ ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, ACR_EBADF);
break;
}
CloseHandle(sh);