type
T2chThreadItem = class(TThreadItem)
private
- FLogFilePath : string;
FIsTemporary : Boolean;
FDat : TStringList;
// *************************************************************************
// \83R\83\93\83X\83g\83\89\83N\83^
// *************************************************************************
-constructor T2chThreadItem.Create( inInstance : DWORD );
+constructor T2chThreadItem.Create(
+ inInstance : DWORD
+);
+var
+ uri : TIdURI;
+ uriList : TStringList;
begin
inherited;
OnGetHeader := GetHeader;
OnGetFooter := GetFooter;
- FLogFilePath := '';
+ FilePath := '';
FIsTemporary := False;
Randomize;
+ uri := TIdURI.Create( URL );
+ uriList := TStringList.Create;
+ try
+ YofUtils.ExtractHttpFields( ['/', '?'], [], uri.Path, uriList );
+ FilePath := LogFolder + '2ch\' + uriList.Strings[ 3 ] + '\' + uriList.Strings[ 4 ] + '.dat';
+ IsLogFile := FileExists( FilePath );
+ finally
+ uri.Free;
+ uriList.Free;
+ end;
+
end;
// *************************************************************************
// \88ê\8e\9e\83t\83@\83C\83\8b\82Ì\8fê\8d\87\82Í\8dí\8f\9c\82·\82é
if FIsTemporary then
- DeleteFile( FLogFilePath );
+ DeleteFile( FilePath );
inherited;
YofUtils.ExtractHttpFields( ['/', '?'], [], uri.Path, uriList );
// http://pc2.2ch.net/test/read.cgi/software/1065250336/l50
// protocol://host/1/2/3/4/uriList.Count - 1
- FLogFilePath := FLogFilePath + '2ch\' + uriList.Strings[ 2 ] + '\' + uriList.Strings[ 3 ];
- except
- uri.Free;
- uriList.Free;
- raise;
- end;
-
- if FLogFilePath = '' then begin
- FLogFilePath := LogFolder;
- if FLogFilePath = '' then begin
+ if LogFolder = '' then begin
// \82Ç\82±\82É\95Û\91¶\82µ\82Ä\82¢\82¢\82Ì\82©\95ª\82©\82ç\82È\82¢\82Ì\82Å\88ê\8e\9e\83t\83@\83C\83\8b\82É\95Û\91¶
- FLogFilePath := TemporaryFile;
- FIsTemporary := True;
+ FilePath := TemporaryFile;
+ FIsTemporary := True;
end else begin
- FLogFilePath := FLogFilePath + '2ch\' + uriList.Strings[ 3 ] + '\' + uriList.Strings[ 4 ] + '.dat';
+ FilePath := LogFolder + '2ch\' + uriList.Strings[ 3 ] + '\' + uriList.Strings[ 4 ] + '.dat';
end;
- end;
- logStream := TFileStream.Create( FLogFilePath, fmOpenReadWrite 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Í
- // InternalDownload \82É\94C\82¹\82é\82±\82Æ\82ª\8fo\97\88\82é
- modified := LastModified;
- // http://pc2.2ch.net/software/1000000000.dat
- datURL :=
- uri.Protocol + '://' + uri.Host + '/' +
- uriList.Strings[ 3 ] + '/' + uriList.Strings[ 4 ] + '.dat';
- responseCode := InternalDownload( PChar( datURL ), modified, tmp, Max( 0, logStream.Size - 1 ) );
-
- if responseCode = 0 then begin
- LastModified := modified;
- IsLogFile := True;
-
- logStream.Position := Max( 0, logStream.Size - 1 );
- logStream.Write( tmp, Length( tmp ) );
- end;
-
- DisposeResultString( tmp );
+ logStream := TFileStream.Create( FilePath, fmOpenReadWrite 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Í
+ // InternalDownload \82É\94C\82¹\82é\82±\82Æ\82ª\8fo\97\88\82é
+ modified := LastModified;
+ // http://pc2.2ch.net/software/1000000000.dat
+ datURL :=
+ uri.Protocol + '://' + uri.Host + '/' +
+ uriList.Strings[ 3 ] + '/' + uriList.Strings[ 4 ] + '.dat';
+ responseCode := InternalDownload( PChar( datURL ), modified, tmp, Max( 0, logStream.Size - 1 ) );
+
+ if responseCode = 0 then begin
+ LastModified := modified;
+ IsLogFile := True;
+
+ logStream.Position := Max( 0, logStream.Size - 1 );
+ logStream.Write( tmp, Length( tmp ) );
+ end;
+
+ DisposeResultString( tmp );
+ finally
+ logStream.Free;
+ end;
finally
- logStream.Free;
+ uri.Free;
+ uriList.Free;
end;
end;
FDat.Free;
if IsLogFile then begin
FDat := TStringList.Create;
- FDat.LoadFromFile( FLogFilePath );
+ FDat.LoadFromFile( FilePath );
end;
except
end;