55interface
66
77uses
8- Classes, SysUtils, torrent_miscellaneous, ngosang_trackerslist ;
8+ Classes, SysUtils, torrent_miscellaneous;
99
1010type
1111 TVerifyTrackerResult = record
@@ -20,6 +20,9 @@ TVerifyTrackerResult = record
2020 end ;
2121
2222
23+ function LoadConsoleLog (const FileNameWithPath: string; out StatusOK: boolean;
24+ out TorrentFilesCount: integer; out TrackersCount: integer): boolean;
25+
2326function GetProjectRootFolderWithPathDelimiter : string;
2427
2528function VerifyTrackerResult (var VerifyTracker: TVerifyTrackerResult): boolean;
@@ -561,4 +564,54 @@ function VerifyTrackerResult(var VerifyTracker: TVerifyTrackerResult): boolean;
561564 end ;
562565end ;
563566
567+ function LoadConsoleLog (const FileNameWithPath: string; out StatusOK: boolean;
568+ out TorrentFilesCount: integer; out TrackersCount: integer): boolean;
569+ var
570+ ConsoleStringlist: TStringList;
571+ begin
572+ {
573+ console_log.txt is only created in console mode.
574+ Show the in console mode the success/failure of the torrent update.
575+ First line status: 'OK' or 'ERROR: xxxxxxx' xxxxxxx = error description
576+ Second line files count: '1'
577+ Third line tracker count: 23
578+ Second and third line info are only valid if the first line is 'OK'
579+ }
580+
581+ // Result = true if file can be readed as expected.
582+ // with 2 lines of values if first line is 'OK'
583+
584+ ConsoleStringlist := TStringList.Create;
585+ try
586+ ConsoleStringlist.LoadFromFile(FileNameWithPath);
587+
588+ Result := ConsoleStringlist.Count > 0 ;
589+ if Result then
590+ begin
591+ StatusOK := ConsoleStringlist[0 ] = CONSOLE_SUCCESS_STATUS;
592+ end ;
593+
594+ if StatusOK then
595+ begin
596+ // The totall lines in the file must be 3
597+ Result := ConsoleStringlist.Count >= 3 ;
598+ if Result then
599+ begin
600+ Result := TryStrToInt(ConsoleStringlist[1 ], TorrentFilesCount);
601+ end ;
602+
603+ // read only if the TorrentFilesCount is successful
604+ if Result then
605+ begin
606+ Result := TryStrToInt(ConsoleStringlist[2 ], TrackersCount);
607+ end ;
608+ end ;
609+
610+ except
611+ Result := False;
612+ end ;
613+
614+ ConsoleStringlist.Free;
615+ end ;
616+
564617end .
0 commit comments