mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-31 03:20:28 +08:00
* ntdll.h (RtlInitCountedUnicodeString): Swap order of string and length
parameters to be the same as for RtlInitEmptyUnicodeString. (RtlEqualPathPrefix): New inline function. (RtlEqualPathSuffix): New inline function. * fhandler_disk_file.cc: Accommodate parameter order change of RtlInitEmptyUnicodeString throughout. (fhandler_disk_file::link): Do path checking in unicode. Call CopyFileW instead of CopyFileA.
This commit is contained in:
parent
745c29fe7b
commit
74c5e8c73a
@ -1,3 +1,14 @@
|
|||||||
|
2007-07-27 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* ntdll.h (RtlInitCountedUnicodeString): Swap order of string and length
|
||||||
|
parameters to be the same as for RtlInitEmptyUnicodeString.
|
||||||
|
(RtlEqualPathPrefix): New inline function.
|
||||||
|
(RtlEqualPathSuffix): New inline function.
|
||||||
|
* fhandler_disk_file.cc: Accommodate parameter order change of
|
||||||
|
RtlInitEmptyUnicodeString throughout.
|
||||||
|
(fhandler_disk_file::link): Do path checking in unicode. Call
|
||||||
|
CopyFileW instead of CopyFileA.
|
||||||
|
|
||||||
2007-07-27 Corinna Vinschen <corinna@vinschen.de>
|
2007-07-27 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* autoload.cc (CreateHardLinkA): Remove.
|
* autoload.cc (CreateHardLinkA): Remove.
|
||||||
|
@ -223,8 +223,8 @@ path_conv::ndisk_links (DWORD nNumberOfLinks)
|
|||||||
{
|
{
|
||||||
UNICODE_STRING fname;
|
UNICODE_STRING fname;
|
||||||
|
|
||||||
RtlInitCountedUnicodeString (&fname, pfdi->FileNameLength,
|
RtlInitCountedUnicodeString (&fname, pfdi->FileName,
|
||||||
pfdi->FileName);
|
pfdi->FileNameLength);
|
||||||
InitializeObjectAttributes (&attr, &fname,
|
InitializeObjectAttributes (&attr, &fname,
|
||||||
OBJ_CASE_INSENSITIVE, fh, NULL);
|
OBJ_CASE_INSENSITIVE, fh, NULL);
|
||||||
if (is_volume_mountpoint (&attr))
|
if (is_volume_mountpoint (&attr))
|
||||||
@ -235,8 +235,8 @@ path_conv::ndisk_links (DWORD nNumberOfLinks)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
UNICODE_STRING fname;
|
UNICODE_STRING fname;
|
||||||
RtlInitCountedUnicodeString (&fname, pfdi->FileNameLength,
|
RtlInitCountedUnicodeString (&fname, pfdi->FileName,
|
||||||
pfdi->FileName);
|
pfdi->FileNameLength);
|
||||||
dir->check_mount (&fname, 0, false);
|
dir->check_mount (&fname, 0, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1043,8 +1043,6 @@ fhandler_disk_file::link (const char *newpath)
|
|||||||
char new_buf[strlen (newpath) + 5];
|
char new_buf[strlen (newpath) + 5];
|
||||||
if (!newpc.error && !newpc.case_clash)
|
if (!newpc.error && !newpc.case_clash)
|
||||||
{
|
{
|
||||||
int len;
|
|
||||||
|
|
||||||
if (allow_winsymlinks && pc.is_lnk_special ())
|
if (allow_winsymlinks && pc.is_lnk_special ())
|
||||||
{
|
{
|
||||||
/* Shortcut hack. */
|
/* Shortcut hack. */
|
||||||
@ -1053,10 +1051,9 @@ fhandler_disk_file::link (const char *newpath)
|
|||||||
newpc.check (newpath, PC_SYM_NOFOLLOW);
|
newpc.check (newpath, PC_SYM_NOFOLLOW);
|
||||||
}
|
}
|
||||||
else if (!pc.isdir ()
|
else if (!pc.isdir ()
|
||||||
&& (len = strlen (pc.get_win32 ())) > 4
|
&& RtlEqualPathSuffix (pc.get_nt_native_path (), L".exe", TRUE)
|
||||||
&& strcasematch (pc.get_win32 () + len - 4, ".exe")
|
&& !RtlEqualPathSuffix (newpc.get_nt_native_path (), L".exe",
|
||||||
&& (len = strlen (newpc.get_win32 ())) > 4
|
TRUE))
|
||||||
&& !strcasematch (newpc.get_win32 () + len - 4, ".exe"))
|
|
||||||
{
|
{
|
||||||
/* Executable hack. */
|
/* Executable hack. */
|
||||||
stpcpy (stpcpy (new_buf, newpath), ".exe");
|
stpcpy (stpcpy (new_buf, newpath), ".exe");
|
||||||
@ -1091,7 +1088,10 @@ fhandler_disk_file::link (const char *newpath)
|
|||||||
if (status == STATUS_INVALID_DEVICE_REQUEST)
|
if (status == STATUS_INVALID_DEVICE_REQUEST)
|
||||||
{
|
{
|
||||||
/* FS doesn't support hard links. Try to copy file. */
|
/* FS doesn't support hard links. Try to copy file. */
|
||||||
if (!CopyFileA (pc, newpc, TRUE))
|
WCHAR pcw[pc.get_nt_native_path ()->Length + 1];
|
||||||
|
WCHAR newpcw[newpc.get_nt_native_path ()->Length + 1];
|
||||||
|
if (!CopyFileW (pc.get_wide_win32_path (pcw),
|
||||||
|
newpc.get_wide_win32_path (newpcw), TRUE))
|
||||||
{
|
{
|
||||||
__seterrno ();
|
__seterrno ();
|
||||||
return -1;
|
return -1;
|
||||||
@ -1732,11 +1732,12 @@ fhandler_disk_file::readdir_helper (DIR *dir, dirent *de, DWORD w32_err,
|
|||||||
UNICODE_STRING uname;
|
UNICODE_STRING uname;
|
||||||
UNICODE_STRING lname;
|
UNICODE_STRING lname;
|
||||||
|
|
||||||
RtlInitCountedUnicodeString (&uname, 4 * sizeof (WCHAR),
|
RtlInitCountedUnicodeString (&uname,
|
||||||
fname->Buffer +
|
fname->Buffer
|
||||||
fname->Length / sizeof (WCHAR) - 4);
|
+ fname->Length / sizeof (WCHAR) - 4,
|
||||||
RtlInitCountedUnicodeString (&lname, 4 * sizeof (WCHAR),
|
4 * sizeof (WCHAR));
|
||||||
(PWCHAR) L".lnk");
|
RtlInitCountedUnicodeString (&lname, (PWCHAR) L".lnk",
|
||||||
|
4 * sizeof (WCHAR));
|
||||||
|
|
||||||
if (RtlEqualUnicodeString (&uname, &lname, TRUE))
|
if (RtlEqualUnicodeString (&uname, &lname, TRUE))
|
||||||
{
|
{
|
||||||
@ -1872,7 +1873,7 @@ go_ahead:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
FileName = ((PFILE_BOTH_DIR_INFORMATION) buf)->FileName;
|
FileName = ((PFILE_BOTH_DIR_INFORMATION) buf)->FileName;
|
||||||
RtlInitCountedUnicodeString (&fname, buf->FileNameLength, FileName);
|
RtlInitCountedUnicodeString (&fname, FileName, buf->FileNameLength);
|
||||||
de->d_ino = d_mounts (dir)->check_mount (&fname, de->d_ino);
|
de->d_ino = d_mounts (dir)->check_mount (&fname, de->d_ino);
|
||||||
if (de->d_ino == 0 && (dir->__flags & dirent_set_d_ino))
|
if (de->d_ino == 0 && (dir->__flags & dirent_set_d_ino))
|
||||||
{
|
{
|
||||||
|
@ -807,8 +807,8 @@ extern "C"
|
|||||||
dest->Buffer = (PWSTR) buf;
|
dest->Buffer = (PWSTR) buf;
|
||||||
}
|
}
|
||||||
inline
|
inline
|
||||||
VOID NTAPI RtlInitCountedUnicodeString (PUNICODE_STRING dest, USHORT len,
|
VOID NTAPI RtlInitCountedUnicodeString (PUNICODE_STRING dest, PCWSTR buf,
|
||||||
PCWSTR buf)
|
USHORT len)
|
||||||
{
|
{
|
||||||
dest->Length = dest->MaximumLength = len;
|
dest->Length = dest->MaximumLength = len;
|
||||||
dest->Buffer = (PWSTR) buf;
|
dest->Buffer = (PWSTR) buf;
|
||||||
@ -822,9 +822,36 @@ extern "C"
|
|||||||
;
|
;
|
||||||
++len;
|
++len;
|
||||||
if (dir)
|
if (dir)
|
||||||
RtlInitCountedUnicodeString (dir, len * sizeof (WCHAR), path->Buffer);
|
RtlInitCountedUnicodeString (dir, path->Buffer, len * sizeof (WCHAR));
|
||||||
if (file)
|
if (file)
|
||||||
RtlInitCountedUnicodeString (file, path->Length - len * sizeof (WCHAR),
|
RtlInitCountedUnicodeString (file, &path->Buffer[len],
|
||||||
&path->Buffer[len]);
|
path->Length - len * sizeof (WCHAR));
|
||||||
|
}
|
||||||
|
inline
|
||||||
|
BOOLEAN NTAPI RtlEqualPathPrefix (PUNICODE_STRING path, PCWSTR prefix,
|
||||||
|
BOOLEAN caseinsensitive)
|
||||||
|
{
|
||||||
|
UNICODE_STRING p, pref;
|
||||||
|
|
||||||
|
RtlInitUnicodeString (&pref, prefix);
|
||||||
|
RtlInitCountedUnicodeString (&p, path->Buffer,
|
||||||
|
pref.Length < path->Length
|
||||||
|
? pref.Length : path->Length);
|
||||||
|
return RtlEqualUnicodeString (&p, &pref, caseinsensitive);
|
||||||
|
}
|
||||||
|
inline
|
||||||
|
BOOL NTAPI RtlEqualPathSuffix (PUNICODE_STRING path, PCWSTR suffix,
|
||||||
|
BOOLEAN caseinsensitive)
|
||||||
|
{
|
||||||
|
UNICODE_STRING p, suf;
|
||||||
|
|
||||||
|
RtlInitUnicodeString (&suf, suffix);
|
||||||
|
if (suf.Length < path->Length)
|
||||||
|
RtlInitCountedUnicodeString (&p, (PWCHAR) ((PBYTE) path->Buffer
|
||||||
|
+ path->Length - suf.Length),
|
||||||
|
suf.Length);
|
||||||
|
else
|
||||||
|
RtlInitCountedUnicodeString (&p, path->Buffer, path->Length);
|
||||||
|
return RtlEqualUnicodeString (&p, &suf, caseinsensitive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user