Subversion Repositories recyclebinunit

Compare Revisions

Regard whitespace Rev 95 → Rev 96

/trunk/Recycle Bin Unit/RecyclerFunctions.pas
387,6 → 387,7
LNG_API_CALL_ERROR = 'Error while calling the API. Additional information: "%s".';
LNG_NOT_CALLABLE = '%s not callable';
LNG_ERROR_CODE = '%s (Arguments: %s) returns error code %s';
LNG_UNEXPECTED_VISTA_FORMAT = 'Unexpeceted version %d of Vista index file';
 
function _DeleteDirectory(const Name: string): boolean;
var
966,7 → 967,7
try
fs.ReadBuffer(version, 4);
if version > 2 then
raise Exception.CreateFmt('Unexpeceted version %d of Vista index file', [version]);
raise Exception.CreateFmt(LNG_UNEXPECTED_VISTA_FORMAT, [version]);
fs.seek(drive_vista_position, soFromBeginning);
result := _readChar(fs);
finally
993,7 → 994,7
try
fs.ReadBuffer(version, 4);
if version > 2 then
raise Exception.CreateFmt('Unexpeceted version %d of Vista index file', [version]);
raise Exception.CreateFmt(LNG_UNEXPECTED_VISTA_FORMAT, [version]);
fs.seek(timestamp_vista_position, soFromBeginning);
result := _fileTimeToDateTime(_readInt64(fs));
finally
1026,7 → 1027,7
else if version = 1 then
fs.seek(unicode_vista_position_v1, soFromBeginning)
else
raise Exception.CreateFmt('Unexpeceted version %d of Vista index file', [version]);
raise Exception.CreateFmt(LNG_UNEXPECTED_VISTA_FORMAT, [version]);
result := _readNullTerminatedWideString(fs);
finally
fs.free;
1051,7 → 1052,7
try
fs.ReadBuffer(version, 4);
if version > 2 then
raise Exception.CreateFmt('Unexpeceted version %d of Vista index file', [version]);
raise Exception.CreateFmt(LNG_UNEXPECTED_VISTA_FORMAT, [version]);
fs.seek(size_vista_position, soFromBeginning);
result := _readInt32(fs);
finally
2219,7 → 2220,7
 
function RecyclerShellStateConfirmationDialogEnabled: boolean;
type
TSHGetSettings = procedure (var lpss: SHELLSTATE; dwMask: DWORD) stdcall;
TSHGetSettings = procedure (var lpss: SHELLSTATE; dwMask: DWORD); stdcall;
const
C_SHGetSettings = 'SHGetSettings';
var
2291,7 → 2292,7
 
procedure RecyclerConfirmationDialogSetEnabled(NewSetting: boolean);
type
TSHGetSetSettings = procedure (var lpss: SHELLSTATE; dwMask: DWORD; bSet: BOOL) stdcall;
TSHGetSetSettings = procedure (var lpss: SHELLSTATE; dwMask: DWORD; bSet: BOOL); stdcall;
const
C_SHGetSetSettings = 'SHGetSetSettings';
var
/trunk/Recycle Bin Unit v2/RecBinUnit2.pas
380,31 → 380,6
TSHGetSettings = procedure(var lpss: SHELLSTATE; dwMask: DWORD); stdcall;
TSHGetSetSettings = procedure(var lpss: SHELLSTATE; dwMask: DWORD; bSet: BOOL); stdcall;
 
type
TWideCharArray = array of WideChar;
TAnsiCharArray = array of AnsiChar;
 
function WideCharArrayToWideString(x: TWideCharArray): WideString;
var
i: integer;
begin
// In x86, the "cast" works with WideString.
// In x64, it does not work (outputs empty string, without compiler warning!)
// So, we created this fake-cast
SetLength(result, Length(x));
for i := 0 to Length(x)-1 do
result[i+1] := x[i];
end;
 
function AnsiCharArrayToWideString(x: TAnsiCharArray): WideString;
var
i: integer;
begin
SetLength(result, Length(x));
for i := 0 to Length(x)-1 do
result[i+1] := WideChar(x[i]);
end;
 
procedure AnsiRemoveNulChars(var s: AnsiString);
begin
while (Length(s) > 0) and (s[Length(s)] = #0) do
1560,9 → 1535,11
var
r1: TRbVistaRecord1;
r2: TRbVistaRecord2Head;
r2SourceUnicode: TWideCharArray;
r2SourceUnicode: array of WideChar;
version: DWORD;
i: Integer;
resourcestring
LNG_VISTA_WRONG_FORMAT = 'Invalid Vista index format version %d';
begin
stream.ReadBuffer(version, SizeOf(version));
 
1594,8 → 1571,17
SetLength(r2SourceUnicode, SizeOf(WideChar)*(r2.SourceCountChars-1));
stream.Read(r2SourceUnicode[0], SizeOf(WideChar)*(r2.sourceCountChars-1));
 
FSourceAnsi := AnsiString(WideCharArrayToWideString(r2sourceUnicode)); // Invalid chars are automatically converted into '?'
FSourceUnicode := WideCharArrayToWideString(r2sourceUnicode);
// Invalid chars are automatically converted into '?'
(* FSourceAnsi := AnsiString(WideCharArrayToWideString(r2sourceUnicode)); *)
SetLength(FSourceAnsi, Length(r2sourceUnicode));
for i := 0 to Length(r2sourceUnicode)-1 do
FSourceAnsi[i+1] := AnsiChar(r2sourceUnicode[i]);
 
(* FSourceUnicode := WideCharArrayToWideString(r2sourceUnicode); *)
SetLength(FSourceUnicode, Length(r2sourceUnicode));
for i := 0 to Length(r2sourceUnicode)-1 do
FSourceUnicode[i+1] := WideChar(r2sourceUnicode[i]);
 
FID := ''; // will be added manually (at the constructor)
FSourceDrive := AnsiChar(r2sourceUnicode[1]);
FDeletionTime := FileTimeToDateTime(r2.deletionTime);
1603,7 → 1589,7
end
else
begin
raise Exception.CreateFmt('Invalid Vista index format version %d', [version]);
raise Exception.CreateFmt(LNG_VISTA_WRONG_FORMAT, [version]);
end;
 
// Remove #0 at the end. There are some bugs where #0 is added to ANSI/Unicode read paths?! (probably in the ReadVista stuff)