Subversion Repositories recyclebinunit

Compare Revisions

Regard whitespace Rev 96 → Rev 95

/trunk/Recycle Bin Unit/RecyclerFunctions.pas
387,7 → 387,6
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
967,7 → 966,7
try
fs.ReadBuffer(version, 4);
if version > 2 then
raise Exception.CreateFmt(LNG_UNEXPECTED_VISTA_FORMAT, [version]);
raise Exception.CreateFmt('Unexpeceted version %d of Vista index file', [version]);
fs.seek(drive_vista_position, soFromBeginning);
result := _readChar(fs);
finally
994,7 → 993,7
try
fs.ReadBuffer(version, 4);
if version > 2 then
raise Exception.CreateFmt(LNG_UNEXPECTED_VISTA_FORMAT, [version]);
raise Exception.CreateFmt('Unexpeceted version %d of Vista index file', [version]);
fs.seek(timestamp_vista_position, soFromBeginning);
result := _fileTimeToDateTime(_readInt64(fs));
finally
1027,7 → 1026,7
else if version = 1 then
fs.seek(unicode_vista_position_v1, soFromBeginning)
else
raise Exception.CreateFmt(LNG_UNEXPECTED_VISTA_FORMAT, [version]);
raise Exception.CreateFmt('Unexpeceted version %d of Vista index file', [version]);
result := _readNullTerminatedWideString(fs);
finally
fs.free;
1052,7 → 1051,7
try
fs.ReadBuffer(version, 4);
if version > 2 then
raise Exception.CreateFmt(LNG_UNEXPECTED_VISTA_FORMAT, [version]);
raise Exception.CreateFmt('Unexpeceted version %d of Vista index file', [version]);
fs.seek(size_vista_position, soFromBeginning);
result := _readInt32(fs);
finally
2220,7 → 2219,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
2292,7 → 2291,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,6 → 380,31
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
1535,11 → 1560,9
var
r1: TRbVistaRecord1;
r2: TRbVistaRecord2Head;
r2SourceUnicode: array of WideChar;
r2SourceUnicode: TWideCharArray;
version: DWORD;
i: Integer;
resourcestring
LNG_VISTA_WRONG_FORMAT = 'Invalid Vista index format version %d';
begin
stream.ReadBuffer(version, SizeOf(version));
 
1571,17 → 1594,8
SetLength(r2SourceUnicode, SizeOf(WideChar)*(r2.SourceCountChars-1));
stream.Read(r2SourceUnicode[0], SizeOf(WideChar)*(r2.sourceCountChars-1));
 
// 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]);
 
FSourceAnsi := AnsiString(WideCharArrayToWideString(r2sourceUnicode)); // Invalid chars are automatically converted into '?'
FSourceUnicode := WideCharArrayToWideString(r2sourceUnicode);
FID := ''; // will be added manually (at the constructor)
FSourceDrive := AnsiChar(r2sourceUnicode[1]);
FDeletionTime := FileTimeToDateTime(r2.deletionTime);
1589,7 → 1603,7
end
else
begin
raise Exception.CreateFmt(LNG_VISTA_WRONG_FORMAT, [version]);
raise Exception.CreateFmt('Invalid Vista index format version %d', [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)