Subversion Repositories checksum-tools

Rev

Rev 2 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 6
Line 1... Line 1...
1
unit SFV;
1
unit SFV;
2
 
2
 
3
interface
3
interface
4
 
4
 
5
uses
5
uses
6
  Classes;
6
  Classes, Common;
-
 
7
 
-
 
8
type
-
 
9
  TCheckSumFileSFV = class(TCheckSumFile)
-
 
10
  protected
-
 
11
    sfvFile: string;
-
 
12
  public
-
 
13
    constructor Create(AFileName: string); override;
-
 
14
    procedure ToStringList(slOut: TStringList); override;
-
 
15
    function SingleFileChecksum(AFileName: string): string; override;
-
 
16
    function MergeLine(AFileName, ACheckSum: string): string; override;
-
 
17
  end;
7
 
18
 
8
function CalcFileCRC32(filename: string): string; overload;
19
function CalcFileCRC32(filename: string): string; overload;
9
procedure SFVFileToStringList(aSFVFile: string; slOut: TStringList);
20
procedure SFVFileToStringList(aSFVFile: string; slOut: TStringList);
10
 
21
 
11
implementation
22
implementation
12
 
23
 
13
uses
24
uses
14
  Windows, SysUtils, CRC32, Common, LongFilenameOperations;
25
  Windows, SysUtils, CRC32, LongFilenameOperations;
15
 
26
 
16
function CalcFileCRC32(filename: string): string; overload;
27
function CalcFileCRC32(filename: string): string; overload;
17
var
28
var
18
  checksum: DWORD;
29
  checksum: DWORD;
19
  totalbytes: TInteger8;
30
  totalbytes: TInteger8;
Line 78... Line 89...
78
  finally
89
  finally
79
    MyCloseFile(fil);
90
    MyCloseFile(fil);
80
  end;
91
  end;
81
end;
92
end;
82
 
93
 
-
 
94
{ TCheckSumFileSFV }
-
 
95
 
-
 
96
constructor TCheckSumFileSFV.Create(AFileName: string);
-
 
97
begin
-
 
98
  inherited;
-
 
99
  sfvFile := AFileName;
-
 
100
  if not SameText(ExtractFileExt(AFileName),'.sfv') then
-
 
101
    raise Exception.Create('Invalid checksum file extension.');
-
 
102
end;
-
 
103
 
-
 
104
function TCheckSumFileSFV.MergeLine(AFileName, ACheckSum: string): string;
-
 
105
begin
-
 
106
  result := AFileName + ' ' + ACheckSum;
-
 
107
end;
-
 
108
 
-
 
109
function TCheckSumFileSFV.SingleFileChecksum(AFileName: string): string;
-
 
110
begin
-
 
111
  result := CalcFileCRC32(AFileName);
-
 
112
end;
-
 
113
 
-
 
114
procedure TCheckSumFileSFV.ToStringList(slOut: TStringList);
-
 
115
begin
-
 
116
  inherited;
-
 
117
  SFVFileToStringList(sfvFile, slOut);
-
 
118
end;
-
 
119
 
83
end.
120
end.