00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 #include "camtypes.h"
00104 #include "sgindgen.h"
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
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
00149
00150
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
00162 BOOL GenerateIndexFile::UseOldIndexes = TRUE;
00163 BOOL GenerateIndexFile::UseDocComments = TRUE;
00164
00165
00166 BOOL GenerateIndexFile::UseAutomaticUpdate = FALSE;
00167
00168
00169
00170
00171
00172 static BOOL QuietThumbnail = FALSE;
00173
00174
00175 static BOOL StopIndGen = FALSE;
00176
00177 static FilePos LastFoundItemInIndex = 0;
00178
00179
00180
00181
00182 #endif
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
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
00216 }
00217
00218 #if 0
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236 BOOL GenerateIndexFile::CloseSearchHandle(void)
00237 {
00238
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
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
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
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
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");
00302 PathName ROPath(ROPathStr);
00303 Error::ClearError();
00304
00305 CCDiskFile ROFile(1024, FALSE, TRUE);
00306 BOOL ReadOnly = TRUE;
00307 BOOL CreatedFile = FALSE;
00308
00309
00310 TRY
00311 {
00312 CreatedFile = ROFile.open(ROPath, ios::out);
00313 }
00314
00315 CATCH(CFileException, e)
00316 {
00317
00318 ReadOnly = TRUE;
00319 Error::ClearError();
00320 }
00321 END_CATCH
00322
00323
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
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
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
00375
00376
00377
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
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432 if(!GiveMeAValidDirectoryName(&FPath, &TmpDir))
00433 return FALSE;
00434 }
00435
00436
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
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
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
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]))
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
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
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
00539 if(!SGLibOil::FileExists(&Index))
00540 {
00541
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
00555 PathName TmpPath(RemoteLocationOfIndex);
00556
00557 if(!SGLibOil::FileExists(&TmpPath))
00558 {
00559
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
00571
00572 RemoteLocationOfIndex += String_16(_R(IDS_LIBRARIES_XARAINFO_DIRNAME));
00573 RemoteLocationOfFiles = FilesPath->GetPath(FALSE);
00574
00575 return TRUE;
00576 }
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
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
00603 if(IsDirectoryReadOnly(&LibPath))
00604 {
00605
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
00616
00617 NewIndex += Index.GetFileName(TRUE);
00618
00619 Index = NewIndex;
00620 }
00621 else
00622 {
00623
00624
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
00641 PathName XIPath(XIPathStr);
00642
00643 if(!SGLibOil::FileExists(&XIPath))
00644 {
00645
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
00655
00656 OldIndexOK = FALSE;
00657
00658
00659 if(SGLibOil::FileExists(&Index) && GenerateIndexFile::UseOldIndexes)
00660 {
00661 TmpIndexFile = new PathName(Index);
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
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
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
00714
00715
00716 IndexCountOff = IndexFile->tell();
00717
00718 ID = 0;
00719 wsprintf(Line, "%05d", TotalFiles);
00720 Line += TEXT("\r\n");
00721 AddLineToIndex(&Line);
00722
00723
00724 Line = _R(IDS_LIBRARIES_SYNONYM_FILENAME);
00725 Line += TEXT("\r\n");
00726 AddLineToIndex(&Line);
00727
00728
00729
00730
00731
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
00738
00739 AddLineToIndex(&Line);
00740
00741
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));
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
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
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
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847 INT32 GenerateIndexFile::CountValidFiles(void)
00848 {
00849
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
00866
00867
00868 do
00869 {
00870 Pass ++;
00871 Counting = (Pass == 1);
00872 Creating = (Pass == 2);
00873
00874 fFinished = FALSE;
00875 hSearch = 0;
00876
00877
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
00888 String_256 FileToAddStr((const TCHAR *)LibPath.GetPath(TRUE));
00889 FileToAddStr += (TCHAR *)FileData.cFileName;
00890
00891
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
00901 if(IsFileType(&FileToAdd, LibType))
00902 {
00903
00904 if(Counting)
00905 Count ++;
00906
00907
00908 if(Creating)
00909 FileNameBuffer.AddItem((TCHAR *)FileToAddStr);
00910 }
00911 }
00912
00913
00914 if (!FindNextFile(hSearch, &FileData))
00915 fFinished = TRUE;
00916 }
00917
00918
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
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964 IndGenFileBuffer::IndGenFileBuffer()
00965 {
00966 Buffer = NULL;
00967 Items = 0;
00968 Position = 0;
00969 }
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983
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
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
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
01045
01046
01047
01048
01049
01050
01051
01052
01053
01054
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
01085
01086
01087
01088
01089
01090
01091
01092
01093
01094
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
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118
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
01134 INT32 Value = CompareString(LOCALE_USER_DEFAULT,
01135 (NORM_IGNORECASE | NORM_IGNOREKANATYPE | NORM_IGNOREWIDTH),
01136 String1, -1, String2, -1);
01137 Value -= 2;
01138
01139 return(Value);
01140 }
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
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
01168
01169
01170
01171
01172
01173
01174
01175
01176
01177
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
01200
01201
01202
01203
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213 BOOL GenerateIndexFile::AddFile(PathName *FileName)
01214 {
01215
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
01223 INT32 Size = (DWORD)SGLibOil::FileSize(FileName);
01224
01225
01226 String_256 FName(FileName->GetFileName(TRUE));
01227 FName.toLower();
01228
01229
01230 TCHAR First = camToupper(((TCHAR *)FName)[0]);
01231 ((TCHAR *)FName)[0] = First;
01232
01233
01234 String_256 Description;
01235
01236 #ifdef FILENAME_AS_DEFAULT_DESCRIPTION
01237 Description = FileName->GetFileName(FALSE);
01238 Description.toLower();
01239
01240
01241 First = camToupper(((TCHAR *)Description)[0]);
01242 ((TCHAR *)Description)[0] = First;
01243 #endif
01244
01245
01246 String_256 Keywords("");
01247
01248
01249 String_256 Title("");
01250
01251 BOOL FoundProperDescription = FALSE;
01252
01253
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
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
01290
01291
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
01307
01308 if(TmpIndexFile != NULL)
01309 {
01310
01311
01312 String_256 OldDesc(Description);
01313 String_256 OldKeywords(Keywords);
01314 String_256 OldTitle(