OSDN Git Service

・TThreadItem の作成時に IsLogFile が設定されるようになった。
[gikonavigoeson/gikonavi.git] / BoardGroup.pas
index 1edfba4..1db76d2 100644 (file)
@@ -380,14 +380,13 @@ const
 //     COLUMN_THREADITEM: array[0..3] of string = ('\83X\83\8c\83b\83h\96¼', '\83J\83E\83\93\83g', '\8f\84\89ñ\97\\96ñ', '\91O\89ñ\8f\84\89ñ\93ú\8e\9e');
 
 function       BBSsFindBoardFromBBSID(
-       inBBSID         : string
+       inBBSID : string
 ) : TBoard;
 var
-       i, bound        : Integer;
+       i                               : Integer;
 begin
 
-       bound := Length( BBSs ) - 1;
-       for i := 0 to bound do begin
+       for i := Length( BBSs ) - 1 downto 0 do begin
                Result := BBSs[ i ].FindBBSID( inBBSID );
                if Result <> nil then
                        Exit;
@@ -398,14 +397,13 @@ begin
 end;
 
 function       BBSsFindBoardFromURL(
-       inURL                   : string
+       inURL   : string
 ) : TBoard;
 var
-       i, bound        : Integer;
+       i                       : Integer;
 begin
 
-       bound := Length( BBSs ) - 1;
-       for i := 0 to bound do begin
+       for i := Length( BBSs ) - 1 downto 0 do begin
                Result := BBSs[ i ].FindBoardFromURL( inURL );
                if Result <> nil then
                        Exit;
@@ -416,14 +414,13 @@ begin
 end;
 
 function       BBSsFindBoardFromTitle(
-       inTitle         : string
+       inTitle : string
 ) : TBoard;
 var
-       i, bound        : Integer;
+       i                               : Integer;
 begin
 
-       bound := Length( BBSs ) - 1;
-       for i := 0 to bound do begin
+       for i := Length( BBSs ) - 1 downto 0 do begin
                Result := BBSs[ i ].FindBoardFromTitle( inTitle );
                if Result <> nil then
                        Exit;
@@ -434,14 +431,13 @@ begin
 end;
 
 function       BBSsFindThreadFromURL(
-       inURL                   : string
+       inURL   : string
 ) : TThreadItem;
 var
-       i, bound        : Integer;
+       i                       : Integer;
 begin
 
-       bound := Length( BBSs ) - 1;
-       for i := 0 to bound do begin
+       for i := Length( BBSs ) - 1 downto 0 do begin
                Result := BBSs[ i ].FindThreadFromURL( inURL );
                if Result <> nil then
                        Exit;
@@ -514,19 +510,14 @@ end;
 
 function TBBS.FindBBSID(BBSID: string): TBoard;
 var
-       i: Integer;
-       Category: TCategory;
-       Board: TBoard;
+       i       : Integer;
 begin
-       Result := nil;
-       for i := 0 to Count - 1 do begin
-               Category := Items[i];
-               Board := Category.FindBBSID(BBSID);
-               if Board <> nil then begin
-                       Result := Board;
+       for i := Count - 1 downto 0 do begin
+               Result := Items[ i ].FindBBSID(BBSID);
+               if Result <> nil then
                        Exit;
-               end;
        end;
+       Result := nil;
 end;
 
 //*************************************************************************
@@ -535,18 +526,13 @@ end;
 function TBBS.FindBoardFromTitle(Title: string): TBoard;
 var
        i: Integer;
-       Category: TCategory;
-       Board: TBoard;
 begin
-       Result := nil;
-       for i := 0 to Count - 1 do begin
-               Category := Items[i];
-               Board := Category.FindBoardFromTitle(Title);
-               if Board <> nil then begin
-                       Result := Board;
+       for i := Count - 1 downto 0 do begin
+               Result := Items[ i ].FindBoardFromTitle(Title);
+               if Result <> nil then
                        Exit;
-               end;
        end;
+       Result := nil;
 end;
 
 //*************************************************************************
@@ -554,19 +540,14 @@ end;
 //*************************************************************************)
 function TBBS.FindBoardFromURL(inURL: string): TBoard;
 var
-       i: Integer;
-       Category: TCategory;
-       Board: TBoard;
+       i                                       : Integer;
 begin
-       Result := nil;
-       for i := 0 to Count - 1 do begin
-               Category := Items[i];
-               Board := Category.FindBoardFromURL(inURL);
-               if Board <> nil then begin
-                       Result := Board;
+       for i := Count - 1 downto 0 do begin
+               Result := Items[ i ].FindBoardFromURL( inURL );
+               if Result <> nil then
                        Exit;
-               end;
        end;
+       Result := nil;
 end;
 
 //*************************************************************************
@@ -574,9 +555,9 @@ end;
 //*************************************************************************)
 function TBBS.FindThreadFromURL(inURL: string): TThreadItem;
 var
-       i: Integer;
+       i       : Integer;
 begin
-       for i := 0 to Count - 1 do begin
+       for i := Count - 1 downto 0 do begin
                Result := Items[ i ].FindThreadFromURL( inURL );
                if Result <> nil then
                        Exit;
