procedure LoadRoundBoardFile;
procedure LoadRoundThreadFile;
procedure SaveRoundFile;
+
+ procedure URLReplace(oldURLs: TStringList; newURLs :TStringList);
end;
TRoundItem = class(TObject)
TRoundItem(FBoardList[i]).Free;
FBoardList.Delete(i);
end;
+ FBoardList.Capacity := FBoardList.Count;
for i := FItemList.Count - 1 downto 0 do begin
if FItemList[i] <> nil then
TRoundItem(FItemList[i]).Free;
FItemList.Delete(i);
end;
+ FItemList.Capacity := FItemList.Count;
end;
function TRoundList.Find(Board: TBoard): Integer;
Item: TRoundItem;
begin
Result := -1;
- for i := 0 to FItemList.Count - 1 do begin
- Item := TRoundItem(FItemList[i]);
- if Item.FRoundType <> RoundType then Continue;
- if Item.FURL = URL then begin
- Result := i;
- Exit;
+ if RoundType = grtItem then begin
+ for i := 0 to FItemList.Count - 1 do begin
+ Item := TRoundItem(FItemList[i]);
+ if Item.FRoundType <> RoundType then Continue;
+ if Item.FURL = URL then begin
+ Result := i;
+ Exit;
+ end;
end;
- end;
+ end else begin
+ for i := 0 to FBoardList.Count - 1 do begin
+ Item := TRoundItem(FBoardList[i]);
+ if Item.FRoundType <> RoundType then Continue;
+ if Item.FURL = URL then begin
+ Result := i;
+ Exit;
+ end;
+ end;
+ end;
end;
procedure TRoundList.Delete(URL: string; RoundType: TGikoRoundType);
var
begin
idx := Find(URL, RoundType);
if idx <> -1 then begin
- Item := TRoundItem(FItemList[idx]);
- Item.Free;
- FItemList.Delete(idx);
+
if RoundType = grtBoard then begin
+ Item := TRoundItem(FBoardList[idx]);
+ Item.Free;
+ FBoardList.Delete(idx);
board := BBSsFindBoardFromURL(URL);
- board.Round := False;
- board.RoundName := '';
+ if board <> nil then begin
+ board.Round := False;
+ board.RoundName := '';
+ end;
end else begin
+ Item := TRoundItem(FItemList[idx]);
+ Item.Free;
+ FItemList.Delete(idx);
+
threadItem := BBSsFindThreadFromURL(URL);
- threadItem.Round := false;
- threadItem.RoundName := '';
+ if threadItem <> nil then begin
+ threadItem.Round := false;
+ threadItem.RoundName := '';
+ end;
end;
end;
end;
errorSl: TStringList;
errorFileName: string;
Item: TRoundItem;
+ delCount: Integer;
begin
sl := TStringList.Create;
errorSl := TStringList.Create;
end;
end;
//Item := TRoundItem.Create;
+ delCount := 0;
//\82P\8ds\96Ú\82Í\83o\81[\83W\83\87\83\93
if sl[0] = ROUND_INDEX_VERSION then begin
- for i := sl.Count - 1 downto 1 do begin
- Item := ParseRoundBoardLine(sl[i]);
+ for i := 1 to sl.Count - 1 do begin
+ Item := ParseRoundBoardLine(sl[i - delCount]);
if Item <> nil then begin
FBoardList.Add(Item);
RoundNameList.Add(Item.RoundName);
end else begin
- errorSl.Add( sl[i] );
- sl.Delete(i);
+ errorSl.Add( sl[i - delCount] );
+ sl.Delete(i- delCount);
+ Inc(delCount);
end;
end;
end else begin
if FOldFileRead then begin //\83M\83R\83i\83r\96{\91Ì\82ª\83{\81[\83h\83t\83@\83C\83\8b\82ð\82æ\82Ý\82Æ\82Á\82½\8cã\82¶\82á\82È\82¢\82Æ\83N\83\89\83b\83V\83\85\82·\82é\82Ì\82Å
- for i := sl.Count - 1 downto 1 do begin
- Item := ParseOldRoundBoardLine(sl[i]);
+ for i := 1 to sl.Count - 1 do begin
+ Item := ParseOldRoundBoardLine(sl[i - delCount]);
if Item <> nil then begin
FBoardList.Add(Item);
RoundNameList.Add(Item.RoundName);
end else begin
- errorSl.Add( sl[i] );
- sl.Delete(i);
+ errorSl.Add( sl[i- delCount] );
+ sl.Delete(i- delCount);
+ Inc(delCount);
end;
end;
end else
errorSl: TStringList;
errorFileName: string;
Item: TRoundItem;
+ delCount: Integer;
// boardList : TStringList;
begin
// boardList := TStringList.Create;
end;
end;
//Item := TRoundItem.Create;
+ delCount := 0;
//\82P\8ds\96Ú\82Í\83o\81[\83W\83\87\83\93
if sl[0] = ROUND_INDEX_VERSION then begin
- for i := sl.Count - 1 downto 1 do begin
- Item := ParseRoundThreadLine(sl[i]);
+ for i := 1 to sl.Count - 1 do begin
+ Item := ParseRoundThreadLine(sl[i - delCount]);
if Item <> nil then begin
FItemList.Add(Item);
RoundNameList.Add(Item.RoundName);
end else begin
- errorSl.Add(sl[i]);
- sl.Delete(i);
+ errorSl.Add(sl[i - delCount]);
+ sl.Delete(i - delCount);
+ Inc(delCount);
end;
end;
end else begin
LoadRoundBoardFile;
- for i := sl.Count - 1 downto 1 do begin
- Item := ParseOldRoundThreadLine(sl[i]);
+ for i := 1 to sl.Count - 1 do begin
+ Item := ParseOldRoundThreadLine(sl[i - delCount]);
if Item <> nil then begin
FItemList.Add(Item);
RoundNameList.Add(Item.RoundName);
end else begin
- errorSl.Add(sl[i]);
- sl.Delete(i);
+ errorSl.Add(sl[i - delCount]);
+ sl.Delete(i - delCount);
+ Inc(delCount);
end;
end;
end;
errorSl.SaveToFile(errorFileName);
end;
finally
+ errorSl.Free;
sl.Free;
// boardList.Free;
end;
try
FileName := GikoSys.GetConfigDir + ROUND_BOARD_FILENAME;
sl.Add(ROUND_INDEX_VERSION);
- for i := FBoardList.Count - 1 downto 0 do begin
+ for i := 0 to FBoardList.Count - 1 do begin
Item := TRoundItem(FBoardList[i]);
s := Item.URL + #1
+ Item.BoardTitle + #1
sl.Clear;
FileName := GikoSys.GetConfigDir + ROUND_ITEM_FILENAME;
sl.Add(ROUND_INDEX_VERSION);
- for i := FItemList.Count - 1 downto 0 do begin
+ for i := 0 to FItemList.Count - 1 do begin
Item := TRoundItem(FItemList[i]);
s := Item.URL + #1
+ Item.BoardTitle + #1
end;
except
Result := nil;
- Exit;
+ break;
+ end;
+ end;
+end;
+procedure TRoundList.URLReplace(oldURLs: TStringList; newURLs :TStringList);
+var
+ i: Integer;
+ j: Integer;
+ tempString: string;
+ tmpURL: string;
+ oldHost: string;
+ oldBoardName: string;
+ newHost: string;
+ newBoardName: string;
+begin
+ if oldURLs.Count <> newURLs.Count then
+ Exit;
+ //\82±\82±\82©\82ç\81ABoard\82ÌURL\82Ì\95Ï\8dX
+ for j :=0 to oldURLs.Count - 1 do begin
+ for i :=0 to FBoardList.Count - 1 do begin
+ if TRoundItem(FBoardList[i]).FURL = oldURLs[j] then
+ TRoundItem(FBoardList[i]).FURL := newURLs[j];
+ end;
+ end;
+ //\82±\82±\82Ü\82Å\81ABoard\82ÌURL\82Ì\95Ï\8dX
+
+ //\82±\82±\82©\82ç\81AThread\82ÌURL\82Ì\95Ï\8dX
+ //\96Ê\93|\82¾\82¯\82Çthread\82Í\82»\82ê\82¼\82êURL\82ð\83`\83\83\83b\83N\82µ\82È\82ª\82ç\82â\82Á\82Ä\82©\82È\82«\82á\82¢\82¯\82È\82¢\81B
+ for i := 0 to oldURLs.Count - 1 do begin
+ tmpURL := Copy(oldURLs[i], 1, Length(oldURLs[i]) -1);
+ oldHost := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );
+ oldBoardName := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';
+ tmpURL := Copy(newURLs[i], 1, Length(newURLs[i]) -1);
+ newHost := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );
+ newBoardName := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';
+
+ for j := 0 to FItemList.Count - 1 do begin
+ tempString := TRoundItem(FItemList[j]).FURL;
+ if ( AnsiPos(oldBoardName, tempString) <> 0 ) and ( AnsiPos(oldHost, tempString ) <> 0 ) then begin
+ tempString := StringReplace(tempString, oldHost, newHost,[]);
+ TRoundItem(FItemList[j]).FURL := tempString;
+ end;
end;
end;
+ //\82±\82±\82Ü\82Å\81AThread\82ÌURL\82Ì\95Ï\8dX
+
end;
end.