Subversion Repositories recyclebinunit

Rev

Rev 89 | Rev 93 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 89 Rev 90
Line 367... Line 367...
367
  TGetVolumeNameForVolumeMountPointA = function(lpszVolumeMountPoint: LPCSTR; lpszVolumeName: LPSTR; cchBufferLength: DWORD): BOOL; stdcall;
367
  TGetVolumeNameForVolumeMountPointA = function(lpszVolumeMountPoint: LPCSTR; lpszVolumeName: LPSTR; cchBufferLength: DWORD): BOOL; stdcall;
368
  TSHEmptyRecycleBin = function(Wnd: HWND; pszRootPath: PChar; dwFlags: DWORD): HRESULT; stdcall;
368
  TSHEmptyRecycleBin = function(Wnd: HWND; pszRootPath: PChar; dwFlags: DWORD): HRESULT; stdcall;
369
  TSHGetSettings = procedure(var lpss: SHELLSTATE; dwMask: DWORD); stdcall;
369
  TSHGetSettings = procedure(var lpss: SHELLSTATE; dwMask: DWORD); stdcall;
370
  TSHGetSetSettings = procedure(var lpss: SHELLSTATE; dwMask: DWORD; bSet: BOOL); stdcall;
370
  TSHGetSetSettings = procedure(var lpss: SHELLSTATE; dwMask: DWORD; bSet: BOOL); stdcall;
371
 
371
 
-
 
372
function WideCharArrayToWideString(x: array of WideChar): WideString;
-
 
373
var
-
 
374
  i: integer;
-
 
375
begin
-
 
376
  // In x86, the "cast" works with WideString.
-
 
377
  // In x64, it does not work (outputs empty string, without compiler warning!)
-
 
378
  // So, we created this fake-cast
-
 
379
  SetLength(result, Length(x));
-
 
380
  for i := 0 to Length(x)-1 do
-
 
381
    result[i+1] := x[i];
-
 
382
end;
-
 
383
 
-
 
384
function AnsiCharArrayToWideString(x: array of AnsiChar): WideString;
-
 
385
var
-
 
386
  i: integer;
-
 
387
begin
-
 
388
  SetLength(result, Length(x));
-
 
389
  for i := 0 to Length(x)-1 do
-
 
390
    result[i+1] := WideChar(x[i]);
-
 
391
end;
-
 
392
 
372
procedure AnsiRemoveNulChars(var s: AnsiString);
393
procedure AnsiRemoveNulChars(var s: AnsiString);
373
begin
394
begin
374
  while (Length(s) > 0) and (s[Length(s)] = #0) do
395
  while (Length(s) > 0) and (s[Length(s)] = #0) do
375
    s := Copy(s, 1, Length(s)-1);
396
    s := Copy(s, 1, Length(s)-1);
376
end;
397
end;
Line 1378... Line 1399...
1378
    FRemovedEntry := true;
1399
    FRemovedEntry := true;
1379
    r.sourceAnsi[0] := AnsiChar(FSourceDrive);
1400
    r.sourceAnsi[0] := AnsiChar(FSourceDrive);
1380
  end;
1401
  end;
1381
 
1402
 
1382
  FSourceAnsi := r.sourceAnsi;
1403
  FSourceAnsi := r.sourceAnsi;
1383
  FSourceUnicode := WideString(r.sourceAnsi); // Unicode does not exist in INFO(1) structure
1404
  FSourceUnicode := AnsiCharArrayToWideString(r.sourceAnsi); // Unicode does not exist in INFO(1) structure
1384
  FID := IntToStr(r.recordNumber);
1405
  FID := IntToStr(r.recordNumber);
1385
  FDeletionTime := FileTimeToDateTime(r.deletionTime);
1406
  FDeletionTime := FileTimeToDateTime(r.deletionTime);
1386
  FOriginalSize := r.originalSize;
1407
  FOriginalSize := r.originalSize;
1387
 
1408
 
1388
  // Remove #0 at the end. There are some bugs where #0 is added to ANSI/Unicode read paths?! (probably in the ReadVista stuff)
1409
  // Remove #0 at the end. There are some bugs where #0 is added to ANSI/Unicode read paths?! (probably in the ReadVista stuff)
Line 1524... Line 1545...
1524
 
1545
 
1525
  if version = 1 then
1546
  if version = 1 then
1526
  begin
1547
  begin
1527
    stream.Seek(0, soBeginning);
1548
    stream.Seek(0, soBeginning);
1528
    stream.ReadBuffer(r1, SizeOf(r1));
1549
    stream.ReadBuffer(r1, SizeOf(r1));
1529
    FSourceAnsi := AnsiString(r1.sourceUnicode); // Invalid chars are automatically converted into '?'
1550
    FSourceAnsi := AnsiString(WideCharArrayToWideString(r1.sourceUnicode)); // Invalid chars are automatically converted into '?'
1530
    FSourceUnicode := WideString(r1.sourceUnicode);
1551
    FSourceUnicode := WideCharArrayToWideString(r1.sourceUnicode);
1531
    FID := ''; // will be added manually (at the constructor)
1552
    FID := ''; // will be added manually (at the constructor)
1532
    FSourceDrive := r1.sourceUnicode[1];
1553
    FSourceDrive := r1.sourceUnicode[1];
1533
    FDeletionTime := FileTimeToDateTime(r1.deletionTime);
1554
    FDeletionTime := FileTimeToDateTime(r1.deletionTime);
1534
    FOriginalSize := r1.originalSize;
1555
    FOriginalSize := r1.originalSize;
1535
  end
1556
  end
1536
  else if version = 2 then
1557
  else if version = 2 then
1537
  begin
1558
  begin
1538
    stream.Seek(0, soBeginning);
1559
    stream.Seek(0, soBeginning);
1539
    stream.ReadBuffer(r2, SizeOf(r2));
1560
    stream.ReadBuffer(r2, SizeOf(r2));
1540
 
1561
 
1541
    SetLength(r2SourceUnicode, 2*(r2.SourceCountChars-1));
1562
    SetLength(r2SourceUnicode, SizeOf(WideChar)*(r2.SourceCountChars-1));
1542
    stream.Read(r2SourceUnicode[0], 2*(r2.sourceCountChars-1));
1563
    stream.Read(r2SourceUnicode[0], SizeOf(WideChar)*(r2.sourceCountChars-1));
1543
 
1564
 
1544
    FSourceAnsi := AnsiString(WideString(r2sourceUnicode)); // Invalid chars are automatically converted into '?'
1565
    FSourceAnsi := AnsiString(WideCharArrayToWideString(r2sourceUnicode)); // Invalid chars are automatically converted into '?'
1545
    FSourceUnicode := WideString(r2sourceUnicode);
1566
    FSourceUnicode := WideCharArrayToWideString(r2sourceUnicode);
1546
    FID := ''; // will be added manually (at the constructor)
1567
    FID := ''; // will be added manually (at the constructor)
1547
    FSourceDrive := r2sourceUnicode[1];
1568
    FSourceDrive := r2sourceUnicode[1];
1548
    FDeletionTime := FileTimeToDateTime(r2.deletionTime);
1569
    FDeletionTime := FileTimeToDateTime(r2.deletionTime);
1549
    FOriginalSize := r2.originalSize;
1570
    FOriginalSize := r2.originalSize;
1550
  end
1571
  end