@@ -673,15 +654,15 @@ end;
 
 function TCategory.FindBBSID(BBSID: string): TBoard;
 var
-       i: integer;
+       i       : integer;
 begin
-       Result := nil;
-       for i := 0 to Count - 1 do begin
+       for i := Count - 1 downto 0 do begin
                if Items[i].FBBSID = BBSID then begin
                        Result := Items[i];
                        Exit;
                end;
        end;
+       Result := nil;
 end;
 
 //*************************************************************************
@@ -689,15 +670,15 @@ end;
 //*************************************************************************)
 function TCategory.FindBoardFromTitle(Title: string): TBoard;
 var
-       i: integer;
+       i       : integer;
 begin
-       Result := nil;
-       for i := 0 to Count - 1 do begin
+       for i := Count - 1 downto 0 do begin
                if Items[i].FTitle = Title then begin
                        Result := Items[i];
                        Exit;
                end;
        end;
+       Result := nil;
 end;
 
 //*************************************************************************
@@ -705,15 +686,15 @@ end;
 //*************************************************************************)
 function TCategory.FindBoardFromURL(inURL: string): TBoard;
 var
-       i: integer;
+       i       : Integer;
 begin
-       Result := nil;
-       for i := 0 to Count - 1 do begin
+       for i := Count - 1 downto 0 do begin
                if Pos( Items[i].URL, inURL ) = 1 then begin
                        Result := Items[i];
                        Exit;
                end;
        end;
+       Result := nil;
 end;
 
 //*************************************************************************
@@ -724,7 +705,7 @@ var
        i                                               : Integer;
 begin
 
-       for i := 0 to Count - 1 do begin
+       for i := Count - 1 downto 0 do begin
                Result := Items[ i ].FindThreadFromURL( inURL );
                if Result <> nil then
                        Exit;
@@ -795,9 +776,8 @@ constructor TBoard.Create(
        inURL                   : string
 );
 var
-       foundPos                        : Integer;
        protocol, host, path, document, port, bookmark  : string;
-       BBSID, BBSKey   : string;
+       BBSID                   : string;
 begin
 
        Create;
@@ -808,16 +788,16 @@ begin
 
        // \83v\83\89\83O\83C\83\93\82É TBoardItem \82ª\8dì\90¬\82³\82ê\82½\82±\82Æ\82ð\93`\82¦\82é
        if inPlugIn = nil then begin
-    // subject.txt \82Ì\95Û\91\83p\83X\82ð\90Ý\92è
-    GikoSys.ParseURI( inURL, protocol, host, path, document, port, bookmark );
-    if GikoSys.Is2chHost( host ) then
-      FilePath :=
-        IncludeTrailingPathDelimiter( GikoSys.Setting.LogFolder ) +
-        BBS2CH_LOG_FOLDER + PATH_DELIM + BBSID + PATH_DELIM + SUBJECT_FILENAME
-    else
-      FilePath :=
-        IncludeTrailingPathDelimiter( GikoSys.Setting.LogFolder ) +
-        EXTERNAL_LOG_FOLDER + PATH_DELIM + host + PATH_DELIM + BBSID + PATH_DELIM + SUBJECT_FILENAME
+               // subject.txt \82Ì\95Û\91\83p\83X\82ð\90Ý\92è
+               GikoSys.ParseURI( inURL, protocol, host, path, document, port, bookmark );
+               if GikoSys.Is2chHost( host ) then
+                       FilePath :=
+                               IncludeTrailingPathDelimiter( GikoSys.Setting.LogFolder ) +
+                               BBS2CH_LOG_FOLDER + PATH_DELIM + BBSID + PATH_DELIM + SUBJECT_FILENAME
+               else
+                       FilePath :=
+                               IncludeTrailingPathDelimiter( GikoSys.Setting.LogFolder ) +
+                               EXTERNAL_LOG_FOLDER + PATH_DELIM + host + PATH_DELIM + BBSID + PATH_DELIM + SUBJECT_FILENAME
        end else begin
                inPlugIn.CreateBoardItem( DWORD( Self ) );
        end;
@@ -956,7 +936,7 @@ begin
        if not IsThreadDatRead then
                GikoSys.ReadSubjectFile( Self );
                
-       for i := 0 to Count - 1 do begin
+       for i := Count - 1 downto 0 do begin
                if Pos( Items[ i ].URL, inURL ) = 1 then begin
                        Result := Items[ i ];
                        Exit;
@@ -1393,7 +1373,9 @@ begin
                        else
                                FilePath :=
                                        IncludeTrailingPathDelimiter( GikoSys.Setting.LogFolder ) +
-                                       EXTERNAL_LOG_FOLDER + PATH_DELIM + host + PATH_DELIM + BBSID + PATH_DELIM + BBSKey + '.dat'
+                                       EXTERNAL_LOG_FOLDER + PATH_DELIM + host + PATH_DELIM + BBSID + PATH_DELIM + BBSKey + '.dat';
+                       FileName        := BBSKey + '.dat';
+      IsLogFile        := FileExists( FilePath );
                end;
        end else begin
                // \83v\83\89\83O\83C\83\93\82É TThreadItem \82ª\8dì\90¬\82³\82ê\82½\82±\82Æ\82ð\93`\82¦\82é