destructor TShitarabaThreadItem.Destroy;
begin
- if FDat <> nil then
- FDat.Free;
+ if FDat <> nil then begin
+ try
+ FDat.Free;
+ FDat := nil;
+ except
+ end;
+ end;
// \88ê\8e\9e\83t\83@\83C\83\8b\82Ì\8fê\8d\87\82Í\8dí\8f\9c\82·\82é
if FIsTemporary then
var
modified : Double;
tmp : PChar;
- downResult : string;
+ downResult : TStringList;
responseCode : Longint;
logStream : TFileStream;
uri : TIdURI;
uriList : TStringList;
datURL : string;
+ foundPos : Integer;
begin
{$IFDEF DEBUG}
ForceDirectoriesEx( Copy( FilePath, 1, LastDelimiter( '\', FilePath ) ) );
- //if FileExists( FilePath ) then
- // logStream := TFileStream.Create( FilePath, fmOpenReadWrite or fmShareDenyWrite )
- //else
+ // \81«----- \8dÅ\8fI\93I\82É\8dí\8f\9c\82·\82é\82±\82Æ -----\81«
+ // \82Ü\82¾ Subject.txt \82Ì\8f\88\97\9d\82ð\8f\91\82¢\82Ä\82¢\82È\82¢\82½\82ß\81AAllResCount \82É\92l\82ª\90Ý\92è\82³\82ê\82È\82¢\82Ì\82Å
+ // \88ê\93x\83\8d\81[\83h\82µ\82Ä\81A\83\8c\83X\82Ì\90\94\82ð\83J\83E\83\93\83g\82·\82é
+ AllResCount := 0;
+ if FileExists( FilePath ) then begin
+ if FDat <> nil then begin
+ try
+ FDat.Free;
+ FDat := nil;
+ except
+ end;
+ end;
+ FDat := TStringList.Create;
+ try
+ // dat \82Ì\93Ç\82Ý\8d\9e\82Ý
+ FDat.LoadFromFile( FilePath );
+ // \8ds\90\94\82Ì\83J\83E\83\93\83g
+ AllResCount := FDat.Count;
+ finally
+ FDat.Free;
+ FDat := nil;
+ end;
+ end;
+ // \81ª----- \8dÅ\8fI\93I\82É\8dí\8f\9c\82·\82é\82±\82Æ -----\81ª
+
+ if FileExists( FilePath ) then
+ logStream := TFileStream.Create( FilePath, fmOpenReadWrite or fmShareDenyWrite )
+ else
logStream := TFileStream.Create( FilePath, fmCreate or fmShareDenyWrite );
try
// \93Æ\8e©\82É\83_\83E\83\93\83\8d\81[\83h\82â\83t\83B\83\8b\83^\83\8a\83\93\83O\82ð\8ds\82í\82È\82¢\8fê\8d\87\82Í
modified := LastModified;
datURL :=
uri.Protocol + '://' + uri.Host + '/bbs/read.cgi/' +
- uriList.Strings[ 3 ] + '/' + uriList.Strings[ 4 ] + '/' + uriList.Strings[ 5 ] + '/';
+ uriList.Strings[ 3 ] + '/' + uriList.Strings[ 4 ] + '/' +
+ uriList.Strings[ 5 ] + '/' + IntToStr( AllResCount + 1 ) + '-n';
//responseCode := InternalDownload( PChar( datURL ), modified, tmp, Max( 0, logStream.Size - 1 ) );
responseCode := InternalDownload( PChar( datURL ), modified, tmp, 0 );
- {$IFDEF DEBUG}
- Writeln( 'responseCode:' + IntToStr( responseCode ) );
- {$ENDIF}
- if responseCode = 200 then begin
- downResult := string( tmp );
-
- downResult := Copy( downResult, Pos( '<dt', downResult ), Length( downResult ) );
- downResult := Copy( downResult, 1, Pos( '<table', downResult ) - 1 );
-
- if Length( downResult ) > 0 then begin
- LastModified := modified;
- IsLogFile := True;
- //logStream.Position := Max( 0, logStream.Size - 1 );
- logStream.Position := 0;
- logStream.Write( PChar( downResult )^, Length( downResult ) );
+ try
+ {$IFDEF DEBUG}
+ Writeln( 'responseCode:' + IntToStr( responseCode ) );
+ {$ENDIF}
+ if responseCode = 200 then begin
+ downResult := TStringList.Create;
+ try
+ downResult.Text := string( tmp );
+
+ foundPos := Pos( '<dt', downResult.Text );
+ downResult.Text := Copy( downResult.Text, foundPos, Length( downResult.Text ) );
+ if foundPos > 0 then begin
+ foundPos := Pos( '<table', downResult.Text ) - 1;
+ if foundPos > 0 then
+ downResult.Text := Copy( downResult.Text, 1, foundPos );
+
+ MessageBox( 0, PChar( IntToStr( downResult.Count ) ), '', MB_OK );
+ if downResult.Count > 0 then begin
+ LastModified := modified;
+ IsLogFile := True;
+ NewReceive := AllResCount + 1;
+ AllResCount := AllResCount + downResult.Count;
+ NewResCount := downResult.Count;
+
+ logStream.Position := logStream.Size;
+ logStream.Write( PChar( downResult.Text )^, Length( downResult.Text ) );
+ end;
+ end else begin
+ responseCode := -1;
+ end;
+ finally
+ downResult.Free;
+ end;
end;
+ finally
+ DisposeResultString( tmp );
end;
-
- DisposeResultString( tmp );
finally
logStream.Free;
end;
// GetRes \82ð\8cÄ\82Î\82ê\82é\82±\82Æ\82ª\97\\91z\82³\82ê\82é\82Ì\82Å FDat \82ð\90¶\90¬\82µ\82Ä\82¨\82
try
if FDat <> nil then begin
- FDat.Free;
- FDat := nil;
+ try
+ FDat.Free;
+ FDat := nil;
+ except
+ end;
end;
if IsLogFile then begin
// dat \82Ì\93Ç\82Ý\8d\9e\82Ý