sgindgen.cpp

Go to the documentation of this file.
00001 // $Id: sgindgen.cpp 1361 2006-06-25 16:43:38Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 // Gallery index generation classes
00099 
00100 /*
00101 */
00102 
00103 #include "camtypes.h"
00104 #include "sgindgen.h"
00105 
00106 /*#include "ccfile.h"
00107 //#include "pathname.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00108 //#include "thumb.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00109 #include "sgliboil.h"
00110 //#include "richard.h"
00111 #include "progress.h"
00112 //#include "resource.h"
00113 //#include "errors.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00114 //#include "fixmem.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00115 #ifndef WEBSTER
00116 #include "extfilts.h"
00117 #include "imglib.h"
00118 #include "img_err.h"
00119 #endif  //WEBSTER
00120 //#include "accures.h"
00121 //#include "oilfltrs.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00122 //#include "resource.h"
00123 #include "sgscanf.h"
00124 //#include "simon.h"        // for _R(IDS_CONTINUE)
00125 //#include "sgscan.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00126 //#include "richard2.h"
00127 //#include "camfiltr.h" // BaseCamelotFilter - new version 2 native/web filter - in camtypes.h [AUTOMATICALLY REMOVED]
00128 //#include "cxfdefs.h"      // CXF_IDWORD1, signature of new file format - in camtypes.h [AUTOMATICALLY REMOVED]
00129 
00130 #include "bmpexdoc.h"
00131 #include "bmpfiltr.h"
00132 #include "prvwflt.h"
00133 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00134 */
00135 
00136 extern BOOL MakeShortPath(LPTSTR lpszPath, size_t cchMaxLen);
00137 
00138 DECLARE_SOURCE("$Revision: 1361 $");
00139 
00140 CC_IMPLEMENT_DYNCREATE(GenerateIndexFile, CCObject)
00141 CC_IMPLEMENT_DYNCREATE(IndGenFileBuffer, CCObject)
00142 
00143 PORTNOTE("other", "Removed most of sgindgen.cpp" )
00144 #ifndef EXCLUDE_FROM_XARALX
00145 
00146 #define new CAM_DEBUG_NEW
00147 
00148 // Static initialisation
00149 
00150 // Preference setting saying whether thumbnail generation is required   
00151 #ifdef _DEBUG
00152 #ifdef _BATCHING
00153 BOOL GenerateIndexFile::CreateFontIndexes = TRUE;
00154 #else
00155 BOOL GenerateIndexFile::CreateFontIndexes = FALSE;
00156 #endif
00157 #else
00158 BOOL GenerateIndexFile::CreateFontIndexes = FALSE;
00159 #endif
00160 
00161 // Use old indexes and doc comments for index generation
00162 BOOL GenerateIndexFile::UseOldIndexes = TRUE;
00163 BOOL GenerateIndexFile::UseDocComments = TRUE;
00164 
00165 // Use automatic index update technology ?
00166 BOOL GenerateIndexFile::UseAutomaticUpdate = FALSE;
00167 
00168 // define this to add filenames without their extensions as default descriptions
00169 //#define FILENAME_AS_DEFAULT_DESCRIPTION
00170 
00171 // Display warnings unless told not to
00172 static BOOL QuietThumbnail = FALSE;
00173 
00174 // Keep doing index until told not to
00175 static BOOL StopIndGen = FALSE;
00176 
00177 static FilePos LastFoundItemInIndex = 0;
00178 
00179 // Tmp disk file for index ripping
00180 //CCDiskFile *TmpDiskFile = NULL;
00181 
00182 #endif
00183 
00184 /***********************************************************************************************
00185 
00186 >   GenerateIndexFile::GenerateIndexFile()
00187 
00188     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00189     Created:    27/05/95
00190 
00191     Inputs:     
00192     Outputs:
00193     Returns:
00194 
00195     Purpose:    Variable initalising constructor
00196     Notes:
00197 
00198 ***********************************************************************************************/
00199 
00200 GenerateIndexFile::GenerateIndexFile()
00201 {
00202     LibType = SGLib_Blank;
00203     DoThumbnails = FALSE;
00204     Author = _T("");
00205     IndexFile = NULL;
00206     IndexCountOff = 0;
00207     hSearch = NULL;
00208     ID = 0;
00209     TotalFiles = 0;
00210     TmpIndexFile = NULL;
00211     OldIndexStart = 0;
00212     OldIndexDescriptionField = OldIndexKeywordField = OldIndexTitleField = 0;
00213     OldIndexOK = FALSE;
00214     OldIndexDescription = "";
00215 //  TmpDiskFile = NULL;
00216 }
00217 
00218 #if 0
00219 
00220 /***********************************************************************************************
00221 
00222 >   BOOL GenerateIndexFile::CloseSearchHandle(void);
00223 
00224     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00225     Created:    09/04/95
00226 
00227     Inputs:     
00228     Outputs:
00229     Returns:    TRUE if things went ok.
00230 
00231     Purpose:    Close the search handle
00232     Notes:
00233 
00234 ***********************************************************************************************/
00235 
00236 BOOL GenerateIndexFile::CloseSearchHandle(void)
00237 {
00238     // Close the search handle
00239     if(hSearch != NULL) {
00240         if (!FindClose(hSearch)) {
00241             ERROR3("Couldn't close search handle.");
00242             return FALSE;
00243         }
00244         else
00245         {
00246             hSearch = NULL;
00247         }
00248     }
00249     return TRUE;
00250 }
00251     
00252 /***********************************************************************************************
00253 
00254 >   BOOL GenerateIndexFile::CloseIndexFileHandle(void);
00255 
00256     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00257     Created:    09/04/95
00258 
00259     Inputs:     
00260     Outputs:
00261     Returns:    TRUE if things went ok.
00262 
00263     Purpose:    Close the file handle
00264     Notes:
00265 
00266 ***********************************************************************************************/
00267 
00268 BOOL GenerateIndexFile::CloseIndexFileHandle(void)
00269 {
00270     if(IndexFile != NULL)
00271     {
00272         IndexFile->close();
00273         delete IndexFile;
00274         IndexFile = NULL;
00275     }
00276     return TRUE;
00277 }
00278 
00279 
00280 /***********************************************************************************************
00281 
00282 >   static BOOL GenerateIndexFile::IsDirectoryReadOnly(PathName *Directory);
00283 
00284     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00285     Created:    07/04/95
00286 
00287     Inputs:     Directory   - location of directory we're interested in (without trailing \)
00288     Outputs:
00289     Returns:    TRUE if things the specified directory is read only
00290 
00291     Purpose:    See Returns...
00292     Notes:
00293 
00294 ***********************************************************************************************/
00295 
00296 BOOL GenerateIndexFile::IsDirectoryReadOnly(PathName *Directory)
00297 {
00298     ERROR3IF(Directory == NULL, "GenerateIndexFile::IsDirectoryReadOnly given a NULL dir");
00299 
00300     String_256 ROPathStr(Directory->GetPath(TRUE));
00301     ROPathStr += TEXT("XaraInf");               // Read only check - not displayed, etc...
00302     PathName ROPath(ROPathStr);
00303     Error::ClearError();
00304 
00305     CCDiskFile ROFile(1024, FALSE, TRUE);
00306     BOOL ReadOnly = TRUE;
00307     BOOL CreatedFile = FALSE;
00308 
00309     // Exceptions here mean the directory is RO (or there was some other problem)
00310     TRY
00311     {
00312         CreatedFile = ROFile.open(ROPath, ios::out);
00313     }
00314         
00315     CATCH(CFileException, e)
00316     {
00317         // The directory with the files in is READ ONLY...
00318         ReadOnly = TRUE;
00319         Error::ClearError();
00320     }
00321     END_CATCH
00322 
00323     // Make sure that the files are closed and the memory is reclaimed properly...
00324     if (ROFile.isOpen())
00325         ROFile.close();
00326 
00327     if(CreatedFile)
00328     {
00329         SGLibOil::FileDelete(&ROPath);
00330         return FALSE;
00331     }
00332 
00333     return TRUE;
00334 }
00335 
00336 /***********************************************************************************************
00337 
00338 >   static BOOL GenerateIndexFile::CheckForRemote(PathName *FilesDirectory, String_256 *RemoteDirectory);
00339 
00340     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00341     Created:    07/04/95
00342 
00343     Inputs:     FilesDirectory  - location of directory with files in, on read only media
00344     Outputs:    RemoteDirectory - location of existing indexed remote directory
00345     Returns:    TRUE if we found a remote index directory
00346 
00347     Purpose:    Given a directory on a CD (for example), check whether we've already done
00348                 a remote index for it or not... And return its location.
00349     Notes:
00350 
00351 ***********************************************************************************************/
00352 
00353 BOOL GenerateIndexFile::CheckForRemote(PathName *FilesDirectory, String_256 *RemoteDirectory)
00354 {
00355     ERROR3IF(FilesDirectory == NULL || RemoteDirectory == NULL, "GenerateIndexFile::CheckForRemote given NULL args");
00356 
00357     *RemoteDirectory = Library::RemoteIndexLocation;
00358     BOOL UseTmp = FALSE;
00359 
00360     if(RemoteDirectory->Length()==0)
00361         UseTmp = TRUE;
00362     else
00363     {
00364         PathName RemLocPath(*RemoteDirectory);
00365         if(!RemLocPath.IsValid() || !SGLibOil::FileExists(&RemLocPath) || IsDirectoryReadOnly(&RemLocPath))
00366             UseTmp = TRUE;
00367     }
00368 
00369     if(UseTmp)
00370     {
00371         TCHAR *OSTMP = _tgetenv("TEMP");
00372         if(OSTMP == NULL)
00373         {
00374             //PathName RemLocPath(*RemoteDirectory);
00375 
00376             // Check the specified remote directory isn't read only
00377             //if(IsDirectoryReadOnly(&RemLocPath) || RemLocPath)
00378             //{
00379             *RemoteDirectory = TEXT("");
00380             return FALSE;
00381             //}
00382         }
00383 
00384         camStrcpy((TCHAR *)*RemoteDirectory, OSTMP);
00385     }
00386 
00387     String_256 TmpDir(FilesDirectory->GetFileName(FALSE));
00388     String_256 FPath(FilesDirectory->GetPath());
00389 
00390     if(SGLibOil::IsRootDirectory(&FPath))
00391     {
00392 /*      String_256 Test("\\\\deepfried\\chicken");
00393         GiveMeAValidDirectoryName(&Test, &TmpDir);
00394         ERROR3_PF(("%s -> %s", (TCHAR *)Test, (TCHAR *)TmpDir));
00395 
00396         Test = "a:\\";
00397         GiveMeAValidDirectoryName(&Test, &TmpDir);
00398         ERROR3_PF(("%s -> %s", (TCHAR *)Test, (TCHAR *)TmpDir));
00399 
00400         Test = "\\fred\\fish";
00401         GiveMeAValidDirectoryName(&Test, &TmpDir);
00402         ERROR3_PF(("%s -> %s", (TCHAR *)Test, (TCHAR *)TmpDir));
00403 
00404         Test = "\\\\fred\\fish";
00405         GiveMeAValidDirectoryName(&Test, &TmpDir);
00406         ERROR3_PF(("%s -> %s", (TCHAR *)Test, (TCHAR *)TmpDir));
00407 
00408         Test = "\\\\fred\\fish\\fosh";
00409         GiveMeAValidDirectoryName(&Test, &TmpDir);
00410         ERROR3_PF(("%s -> %s", (TCHAR *)Test, (TCHAR *)TmpDir));
00411 
00412         Test = "x\\\\fred\\fish\\fosh";
00413         GiveMeAValidDirectoryName(&Test, &TmpDir);
00414         ERROR3_PF(("%s -> %s", (TCHAR *)Test, (TCHAR *)TmpDir));
00415 
00416         Test = "\\\\wibble";
00417         GiveMeAValidDirectoryName(&Test, &TmpDir);
00418         ERROR3_PF(("%s -> %s", (TCHAR *)Test, (TCHAR *)TmpDir));
00419 
00420         Test = "\\\\wibble\\";
00421         GiveMeAValidDirectoryName(&Test, &TmpDir);
00422         ERROR3_PF(("%s -> %s", (TCHAR *)Test, (TCHAR *)TmpDir));
00423 
00424         Test = "\\\\wibble\\\\";
00425         GiveMeAValidDirectoryName(&Test, &TmpDir);
00426         ERROR3_PF(("%s -> %s", (TCHAR *)Test, (TCHAR *)TmpDir));
00427 
00428         Test = "\\\\wibble\\ ";
00429         GiveMeAValidDirectoryName(&Test, &TmpDir);
00430         ERROR3_PF(("%s -> %s", (TCHAR *)Test, (TCHAR *)TmpDir));*/
00431 
00432         if(!GiveMeAValidDirectoryName(&FPath, &TmpDir))
00433             return FALSE;
00434     }
00435 
00436     // Well, we could do it, but it's a little nasty using temp\xarainfo aot temp\something\xarainfo
00437     if(TmpDir.Length() == 0)
00438         return FALSE;
00439 
00440     SGLibOil::AppendSlashIfNotPresent(RemoteDirectory);
00441     *RemoteDirectory += TmpDir;
00442 
00443     PathName RemLocPath(*RemoteDirectory);
00444     if(RemLocPath.IsValid() && SGLibOil::FileExists(&RemLocPath) && !IsDirectoryReadOnly(&RemLocPath))
00445         return TRUE;
00446     else
00447         return FALSE;
00448 }
00449 
00450 
00451 /***********************************************************************************************
00452 
00453 >   static BOOL GenerateIndexFile::GiveMeAValidDirectoryName(String_256 *Input, String_256 *Output)
00454 
00455     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00456     Created:    20/02/96
00457 
00458     Inputs:     Input   - String of random characters -> "\\deepthought\fishcake", "a:\", "hg23~';e#y", etc
00459     Outputs:    Output  - String which could be used as a directory name -> "deepthou", "a", "hg23ey"
00460     Returns:    TRUE if things went ok, FALSE if no valid chars were found...
00461 
00462     Purpose:    Given a random string, construct a valid directory name from the string. This is
00463                 smashing if we want a directory name from a root directory, etc...
00464 
00465 ***********************************************************************************************/
00466 
00467 BOOL GenerateIndexFile::GiveMeAValidDirectoryName(String_256 *Input, String_256 *Output)
00468 {
00469     ERROR3IF(Input == NULL || Output == NULL, "GenerateIndexFile::GiveMeAValidDirectoryName given NULL params");
00470 
00471     if(Input == NULL || Output == NULL)
00472         return FALSE;
00473 
00474     INT32 Length = Input->Length();
00475     Output->Empty();
00476     INT32 StartIndex = 0;
00477 
00478     if(Input->Sub(String_8("\\\\")) == 0 && Input->CountChar('\\') > 2)
00479     {
00480         String_256 Tmp;
00481         Input->Right(&Tmp, Length - 2);
00482 
00483         // Tmp now holds string minus the \\ at the start, so we can get an index to the third \ in the string
00484         StartIndex = Tmp.Sub(String_8("\\")) + 2;
00485 
00486         if((Length - StartIndex) < 2)
00487             StartIndex = 0;
00488     }
00489 
00490     for(INT32 i = StartIndex; i <= Length; i++)
00491     {
00492         if(Output->Length() < 8)
00493         {
00494             if(iswalnum((*Input)[i])) // != '\\' && (*Input)[i] != ':')
00495                 *Output += TEXT((*Input)[i]); 
00496         }
00497     }
00498 
00499     if(Output->Length() > 0)
00500         return TRUE;
00501 
00502     return FALSE;
00503 }
00504 
00505 /***********************************************************************************************
00506 
00507 >   BOOL GenerateIndexFile::RemoteIndexSetup(PathName *FilesPath);
00508 
00509     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00510     Created:    07/04/95
00511 
00512     Inputs:     
00513     Outputs:
00514     Returns:    TRUE if things went ok and we're using a remote index.
00515 
00516     Purpose:    Check with the user that it's ok to use a remote index, and find a sensible
00517                 location to put it.
00518     Notes:
00519 
00520 ***********************************************************************************************/
00521 
00522 BOOL GenerateIndexFile::RemoteIndexSetup(PathName *FilesPath)
00523 {
00524     ERROR3IF(FilesPath == NULL, "GenerateIndexFile::RemoteIndexSetup passed a null path");
00525 
00526     IndexIsRemote = FALSE;
00527     RemoteLocationOfIndex = "";
00528     RemoteLocationOfFiles = "";
00529 
00530     if(!Library::RemoteIndexes)
00531         return FALSE;
00532 
00533     BOOL Existing = CheckForRemote(FilesPath, &RemoteLocationOfIndex);
00534 
00535     if(RemoteLocationOfIndex.Length() == 0)
00536         return FALSE;
00537 
00538     // Only report this if the user hasn't already found the index for us...
00539     if(!SGLibOil::FileExists(&Index))
00540     {
00541         // "The chosen folder appears to be read only. Would you like to use '#1%s' for the index and thumbnail data? etc..."
00542         String_256 Msg;
00543         String_256 SmallLocation;
00544         RemoteLocationOfIndex.Left(&SmallLocation, 100);
00545         Msg.MakeMsg(_R(IDS_LIBRARY_CREATE_REMOTE), (TCHAR *)SmallLocation);
00546         Error::SetError(0, Msg, 0);
00547         INT32 ButtonPressed = InformWarning(0, _R(IDS_CREATE), _R(IDS_CANCEL));
00548         Error::ClearError();
00549 
00550         if(ButtonPressed != 1)
00551             return FALSE;
00552     }
00553 
00554     // Pathname for the index file -> c:\clipart\jobby\xarainfo
00555     PathName TmpPath(RemoteLocationOfIndex);
00556 
00557     if(!SGLibOil::FileExists(&TmpPath))
00558     {
00559         // Create the Xarainfo\.. directory
00560         if (!CreateDirectory((TCHAR *)RemoteLocationOfIndex, NULL))
00561         {
00562             DWORD err = GetLastError();     
00563             ERROR3("Can't create Tmp Index directory");
00564             return FALSE;
00565         }
00566     }
00567 
00568     IndexIsRemote = TRUE;
00569     SGLibOil::AppendSlashIfNotPresent(&RemoteLocationOfIndex);
00570     /*if(RemoteLocationOfIndex[RemoteLocationOfIndex.Length()-1] != '\\')
00571         RemoteLocationOfIndex += TEXT("\\");*/
00572     RemoteLocationOfIndex += String_16(_R(IDS_LIBRARIES_XARAINFO_DIRNAME));
00573     RemoteLocationOfFiles = FilesPath->GetPath(FALSE);
00574 
00575     return TRUE;
00576 }
00577 
00578 
00579 /***********************************************************************************************
00580 
00581 >   BOOL GenerateIndexFile::CreateIndexFile(void);
00582 
00583     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00584     Created:    09/04/95
00585 
00586     Inputs:     
00587     Outputs:
00588     Returns:    TRUE if things went ok.
00589 
00590     Purpose:    Create the index file and keywords file then add headers to them                                                       
00591     Notes:
00592 
00593 ***********************************************************************************************/
00594 
00595 BOOL GenerateIndexFile::CreateIndexFile(void)
00596 {
00597     if(!GenerateIndexFile::CreateFontIndexes && LibType == SGLib_Font)
00598         return FALSE;
00599 
00600     String_256 XIPathStr;
00601 
00602     // Check that we have write access to the directory in question...
00603     if(IsDirectoryReadOnly(&LibPath))
00604     {
00605         // The directory with the files in is READ ONLY...
00606         Error::ClearError();
00607 
00608         if(RemoteIndexSetup(&LibPath))
00609         {
00610             XIPathStr = RemoteLocationOfIndex;
00611             IndexIsRemote = TRUE;
00612 
00613             String_256 NewIndex(RemoteLocationOfIndex);
00614             SGLibOil::AppendSlashIfNotPresent(&NewIndex);
00615             /*if(NewIndex[NewIndex.Length()-1] != '\\')
00616                 NewIndex += TEXT("\\");*/
00617             NewIndex += Index.GetFileName(TRUE);
00618 
00619             Index = NewIndex;
00620         }
00621         else
00622         {
00623             // Can't find a sensible temp directory, or remote indexes aren't enabled...
00624             // Tell the user that their media is read only...
00625             InformWarning(_R(IDS_READONLY_MEDIA), _R(IDS_OK));
00626             XIPathStr = LibPath.GetPath(TRUE);
00627             XIPathStr += String_16(_R(IDS_LIBRARIES_XARAINFO_DIRNAME));
00628             IndexIsRemote = FALSE;
00629         }
00630     }
00631     else
00632     {
00633         XIPathStr = LibPath.GetPath(TRUE);
00634         XIPathStr += String_16(_R(IDS_LIBRARIES_XARAINFO_DIRNAME));
00635         IndexIsRemote = FALSE;
00636     }
00637 
00638     /***********************************************************************************/
00639 
00640     // Pathname for the index file -> c:\clipart\jobby\xarainfo
00641     PathName XIPath(XIPathStr);
00642 
00643     if(!SGLibOil::FileExists(&XIPath))
00644     {
00645         // Create the Xarainfo directory
00646         if (!CreateDirectory((TCHAR *)XIPathStr, NULL))
00647         {
00648             DWORD err = GetLastError();     
00649             ERROR3("Can't create XaraInfo directory");
00650             return FALSE;
00651         }
00652     }
00653 
00654     // This should only be true if we've succesfully found an old index, scanned its header
00655     // and copied it to and index.bak file
00656     OldIndexOK = FALSE;
00657 
00658     // If there's already an index file there, make a backup...
00659     if(SGLibOil::FileExists(&Index) && GenerateIndexFile::UseOldIndexes)
00660     {
00661         TmpIndexFile = new PathName(Index); /*(String_256)"C:\\Xaraclip.BAK");*/
00662         if(TmpIndexFile != NULL)
00663         {
00664             TmpIndexFile->SetType("BAK");
00665             SGLibOil::FileCopy(&Index, TmpIndexFile);
00666 
00667             OldIndexOK = PrePassIndex(TmpIndexFile, &OldIndexStart, &OldIndexDescriptionField,
00668                             &OldIndexKeywordField, &OldIndexTitleField, &OldIndexDescription);
00669         }
00670     }
00671 
00672     IndexFile = new CCDiskFile(1024, TRUE, FALSE);
00673     if(IndexFile == NULL)
00674     {
00675         ERROR3("Null index file allocated");
00676         return FALSE;
00677     }
00678 
00679     if(!IndexFile->open(Index, ios::out))
00680     {
00681         TRACEUSER( "Richard", _T("Can't open index file"));
00682         delete IndexFile;
00683         IndexFile = NULL;
00684         return FALSE;
00685     }
00686 
00687     return TRUE;
00688 }
00689 
00690 /***********************************************************************************************
00691 
00692 >   BOOL GenerateIndexFile::DoIndexHeader(void);
00693 
00694     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00695     Created:    09/04/95
00696 
00697     Inputs:     
00698     Outputs:
00699     Returns:    TRUE if things went ok.
00700 
00701     Purpose:    Add all the header data to an index file
00702     Notes:
00703 
00704 ***********************************************************************************************/
00705 
00706 BOOL GenerateIndexFile::DoIndexHeader(void)
00707 {
00708     String_256 Line(_R(IDS_LIBRARIES_INDEX_FILE_FOR));
00709     Line += LibPath.GetFileName();
00710     Line += TEXT("\r\n");
00711     AddLineToIndex(&Line);
00712 
00713 //  _stprintf(Line, "#\r\n# Entry count:\r\n");
00714 //  AddLineToIndex(&Line);
00715 
00716     IndexCountOff = IndexFile->tell();
00717 
00718     ID = 0;
00719     wsprintf(Line, "%05d", TotalFiles);
00720     Line += TEXT("\r\n");
00721     AddLineToIndex(&Line);
00722 
00723 //  _stprintf(Line, "# Synonym file:\r\nSynonyms.txt\r\n");
00724     Line = _R(IDS_LIBRARIES_SYNONYM_FILENAME);
00725     Line += TEXT("\r\n");
00726     AddLineToIndex(&Line);
00727 
00728 //  _stprintf(Line, "# Thumbnail sizes (Small, Medium, Large):\r\n");
00729 //  AddLineToIndex(&Line);
00730 
00731     // Fonts have weird thumbnail sizes
00732     if(LibType == SGLib_Font)
00733         Line = TEXT("28,16, 160,12, 180,26\r\n");
00734     else
00735         Line = TEXT("45,45, 130,64, 130,130\r\n");
00736 
00737 //      _stprintf(Line, "32,32, 64,64, 128,128\r\n");
00738 
00739     AddLineToIndex(&Line);
00740     
00741     // "Filename, Description, ID, Title, Key, Size\r\n"
00742     Line = String_16(_R(IDS_LIBRARIES_INDEX_ITEM_FILENAME));
00743     Line += TEXT(", ");
00744     Line += String_16(_R(IDS_LIBRARIES_INDEX_ITEM_DESC));
00745     Line += TEXT(", ");
00746     Line += String_16(_R(IDS_LIBRARIES_INDEX_ITEM_ID));
00747     Line += TEXT(", ");
00748     Line += String_16(_R(IDS_LIBRARIES_INDEX_ITEM_TITLE));
00749     Line += TEXT(", ");
00750     Line += String_16(_R(IDS_LIBRARIES_INDEX_ITEM_KEY));
00751     Line += TEXT(", ");
00752     Line += String_16(_R(IDS_LIBRARIES_INDEX_ITEM_SIZE));
00753     Line += TEXT("\r\n");
00754     AddLineToIndex(&Line);
00755 
00756     String_256 Description;
00757     if(OldIndexDescription.Length() == 0 || !GenerateIndexFile::UseOldIndexes)
00758     {
00759         String_256 TmpPath(LibPath.GetPath());
00760         LibraryFile::TidyUpSubPath(&TmpPath);
00761         TmpPath.Left(&Description, 60);
00762     }
00763     else
00764         Description = OldIndexDescription;  
00765 
00766     Line = TEXT("#");
00767     Line += String_16(_R(IDS_LIBRARIES_INDEX_DESCRITION)); // "#DESCRIPTION:"
00768     Line += TEXT(" ") + Description;
00769     Line += TEXT("\r\n");
00770     AddLineToIndex(&Line);
00771 
00772     if(IndexIsRemote)
00773     {
00774         Line = _R(IDS_LIBRARIES_INDEX_FILES);
00775         Line += TEXT(" ") + RemoteLocationOfFiles;
00776         Line += TEXT("\r\n");
00777         AddLineToIndex(&Line);
00778     }
00779 
00780     Line = _R(IDS_LIBRARIES_INDEX_START);
00781     Line += TEXT("\r\n");
00782     AddLineToIndex(&Line);
00783 
00784     return TRUE;
00785 }
00786 
00787 /***********************************************************************************************
00788 
00789 >   BOOL GenerateIndexFile::AddToSubLibrary(void);
00790 
00791     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00792     Created:    09/04/95
00793 
00794     Inputs:     
00795     Outputs:
00796     Returns:    TRUE if things went ok.
00797 
00798     Purpose:    This little baby scans a directory for all the files we're expecting and adds
00799                 sensible dummy entries into the Index file...
00800     Notes:
00801 
00802 ***********************************************************************************************/
00803 
00804 BOOL GenerateIndexFile::AddToSubLibrary(void)
00805 {
00806     BOOL Problems = FALSE;
00807     INT32 Count = FileNameBuffer.ItemCount();
00808     INT32 i = 0;
00809 
00810     while(i < Count)
00811     {
00812         TCHAR *Item = FileNameBuffer.GetItem(i);
00813         i++;
00814 
00815         if(Item != NULL)
00816         {
00817             PathName FileToAdd(Item);
00818 
00819             if(!AddFile(&FileToAdd))
00820             {
00821                 ERROR3("Problems adding file to index or keyword file - or ESC pressed");
00822                 Problems = TRUE;
00823                 i = Count;
00824             }
00825         }
00826     }
00827 
00828     return !Problems;
00829 }
00830 
00831 /***********************************************************************************************
00832 
00833 >   INT32 GenerateIndexFile::CountValidFiles(void);
00834 
00835     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00836     Created:    24/04/95
00837 
00838     Inputs:     
00839     Outputs:
00840     Returns:    Number of files that have 'add to index' potential for this type of library
00841 
00842     Purpose:    Counts what it returns
00843     Notes:
00844 
00845 ***********************************************************************************************/
00846 
00847 INT32 GenerateIndexFile::CountValidFiles(void)
00848 {
00849     // Progress bar for generation status
00850     String_64 Status(_R(IDS_LIBRARY_CREATION_SCANNING));
00851     BeginSlowJob(-1, FALSE, &Status);
00852 
00853     INT32 Count = 0;
00854     BOOL Counting = TRUE;
00855     BOOL Creating = FALSE;
00856     INT32 Pass = 0;
00857     BOOL ok = TRUE;
00858 
00859     String_256 FileSearch((const TCHAR *)LibPath.GetPath(TRUE));    
00860     FileSearch += TEXT("*.*");
00861 
00862     WIN32_FIND_DATA FileData;
00863     BOOL fFinished;
00864 
00865     // We go through the below code twice.
00866     // The first time we just count the number of files, so we know how big to make the
00867     // array for the second pass...
00868     do
00869     {
00870         Pass ++;
00871         Counting = (Pass == 1);
00872         Creating = (Pass == 2);
00873 
00874         fFinished = FALSE;
00875         hSearch = 0;
00876 
00877         // Start searching for files
00878         hSearch = FindFirstFile(FileSearch, &FileData);
00879         if (hSearch == INVALID_HANDLE_VALUE)
00880         {
00881             ERROR3("No valid files found in this directory");
00882             fFinished = TRUE;
00883         }
00884 
00885         while (!fFinished)
00886         {
00887             // Add full pathname to file
00888             String_256 FileToAddStr((const TCHAR *)LibPath.GetPath(TRUE));
00889             FileToAddStr += (TCHAR *)FileData.cFileName;
00890 
00891             // Only use normal files - not directories, hidden files, etc...
00892             DWORD FileAttributes = GetFileAttributes(FileToAddStr);
00893 
00894             if( ((FileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
00895                 (FileAttributes & FILE_ATTRIBUTE_HIDDEN) ||
00896                 (FileAttributes & FILE_ATTRIBUTE_SYSTEM)) == 0)
00897             {
00898                 PathName FileToAdd(FileToAddStr);
00899 
00900                 // Check if the file is addable to the index
00901                 if(IsFileType(&FileToAdd, LibType))
00902                 {
00903                     // First or second pass (first == counting files, second == adding files)
00904                     if(Counting)
00905                         Count ++;
00906 
00907                     // Second pass, allocate memory for string and add it into the buffer
00908                     if(Creating)
00909                         FileNameBuffer.AddItem((TCHAR *)FileToAddStr);
00910                 }
00911             }
00912         
00913             // Find the next file
00914             if (!FindNextFile(hSearch, &FileData))
00915                 fFinished = TRUE;
00916         }
00917 
00918         // Close the search handle
00919         if(!CloseSearchHandle())
00920             ERROR3("Couldn't close search handle.");
00921 
00922         if(Count != 0 && Counting)
00923         {
00924             ok = FileNameBuffer.Init(Count);
00925         }
00926 
00927         if(Count != 0 && Creating)
00928         {
00929             ok = FileNameBuffer.Sort();
00930         }
00931 
00932 
00933     } while(Count != 0 && Pass < 2 && ok);
00934 
00935     EndSlowJob();
00936     return Count;
00937 }
00938 
00939 #endif
00940 
00941 /***********************************************************************************************
00942 
00943 >   IndGenFileBuffer::IndGenFileBuffer()
00944 
00945     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00946     Created:    15/05/95
00947 
00948     Inputs:
00949     Outputs:
00950     Returns:
00951 
00952     Purpose:    Constructor
00953     Notes:      Since MSDOS seems happy returning filenames of files in a directory in a
00954                 completely random fashion, we need to have some way of storing all the ones
00955                 it returns us and sorting them alphabetically, so we can generate index files
00956                 in a nice alphabetical order.
00957 
00958                 The data structure used below is basically an array of TCHAR *'s pointed to
00959                 by Buffer. These TCHAR *'s are CCMalloced and given variable length C style
00960                 strings by AddItem. The destructor handles the memory tidying up.
00961 
00962 ***********************************************************************************************/
00963 
00964 IndGenFileBuffer::IndGenFileBuffer()
00965 {
00966     Buffer = NULL;
00967     Items = 0;
00968     Position = 0;
00969 }
00970 
00971 /***********************************************************************************************
00972 
00973 >   IndGenFileBuffer::~IndGenFileBuffer()
00974 
00975     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00976     Created:    15/05/95
00977 
00978     Inputs:
00979     Outputs:
00980     Returns:
00981 
00982     Purpose:    Destructor - frees all the memory
00983     Notes:
00984 
00985 ***********************************************************************************************/
00986 
00987 IndGenFileBuffer::~IndGenFileBuffer()
00988 {   
00989     if(Buffer != NULL)
00990     {
00991         for(INT32 i = 0; i<Items; i++)
00992         {
00993             if(Buffer[i] != NULL)
00994                 CCFree(Buffer[i]);
00995         }
00996 
00997         CCFree(Buffer);
00998         Buffer = NULL;
00999     }
01000 }
01001 
01002 #if 0
01003 
01004 /***********************************************************************************************
01005 
01006 >   BOOL IndGenFileBuffer::Init(INT32 Count)
01007 
01008     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
01009     Created:    15/05/95
01010 
01011     Inputs:     Count   - Number of files we're going to be adding
01012     Outputs:
01013     Returns:    TRUE if things went ok.
01014 
01015     Purpose:    Initialise the FileName Buffer system with a given number of entries
01016     Notes:
01017 
01018 ***********************************************************************************************/
01019 
01020 BOOL IndGenFileBuffer::Init(INT32 Count)
01021 {
01022     ERROR3IF(Buffer != NULL, "IndGenFileBuffer::Init called twice for same object");
01023 
01024     Items = Count;
01025     Buffer = (TCHAR **)CCMalloc(sizeof(TCHAR *) * Count);
01026 
01027     if(Buffer == NULL)
01028     {
01029         ERROR3("IndGenFileBuffer::Init failed to allocate buffer memory");
01030         Items = 0;
01031         return FALSE;
01032     }
01033 
01034     for(INT32 i = 0; i<Items; i++)
01035     {
01036         Buffer[i] = NULL;
01037     }   
01038 
01039     return TRUE;
01040 }
01041 
01042 /***********************************************************************************************
01043 
01044 >   BOOL IndGenFileBuffer::AddItem(INT32 Count)
01045 
01046     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
01047     Created:    15/05/95
01048 
01049     Inputs:     String  - pointer to null terminated string of TCHARS which we want to add
01050     Outputs:
01051     Returns:    TRUE if things went ok.
01052 
01053     Purpose:    Add a filename to the FileName buffer
01054     Notes:
01055 
01056 ***********************************************************************************************/
01057 
01058 BOOL IndGenFileBuffer::AddItem(TCHAR *String)
01059 {
01060     ERROR3IF(Items == 0, "IndGenFileBuffer::AddItem called without initialising first");
01061 
01062     if(Position >= Items)
01063     {
01064         ERROR3("IndGenFileBuffer::AddItem called too many times");
01065         return FALSE;
01066     }
01067 
01068     BOOL ok = FALSE;
01069 
01070     Buffer[Position] = (TCHAR *)CCMalloc((camStrlen(String) + 1) * sizeof(TCHAR));
01071     if(Buffer[Position] != NULL)
01072     {
01073         camStrcpy(Buffer[Position], String);
01074         ok = TRUE;
01075     }
01076 
01077     Position++;
01078 
01079     return ok;
01080 }
01081 
01082 /***********************************************************************************************
01083 
01084 >   BOOL IndGenFileBuffer::Sort(void)
01085 
01086     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
01087     Created:    15/05/95
01088 
01089     Inputs:
01090     Outputs:    
01091     Returns:    TRUE if the buffer was sorted ok
01092 
01093     Purpose:    Sort the strings pointed to by the buffer alphabetically
01094     Notes:
01095 
01096 ***********************************************************************************************/
01097 
01098 BOOL IndGenFileBuffer::Sort(void)
01099 {
01100     qsort(Buffer, Items, sizeof(TCHAR *), IndGenFileBuffer::SortComparator);
01101 
01102     return FALSE;
01103 }
01104 
01105 /********************************************************************************************
01106 
01107 >   static INT32 __cdecl IndGenFileBuffer::SortComparator(const void *Item1, const void *Item2)
01108 
01109     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
01110     Created:    15/5/95
01111 
01112     Inputs:     Item1, Item2 - the strings to be compared
01113 
01114     Returns:    a negative, zero, or positive result of comparing the strings
01115 
01116     Purpose:    'qsort' comparator function, used when sorting the file name buffer
01117 
01118     Notes:
01119 
01120 ********************************************************************************************/
01121 
01122 INT32 __cdecl IndGenFileBuffer::SortComparator(const void *Item1, const void *Item2)
01123 {
01124     if(Item1 == NULL || Item2 == NULL)
01125     {
01126         ERROR3("IndGenFileBuffer::SortComparator given null params");
01127         return 0;
01128     }
01129 
01130     TCHAR *String1 = *((TCHAR **)Item1);
01131     TCHAR *String2 = *((TCHAR **)Item2);
01132 
01133     // Sort by name - case insensitive - 'FRED' and 'fred' are equal...
01134     INT32 Value = CompareString(LOCALE_USER_DEFAULT,
01135         (NORM_IGNORECASE | NORM_IGNOREKANATYPE | NORM_IGNOREWIDTH),
01136         String1, -1, String2, -1);  // multi-locale supported compare routine
01137     Value -= 2;
01138 
01139     return(Value);
01140 }
01141 
01142 /***********************************************************************************************
01143 
01144 >   TCHAR *IndGenFileBuffer::GetItem(INT32 Count)
01145 
01146     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
01147     Created:    15/05/95
01148 
01149     Inputs:     Count   - position of item in buffer
01150     Outputs:    
01151     Returns:    Pointer to the string at offset 'Count'
01152 
01153     Purpose:    Return pointer to item at index 'Count'
01154     Notes:      This can return NULL, and will if the item hasn't been allocated properly...
01155 
01156 ***********************************************************************************************/
01157 
01158 TCHAR *IndGenFileBuffer::GetItem(INT32 Count)
01159 {
01160     ERROR3IF(Count > Position, "IndGenFileBuffer::GetItem given an index which hasn't been added yet");
01161 
01162     return Buffer[Count];
01163 }
01164 
01165 /***********************************************************************************************
01166 
01167 >   BOOL GenerateIndexFile::FixSubLibraryNumber(void);
01168 
01169     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
01170     Created:    09/04/95
01171 
01172     Inputs:
01173     Outputs:
01174     Returns:    TRUE if things went ok.
01175 
01176     Purpose:    Poke the count field with the correct value
01177     Notes:
01178 
01179 ***********************************************************************************************/
01180 
01181 BOOL GenerateIndexFile::FixSubLibraryNumber(void)
01182 {
01183     if(IndexFile && IndexCountOff)
01184     {
01185         IndexFile->seek(IndexCountOff);
01186         String_256 Line;
01187         wsprintf(Line, "%05d", ID);
01188         AddLineToIndex(&Line);
01189     }
01190     else
01191         return FALSE;
01192 
01193     return TRUE;
01194 }
01195 
01196 
01197 /***********************************************************************************************
01198 
01199 >   BOOL GenerateIndexFile::AddFile(PathName *FileName);
01200 
01201     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
01202     Created:    09/04/95
01203 
01204     Inputs:     FileName - name of file to add to index
01205     Outputs:
01206     Returns:    TRUE if things went ok.
01207 
01208     Purpose:    Add a file to the index
01209     Notes:
01210 
01211 ***********************************************************************************************/
01212 
01213 BOOL GenerateIndexFile::AddFile(PathName *FileName)
01214 {
01215     // Update progress bar & Line count
01216     if(!ContinueSlowJob(ID))
01217         return FALSE;
01218     ID++;
01219 
01220     TRACEUSER( "Richard", _T("Adding %s - ID %d to Index file\n"), (const TCHAR *)FileName->GetPath(), ID);
01221 
01222     // Get the file's size
01223     INT32 Size = (DWORD)SGLibOil::FileSize(FileName);
01224 
01225     // Default filename - force to lower case
01226     String_256 FName(FileName->GetFileName(TRUE));
01227     FName.toLower();
01228 
01229     // And capitalise the first character
01230     TCHAR First = camToupper(((TCHAR *)FName)[0]);
01231     ((TCHAR *)FName)[0] = First;
01232 
01233     // Default description - lowercase filename without file extension
01234     String_256 Description;
01235 
01236 #ifdef FILENAME_AS_DEFAULT_DESCRIPTION
01237     Description = FileName->GetFileName(FALSE);
01238     Description.toLower();
01239 
01240     // And capitalise the first character
01241     First = camToupper(((TCHAR *)Description)[0]);
01242     ((TCHAR *)Description)[0] = First;
01243 #endif
01244 
01245     // Default keywords - none
01246     String_256 Keywords("");
01247 
01248     // Default title - none
01249     String_256 Title("");
01250 
01251     BOOL FoundProperDescription = FALSE;
01252     
01253     // If it's a ttf font, rip out the name from the file
01254     if(LibType == SGLib_Font) {
01255 
01256         String_8 Ending(".");
01257         Ending += FileName->GetType();
01258         Ending.toLower();
01259         Ending += ";";
01260 
01261         if(Ending.Sub((String_8)".ttf;") != -1)
01262         {
01263             String_256 MenuName;
01264             if(RipTrueTypeNameFromFile(FileName, &MenuName))
01265             {
01266                 Description = MenuName;
01267                 FoundProperDescription = TRUE;
01268             }
01269         }
01270 
01271         if(Ending.Sub((String_8)".pfb;") != -1)
01272         {
01273             String_256 MenuName;
01274             BOOL Bold = FALSE;
01275             BOOL Italic = FALSE;
01276             if(RipATMNameFromFile(FileName, &MenuName, &Bold, &Italic))
01277             {
01278                 // Since this is going in the index, it would be silly to have a comma now wouldn't it ?
01279                 if(Bold || Italic) MenuName += ";";
01280                 if(Bold) MenuName += String_16(_R(IDS_FONTS_CAPITAL_BOLD));
01281                 if(Italic) MenuName += String_16(_R(IDS_FONTS_CAPITAL_ITALIC));
01282 
01283                 Description = MenuName;
01284                 FoundProperDescription = TRUE;
01285             }
01286         }
01287     }
01288 
01289     // If it's an art / eps file, rip out the comment block
01290     // NB: The function checks to see if it can handle the file type, no need to do it here...
01291     // We could also rip authors and keywords out possibly in the future...
01292     if((LibType == SGLib_ClipArt || LibType == SGLib_ClipArt_WebThemes) && !FoundProperDescription && GenerateIndexFile::UseDocComments)
01293     {
01294         String_256 OldDesc(Description);
01295         String_256 OldKeywords(Keywords);
01296         String_256 OldTitle(Title);
01297         if(RipDescriptionFromFile(FileName, &OldDesc, &OldKeywords, &OldTitle))
01298         {
01299             Description = OldDesc;
01300             Keywords = OldKeywords;
01301             Title = OldTitle;
01302             FoundProperDescription = TRUE;
01303         }
01304     }
01305 
01306     // If we haven't found a name yet, scan the tmp copy of the old index (if there was one)
01307     // Also get any old keywords found in the index for the item
01308     if(TmpIndexFile != NULL)
01309     {
01310 /*  if(!FoundProperDescription && TmpIndexFile != NULL && OldIndexOK && GenerateIndexFile::UseOldIndexes)
01311     { */ 
01312         String_256 OldDesc(Description);
01313         String_256 OldKeywords(Keywords);
01314         String_256 OldTitle(