mirror of
https://github.com/reactos/reactos.git
synced 2025-06-09 03:10:18 +00:00
[RTL]: Implement RtlDoesFileExists_UstrEx, RtlDoesFileExists_UStr, RtlDoesFileExists_UEx.
[RTL]: Make RtlDoesFileExists_UStrEx use the new RTL_RELATIVE_NAME structure and also support whether or not sharing violations should return success or not. [RTL]: For now, use the old RtlDosPathNameToNtPathName API instead of the newer one. svn path=/trunk/; revision=52685
This commit is contained in:
parent
42cac56e9d
commit
a595971d83
1 changed files with 130 additions and 44 deletions
|
@ -44,6 +44,21 @@ static const UNICODE_STRING _nul = RTL_CONSTANT_STRING(L"NUL");
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
RtlReleaseRelativeName(IN PRTL_RELATIVE_NAME_U RelativeName)
|
||||||
|
{
|
||||||
|
/* Check if a directory reference was grabbed */
|
||||||
|
if (RelativeName->CurDirRef)
|
||||||
|
{
|
||||||
|
/* FIXME: Not yet supported */
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
RelativeName->CurDirRef = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
|
@ -903,49 +918,130 @@ RtlDosSearchPath_U(PCWSTR paths,
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
BOOLEAN NTAPI
|
BOOLEAN
|
||||||
RtlDoesFileExists_U(IN PCWSTR FileName)
|
NTAPI
|
||||||
|
RtlDoesFileExists_UstrEx(IN PCUNICODE_STRING FileName,
|
||||||
|
IN BOOLEAN SucceedIfBusy)
|
||||||
{
|
{
|
||||||
UNICODE_STRING NtFileName;
|
BOOLEAN Result;
|
||||||
OBJECT_ATTRIBUTES Attr;
|
|
||||||
FILE_BASIC_INFORMATION Info;
|
|
||||||
NTSTATUS Status;
|
|
||||||
RTL_RELATIVE_NAME_U RelativeName;
|
RTL_RELATIVE_NAME_U RelativeName;
|
||||||
|
UNICODE_STRING NtPathName;
|
||||||
|
PVOID Buffer;
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
NTSTATUS Status;
|
||||||
|
FILE_BASIC_INFORMATION BasicInformation;
|
||||||
|
|
||||||
if (!RtlDosPathNameToNtPathName_U (FileName,
|
#if 0
|
||||||
&NtFileName,
|
/* Get the NT Path */
|
||||||
|
Result = RtlDosPathNameToRelativeNtPathName_Ustr(FileName,
|
||||||
|
&NtPathName,
|
||||||
NULL,
|
NULL,
|
||||||
&RelativeName))
|
&RelativeName);
|
||||||
return FALSE;
|
#else
|
||||||
|
/* FIXME: Use the old API for now */
|
||||||
|
Result = RtlDosPathNameToNtPathName_U(FileName->Buffer,
|
||||||
|
&NtPathName,
|
||||||
|
NULL,
|
||||||
|
&RelativeName);
|
||||||
|
#endif
|
||||||
|
if (!Result) return FALSE;
|
||||||
|
|
||||||
|
/* Save the buffer */
|
||||||
|
Buffer = NtPathName.Buffer;
|
||||||
|
|
||||||
|
/* Check if we have a relative name */
|
||||||
if (RelativeName.RelativeName.Length)
|
if (RelativeName.RelativeName.Length)
|
||||||
NtFileName = RelativeName.RelativeName;
|
{
|
||||||
|
/* Use it */
|
||||||
|
NtPathName = RelativeName.RelativeName;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
RelativeName.ContainingDirectory = 0;
|
{
|
||||||
|
/* Otherwise ignore it */
|
||||||
|
RelativeName.ContainingDirectory = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
InitializeObjectAttributes (&Attr,
|
/* Initialize the object attributes */
|
||||||
&NtFileName,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
&NtPathName,
|
||||||
OBJ_CASE_INSENSITIVE,
|
OBJ_CASE_INSENSITIVE,
|
||||||
RelativeName.ContainingDirectory,
|
RelativeName.ContainingDirectory,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
Status = ZwQueryAttributesFile (&Attr, &Info);
|
/* Query the attributes and free the buffer now */
|
||||||
|
Status = ZwQueryAttributesFile(&ObjectAttributes, &BasicInformation);
|
||||||
|
RtlReleaseRelativeName(&RelativeName);
|
||||||
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
|
|
||||||
RtlFreeUnicodeString(&NtFileName);
|
/* Check if we failed */
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
/* Check if we failed because the file is in use */
|
||||||
|
if ((Status == STATUS_SHARING_VIOLATION) ||
|
||||||
|
(Status == STATUS_ACCESS_DENIED))
|
||||||
|
{
|
||||||
|
/* Check if the caller wants this to be considered OK */
|
||||||
|
Result = SucceedIfBusy ? TRUE : FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* A failure because the file didn't exist */
|
||||||
|
Result = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* The file exists */
|
||||||
|
Result = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the result */
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
if (NT_SUCCESS(Status) ||
|
BOOLEAN
|
||||||
Status == STATUS_SHARING_VIOLATION ||
|
NTAPI
|
||||||
Status == STATUS_ACCESS_DENIED)
|
RtlDoesFileExists_UStr(IN PUNICODE_STRING FileName)
|
||||||
return TRUE;
|
{
|
||||||
|
/* Call the updated API */
|
||||||
|
return RtlDoesFileExists_UstrEx(FileName, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
BOOLEAN
|
||||||
|
BOOLEAN
|
||||||
|
NTAPI
|
||||||
|
RtlDoesFileExists_UEx(IN PCWSTR FileName,
|
||||||
|
IN BOOLEAN SucceedIfBusy)
|
||||||
|
{
|
||||||
|
UNICODE_STRING NameString;
|
||||||
|
|
||||||
|
/* Create the unicode name*/
|
||||||
|
if (NT_SUCCESS(RtlInitUnicodeStringEx(&NameString, FileName)))
|
||||||
|
{
|
||||||
|
/* Call the unicode function */
|
||||||
|
return NT_SUCCESS(RtlDoesFileExists_UstrEx(&NameString, SucceedIfBusy));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fail */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
BOOLEAN
|
||||||
|
NTAPI
|
||||||
|
RtlDoesFileExists_U(IN PCWSTR FileName)
|
||||||
|
{
|
||||||
|
/* Call the new function */
|
||||||
|
return RtlDoesFileExists_UEx(FileName, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @unimplemented
|
||||||
|
@ -961,16 +1057,6 @@ RtlDosPathNameToRelativeNtPathName_U(PVOID Unknown1,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @unimplemented
|
|
||||||
*/
|
|
||||||
VOID NTAPI
|
|
||||||
RtlReleaseRelativeName(PVOID Unknown)
|
|
||||||
{
|
|
||||||
DPRINT1("RtlReleaseRelativeName(0x%p) UNIMPLEMENTED\n", Unknown);
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS NTAPI
|
||||||
RtlpEnsureBufferSize(ULONG Unknown1, ULONG Unknown2, ULONG Unknown3)
|
RtlpEnsureBufferSize(ULONG Unknown1, ULONG Unknown2, ULONG Unknown3)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue