mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
Manually applying Gunnars patch because it's easier this way - and a good chance to review mods.
svn path=/trunk/; revision=3716
This commit is contained in:
parent
f2064b3f8b
commit
2e3612cc58
3 changed files with 76 additions and 19 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: curdir.c,v 1.32 2002/10/20 03:33:34 robd Exp $
|
/* $Id: curdir.c,v 1.33 2002/11/07 02:52:37 robd Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -324,12 +324,8 @@ GetWindowsDirectoryA (
|
||||||
|
|
||||||
Length = RtlUnicodeStringToAnsiSize (&WindowsDirectory); //len of ansi str incl. nullchar
|
Length = RtlUnicodeStringToAnsiSize (&WindowsDirectory); //len of ansi str incl. nullchar
|
||||||
|
|
||||||
printf("windirlen incl term %i\n", Length);
|
|
||||||
|
|
||||||
if (uSize >= Length){
|
if (uSize >= Length){
|
||||||
|
|
||||||
printf("ok: enoug space\n");
|
|
||||||
|
|
||||||
String.Length = 0;
|
String.Length = 0;
|
||||||
String.MaximumLength = uSize;
|
String.MaximumLength = uSize;
|
||||||
String.Buffer = lpBuffer;
|
String.Buffer = lpBuffer;
|
||||||
|
@ -347,12 +343,9 @@ GetWindowsDirectoryA (
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
printf("good: ret chars %i\n",Length-1);
|
|
||||||
printf("dir: %s\n",lpBuffer);
|
|
||||||
return Length-1; //good: ret chars excl. nullchar
|
return Length-1; //good: ret chars excl. nullchar
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("bad: ret chars needed %i\n",Length);
|
|
||||||
return Length; //bad: ret space needed incl. nullchar
|
return Length; //bad: ret space needed incl. nullchar
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: file.c,v 1.37 2002/10/20 11:55:59 chorns Exp $
|
/* $Id: file.c,v 1.38 2002/11/07 02:52:37 robd Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -259,15 +259,18 @@ GetFileType(HANDLE hFile)
|
||||||
switch ((ULONG)hFile)
|
switch ((ULONG)hFile)
|
||||||
{
|
{
|
||||||
case STD_INPUT_HANDLE:
|
case STD_INPUT_HANDLE:
|
||||||
hFile = NtCurrentPeb()->ProcessParameters->hStdInput;
|
hFile = NtCurrentPeb()->ProcessParameters->hStdInput;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STD_OUTPUT_HANDLE:
|
case STD_OUTPUT_HANDLE:
|
||||||
hFile = NtCurrentPeb()->ProcessParameters->hStdOutput;
|
hFile = NtCurrentPeb()->ProcessParameters->hStdOutput;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STD_ERROR_HANDLE:
|
case STD_ERROR_HANDLE:
|
||||||
hFile = NtCurrentPeb()->ProcessParameters->hStdError;
|
hFile = NtCurrentPeb()->ProcessParameters->hStdError;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -800,12 +803,73 @@ SetFileTime(HANDLE hFile,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
The caller must have opened the file with the DesiredAccess FILE_WRITE_DATA flag set.
|
||||||
|
*/
|
||||||
WINBOOL STDCALL
|
WINBOOL STDCALL
|
||||||
SetEndOfFile(HANDLE hFile)
|
SetEndOfFile(HANDLE hFile)
|
||||||
{
|
{
|
||||||
int x = -1;
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
DWORD Num;
|
FILE_END_OF_FILE_INFORMATION EndOfFileInfo;
|
||||||
return WriteFile(hFile,&x,1,&Num,NULL);
|
FILE_ALLOCATION_INFORMATION FileAllocationInfo;
|
||||||
|
FILE_POSITION_INFORMATION FilePosInfo;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
//get current position
|
||||||
|
Status = NtQueryInformationFile(
|
||||||
|
hFile,
|
||||||
|
&IoStatusBlock,
|
||||||
|
&FilePosInfo,
|
||||||
|
sizeof(FILE_POSITION_INFORMATION),
|
||||||
|
FilePositionInformation
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(Status)){
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EndOfFileInfo.EndOfFile.QuadPart = FilePosInfo.CurrentByteOffset.QuadPart;
|
||||||
|
|
||||||
|
/*
|
||||||
|
NOTE:
|
||||||
|
This call is not supposed to free up any space after the eof marker
|
||||||
|
if the file gets truncated. We have to deallocate the space explicitly afterwards.
|
||||||
|
But...most file systems dispatch both FileEndOfFileInformation
|
||||||
|
and FileAllocationInformation as they were the same command.
|
||||||
|
|
||||||
|
*/
|
||||||
|
Status = NtSetInformationFile(
|
||||||
|
hFile,
|
||||||
|
&IoStatusBlock, //out
|
||||||
|
&EndOfFileInfo,
|
||||||
|
sizeof(FILE_END_OF_FILE_INFORMATION),
|
||||||
|
FileEndOfFileInformation
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(Status)){
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
FileAllocationInfo.AllocationSize.QuadPart = FilePosInfo.CurrentByteOffset.QuadPart;
|
||||||
|
|
||||||
|
|
||||||
|
Status = NtSetInformationFile(
|
||||||
|
hFile,
|
||||||
|
&IoStatusBlock, //out
|
||||||
|
&FileAllocationInfo,
|
||||||
|
sizeof(FILE_ALLOCATION_INFORMATION),
|
||||||
|
FileAllocationInformation
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(Status)){
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: lfile.c,v 1.6 2000/06/03 14:47:32 ea Exp $
|
/* $Id: lfile.c,v 1.7 2002/11/07 02:52:37 robd Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -156,11 +156,11 @@ _lcreat (
|
||||||
|
|
||||||
DWORD FileAttributes = 0;
|
DWORD FileAttributes = 0;
|
||||||
|
|
||||||
if ( iAttribute == 1 )
|
if ( iAttribute == 0 )
|
||||||
FileAttributes |= FILE_ATTRIBUTE_NORMAL;
|
FileAttributes |= FILE_ATTRIBUTE_NORMAL;
|
||||||
else if ( iAttribute == 2 )
|
else if ( iAttribute == 1 )
|
||||||
FileAttributes |= FILE_ATTRIBUTE_READONLY;
|
FileAttributes |= FILE_ATTRIBUTE_READONLY;
|
||||||
else if ( iAttribute == 3 )
|
else if ( iAttribute == 2 )
|
||||||
FileAttributes |= FILE_ATTRIBUTE_HIDDEN;
|
FileAttributes |= FILE_ATTRIBUTE_HIDDEN;
|
||||||
else if ( iAttribute == 4 )
|
else if ( iAttribute == 4 )
|
||||||
FileAttributes |= FILE_ATTRIBUTE_SYSTEM;
|
FileAttributes |= FILE_ATTRIBUTE_SYSTEM;
|
||||||
|
|
Loading…
Reference in a new issue