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 #include "camtypes.h"
00101 #include "sgliboil.h"
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 #include "ccdc.h"
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 #include "dlgmgr.h"
00128
00129 #include "oilbitmap.h"
00130
00131
00132 #include "progress.h"
00133 #include "helpuser.h"
00134
00135
00136
00137
00138
00139 #include "camelot.h"
00140 #include "camdoc.h"
00141 #include "unicdman.h"
00142
00143
00144 #include "cxftags.h"
00145 #include "cxfile.h"
00146
00147
00148
00149
00150 #include "pathnmex.h"
00151
00152
00153
00154
00155
00156 #include "nodebmp.h"
00157 #include "product.h"
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168 #if defined(__WXMSW__)
00169 #include <shfolder.h>
00170 #endif
00171
00172 extern void FixFPControlRegister(void);
00173
00174
00175 PORTNOTE("dialog","Removed OpClipartImport")
00176 #ifndef EXCLUDE_FROM_XARALX
00177 CC_IMPLEMENT_DYNCREATE(OpClipartImport, SelOperation)
00178 #endif
00179 PORTNOTE("dialog","Removed OpBitmapImport")
00180 #ifndef EXCLUDE_FROM_XARALX
00181 CC_IMPLEMENT_DYNCREATE(OpBitmapImport, Operation)
00182 #endif
00183 CC_IMPLEMENT_DYNCREATE(SGLibOil, CCObject)
00184
00185
00186
00187 #define new CAM_DEBUG_NEW
00188
00189 extern BOOL getDrive(const TCHAR**, TCHAR* drive);
00190 extern BOOL getNetDrive(const TCHAR**, TCHAR* drive, BOOL *BadCharacter);
00191
00192 TCHAR *SGLibOil::TmpSndName = NULL;
00193
00194
00195
00196
00197
00198 #define SCANFORXARAMOUNT
00199
00200 #if defined(__WXMSW__)
00201 const TCHAR chPathSep = _T('\\');
00202 #else
00203 const TCHAR chPathSep = _T('/');
00204 #endif
00205
00206 PORTNOTE("dialog","Removed OpClipartImport impl.")
00207 #ifndef EXCLUDE_FROM_XARALX
00208
00209
00210
00211 ClipartImportParam::ClipartImportParam()
00212 {
00213 File = NULL;
00214 Import = FALSE;
00215 Result = FALSE;
00216 DropInfo = NULL;
00217 }
00218
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235 OpClipartImport::OpClipartImport() : SelOperation()
00236 {
00237 OpFlags.HasOwnTimeIndicator = TRUE;
00238 }
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255 OpClipartImport::~OpClipartImport()
00256 {
00257 }
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271 BOOL OpClipartImport::Init()
00272 {
00273 OpBitmapImport::Init();
00274 OpAsynchBitmapImport::Init();
00275
00276 return RegisterOpDescriptor(
00277 0,
00278 _R(IDS_OPCLIPARTIMPORT),
00279 CC_RUNTIME_CLASS(OpClipartImport),
00280 OPTOKEN_OPCLIPARTIMPORT,
00281 OpClipartImport::GetState,
00282 0,
00283 0,
00284 0,
00285 0
00286
00287 );
00288 }
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301 OpState OpClipartImport::GetState(String_256* pString, OpDescriptor* pOpDesc)
00302 {
00303
00304 OpState OpSt;
00305
00306 return(OpSt);
00307 }
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324 void OpClipartImport::Do(OpDescriptor *NotUsed)
00325 {
00326 ERROR3("OpClipartImport does not provide a Do() function - Use DoWithParam");
00327 End();
00328 }
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347 void OpClipartImport::DoWithParam(OpDescriptor* pOp, OpParam* pClipartImportParam)
00348 {
00349 ClipartImportParam *pInfo = (ClipartImportParam *) pClipartImportParam;
00350
00351 if(pInfo == NULL)
00352 {
00353 ERROR3("OpClipartImport called with NULL info pointer");
00354 FailAndExecute();
00355 End();
00356 return;
00357 }
00358 else
00359 {
00360 if(pInfo->File == NULL)
00361 {
00362 ERROR3("OpClipartImport called with NULL file pointer");
00363 FailAndExecute();
00364 End();
00365 return;
00366 }
00367 }
00368
00369 PathName Path = *(pInfo->File);
00370
00371 if(!Path.IsValid())
00372 {
00373 ERROR3("Filename is invalid");
00374
00375 FailAndExecute();
00376 End();
00377 return;
00378 }
00379
00380 if(!pInfo->Import)
00381 {
00382
00383 CCamApp *pApp = AfxGetApp();
00384 BaseFileDialog::SelectedFilter = 0;
00385
00386 String_256 OpenPath((const TCHAR *)Path.GetPath());
00387
00388
00389
00390 CCamDoc* pDoc = (CCamDoc*) pApp->OpenDocumentFile((TCHAR *)OpenPath);
00391
00392
00393
00394 if(pDoc != NULL) pOurDoc = Document::GetSelected();
00395
00396 Document* pCurDoc = pDoc->GetKernelDoc();
00397
00398
00399
00400
00401 }
00402 else
00403 {
00404
00405 if(Document::GetSelected() == NULL)
00406 {
00407 ERROR3("No selected document");
00408
00409 FailAndExecute();
00410 End();
00411 return;
00412 }
00413
00414
00415 UINT32 SelFilter = FILTERID_GENERIC;
00416 BOOL LayersImport = FALSE;
00417
00418
00419 Filter *pFilter = Filter::GetFirst();
00420
00421 if(pFilter == NULL)
00422 return;
00423
00424 while (pFilter != NULL)
00425 {
00426 if ((pFilter->GetFlags().CanImport) && (pFilter->FilterID == SelFilter))
00427
00428 break;
00429
00430
00431 pFilter = Filter::GetNext(pFilter);
00432 }
00433
00434 if (pFilter == NULL)
00435 {
00436 InformError(_R(IDT_CANT_FIND_FILTER));
00437 FailAndExecute();
00438 End();
00439 return;
00440 }
00441 else
00442 {
00443
00444
00445
00446 if (!pFilter->IS_KIND_OF(FilterFamily))
00447 {
00448 UINT32 Size = 1024;
00449 INT32 FileSize;
00450 ADDR FilterBuf = pFilter->LoadInitialSegment(Path, &Size, &FileSize);
00451
00452
00453 if (FilterBuf == NULL)
00454 {
00455
00456 InformError();
00457 FailAndExecute();
00458 End();
00459 return;
00460 }
00461
00462
00463
00464
00465
00466
00467 pFilter->PreHowCompatible();
00468
00469
00470
00471
00472 if (pFilter->HowCompatible(Path, FilterBuf, Size, FileSize) < 9)
00473 {
00474
00475 ErrorInfo Question;
00476 Question.ErrorMsg = _R(IDT_IMPQUERY_NOTSURE);
00477 Question.Button[0] = _R(IDB_IMPQUERY_IMPORT);
00478 Question.Button[1] = _R(IDB_IMPQUERY_DONTIMPORT);
00479
00480 if (AskQuestion(&Question) != _R(IDB_IMPQUERY_IMPORT))
00481 {
00482
00483 TRACEUSER( "Richard", wxT("Filter compatibility was less than 10\n") );
00484
00485
00486 CCFree(FilterBuf);
00487 FailAndExecute();
00488 InformMessage(_R(IDT_IMP_USERABORT));
00489 End();
00490 return;
00491 }
00492 }
00493
00494
00495 CCFree(FilterBuf);
00496 }
00497
00498
00499 if (DoStartSelOp(FALSE))
00500
00501
00502 {
00503
00504 CCDiskFile DiskFile(1024, FALSE, TRUE);
00505
00506
00507
00508 Document* pCurDoc;
00509 ImportPosition Pos;
00510
00511 if (pInfo->DropInfo)
00512 {
00513
00514
00515 pCurDoc = pInfo->DropInfo->pDoc;
00516
00517 Pos.Position = pInfo->DropInfo->DropPos;
00518 Pos.pSpread = pInfo->DropInfo->pSpread;
00519 }
00520 else
00521 {
00522 pCurDoc = Document::GetSelected();
00523 }
00524
00525 if(pCurDoc == NULL)
00526 {
00527 ERROR3("OpClipartImport::DoWithParam retrieved NULL selected doc");
00528 return;
00529 }
00530
00531 TRY
00532 {
00533 if (!DiskFile.open(Path, ios::in | ios::binary))
00534 {
00535
00536 TRACEUSER( "Richard", wxT("Failed to open file in ClipartImport Do") );
00537 InformError(_R(IDT_IMPORT_NOTFOUND));
00538 FailAndExecute();
00539 End();
00540 return;
00541 }
00542
00543
00544 ImportPosition* ImportPos;
00545 if (pInfo->DropInfo)
00546 ImportPos = &Pos;
00547 else
00548 {
00549
00550
00551
00552 DocView* pDocView=DocView::GetCurrent();
00553
00554
00555 Pos=pDocView->GetCentreImportPosition();
00556
00557 ImportPos=&Pos;
00558 }
00559
00560
00561
00562 if (!pFilter->DoImport(this, &DiskFile, pCurDoc, FALSE, ImportPos))
00563 {
00564
00565 if (Error::GetErrorNumber() != _R(IDN_USER_CANCELLED))
00566 InformError();
00567 else
00568 Error::ClearError();
00569 FailAndExecute();
00570 End();
00571
00572
00573 if (DiskFile.isOpen())
00574 DiskFile.close();
00575
00576 return;
00577 }
00578
00579
00580 if (DiskFile.isOpen())
00581 DiskFile.close();
00582
00583 }
00584
00585
00586 CATCH(CFileException, e)
00587 {
00588
00589 if (Error::GetErrorNumber() != _R(IDN_USER_CANCELLED))
00590 InformError();
00591 else
00592 Error::ClearError();
00593
00594
00595 TRY
00596 {
00597 if (DiskFile.isOpen())
00598 DiskFile.close();
00599 }
00600 CATCH(CFileException, e)
00601 {
00602
00603 }
00604 END_CATCH
00605
00606
00607 FailAndExecute();
00608 End();
00609 return;
00610 }
00611 END_CATCH
00612 }
00613 }
00614 }
00615
00616
00617 GetMainFrame()->SetActiveWindow();
00618
00619 End();
00620 }
00621
00622
00623
00624
00625
00626
00627
00628
00629 BitmapImportParam::BitmapImportParam()
00630 {
00631 File = NULL;
00632 Result = FALSE;
00633
00634 pTargetDoc = 0;
00635 TagObjectToFill = 0;
00636 TagObjectValid = false;
00637 pObject = 0;
00638 pObjectValid = false;
00639 }
00640
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657 OpBitmapImport::OpBitmapImport() : Operation()
00658 {
00659 OpFlags.HasOwnTimeIndicator = TRUE;
00660 }
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677 OpBitmapImport::~OpBitmapImport()
00678 {
00679 }
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693 BOOL OpBitmapImport::Init()
00694 {
00695 return RegisterOpDescriptor(
00696 0,
00697 _R(IDS_OPCLIPARTIMPORT),
00698 CC_RUNTIME_CLASS(OpBitmapImport),
00699 OPTOKEN_OPBITMAPIMPORT,
00700 OpBitmapImport::GetState,
00701 0,
00702 0,
00703 0,
00704 0
00705
00706 );
00707 }
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720 OpState OpBitmapImport::GetState(String_256* pString, OpDescriptor* pOpDesc)
00721 {
00722
00723 OpState OpSt;
00724
00725 return(OpSt);
00726 }
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743 void OpBitmapImport::Do(OpDescriptor *NotUsed)
00744 {
00745 ERROR3("OpBitmapImport does not provide a Do() function - Use DoWithParam");
00746 End();
00747 }
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765 void OpBitmapImport::DoWithParam(OpDescriptor* pOp, OpParam* pBitmapImportParam)
00766 {
00767 BitmapImportParam *pInfo = (BitmapImportParam *) pBitmapImportParam;
00768 KernelBitmap* pBitmap = 0;
00769
00770 if(pInfo == NULL)
00771 {
00772 ERROR3("OpBitmapImport called with NULL info pointer");
00773 FailAndExecute();
00774 End();
00775 return;
00776 }
00777 else
00778 {
00779 if(pInfo->File == NULL)
00780 {
00781 ERROR3("OpBitmapImport called with NULL file pointer");
00782 FailAndExecute();
00783 End();
00784 return;
00785 }
00786 }
00787
00788 PathName Path = *(pInfo->File);
00789
00790 if(!Path.IsValid())
00791 {
00792 ERROR3("Filename is invalid");
00793
00794 FailAndExecute();
00795 End();
00796 return;
00797 }
00798
00799
00800 UINT32 SelFilter = FILTERID_GENERIC;
00801 BOOL LayersImport = FALSE;
00802
00803
00804 Filter *pFilter = Filter::GetFirst();
00805
00806 if(pFilter == NULL)
00807 return;
00808
00809 while (pFilter != NULL)
00810 {
00811 if ((pFilter->GetFlags().CanImport) && (pFilter->FilterID == SelFilter))
00812
00813 break;
00814
00815
00816 pFilter = Filter::GetNext(pFilter);
00817 }
00818
00819 if (pFilter == NULL)
00820 {
00821 InformError(_R(IDT_CANT_FIND_FILTER));
00822 FailAndExecute();
00823 End();
00824 return;
00825 }
00826 else
00827 {
00828
00829
00830
00831 if (!pFilter->IS_KIND_OF(FilterFamily))
00832 {
00833 UINT32 Size = 1024;
00834 INT32 FileSize;
00835 ADDR FilterBuf = pFilter->LoadInitialSegment(Path, &Size, &FileSize);
00836
00837
00838 if (FilterBuf == NULL)
00839 {
00840
00841 InformError();
00842 FailAndExecute();
00843 End();
00844 return;
00845 }
00846
00847
00848
00849
00850
00851
00852 pFilter->PreHowCompatible();
00853
00854
00855
00856
00857 if (pFilter->HowCompatible(Path, FilterBuf, Size, FileSize) < 9)
00858 {
00859
00860 ErrorInfo Question;
00861 Question.ErrorMsg = _R(IDT_IMPQUERY_NOTSURE);
00862 Question.Button[0] = _R(IDB_IMPQUERY_IMPORT);
00863 Question.Button[1] = _R(IDB_IMPQUERY_DONTIMPORT);
00864
00865 if (AskQuestion(&Question) != _R(IDB_IMPQUERY_IMPORT))
00866 {
00867
00868 TRACEUSER( "Richard", wxT("Filter compatibility was less than 10\n") );
00869
00870
00871 CCFree(FilterBuf);
00872 FailAndExecute();
00873 InformMessage(_R(IDT_IMP_USERABORT));
00874 End();
00875 return;
00876 }
00877 }
00878
00879
00880 CCFree(FilterBuf);
00881 }
00882
00883
00884 CCDiskFile DiskFile(1024, FALSE, TRUE);
00885
00886 TRY
00887 {
00888 if (!DiskFile.open(Path, ios::in | ios::binary))
00889 {
00890
00891 TRACEUSER( "Richard", wxT("Failed to open file in BitmapImport Do") );
00892 InformError(_R(IDT_IMPORT_NOTFOUND));
00893 FailAndExecute();
00894 End();
00895 return;
00896 }
00897
00898
00899 if (!pFilter->ImportBitmap(&DiskFile, &pBitmap))
00900 {
00901
00902 if (Error::GetErrorNumber() != _R(IDN_USER_CANCELLED))
00903 InformError();
00904 else
00905 Error::ClearError();
00906 FailAndExecute();
00907 End();
00908
00909 return;
00910 }
00911
00912
00913 if (DiskFile.isOpen())
00914 DiskFile.close();
00915 }
00916
00917
00918 CATCH(CFileException, e)
00919 {
00920
00921 if (Error::GetErrorNumber() != _R(IDN_USER_CANCELLED))
00922 InformError();
00923 else
00924 Error::ClearError();
00925
00926
00927 TRY
00928 {
00929 if (DiskFile.isOpen())
00930 DiskFile.close();
00931 }
00932 CATCH(CFileException, e)
00933 {
00934
00935 }
00936 END_CATCH
00937
00938
00939 FailAndExecute();
00940 End();
00941 return;
00942 }
00943 END_CATCH
00944 }
00945
00946
00947 ApplyFill(pInfo, pBitmap);
00948
00949
00950 if (pBitmap && pBitmap->GetParentBitmapList() == NULL)
00951 {
00952
00953 delete pBitmap;
00954 }
00955
00956
00957 GetMainFrame()->SetActiveWindow();
00958
00959
00960 End();
00961 }
00962
00963 bool OpBitmapImport::ApplyFill(BitmapImportParam *pInfo, KernelBitmap* pBitmap)
00964 {
00965
00966 if (Document::GetCurrent() != pInfo->pTargetDoc || pInfo->pTargetDoc == 0)
00967 {
00968
00969
00970
00971
00972 ERROR3("Cannot apply fill when active document has changed");
00973 return false;
00974 }
00975
00976
00977 if (!Document::SpreadBelongsToDoc(pInfo->pTargetDoc, pInfo->pSpread))
00978 {
00979 ERROR3("Trying to import a bitmap fill into a non-existent spread");
00980 return false;
00981 }
00982
00983
00984 switch(pInfo->FillType)
00985 {
00986
00987 case ApplyToObject:
00988 {
00989 NodeRenderableInk* pObjectToUse;
00990 if (pInfo->TagObjectValid)
00991 {
00992 Node *pTreeRoot = pInfo->pTargetDoc->GetFirstNode()->FindFirstDepthFirst();
00993 if (pTreeRoot) pTreeRoot = pTreeRoot->FindNext();
00994 Node *pNode = pTreeRoot->FindFirstDepthFirst();
00995 while ((pNode != NULL) && (pNode->GetTag() != pInfo->TagObjectToFill))
00996 pNode = pNode->FindNextDepthFirst(pTreeRoot);
00997
00998 if (pNode == 0)
00999 return false;
01000
01001 if (pNode->IsAnObject())
01002 pObjectToUse = static_cast<NodeRenderableInk *>(pNode);
01003 else
01004 {
01005 ERROR3("It has the tag we saved but its type has changed. This is odd");
01006 return false;
01007 }
01008 }
01009
01010 AttrBitmapColourFill* Attrib = new AttrBitmapColourFill;
01011 if (Attrib == 0)
01012 return false;
01013
01014 Attrib->AttachBitmap(pBitmap);
01015
01016 if (pInfo->TagObjectValid)
01017 AttributeManager::ApplyAttribToNode(pObjectToUse, Attrib);
01018 else if (pInfo->pObjectValid)
01019 AttributeManager::ApplyAttribToNode(pInfo->pObject, Attrib);
01020 else
01021 AttributeManager::AttributeSelected(0, Attrib);
01022
01023 return true;
01024 }
01025
01026 case ApplyToObjectAsTransp:
01027 {
01028 NodeRenderableInk* pObjectToUse;
01029
01030 if (pInfo->TagObjectValid)
01031 {
01032 Node *pTreeRoot = pInfo->pTargetDoc->GetFirstNode()->FindFirstDepthFirst();
01033 if (pTreeRoot) pTreeRoot = pTreeRoot->FindNext();
01034 Node *pNode = pTreeRoot->FindFirstDepthFirst();
01035 while ((pNode != NULL) && (pNode->GetTag() != pInfo->TagObjectToFill))
01036 pNode = pNode->FindNextDepthFirst(pTreeRoot);
01037
01038 if (pNode == 0)
01039 return false;
01040
01041 if (pNode->IsAnObject())
01042 pObjectToUse = static_cast<NodeRenderableInk *>(pNode);
01043 else
01044 {
01045 ERROR3("It has the tag we saved but its type has changed. This is odd");
01046 return false;
01047 }
01048 }
01049
01050 pBitmap = NodeBitmap::CheckGreyscaleBitmap(pBitmap, _R(IDS_BMPGAL_MAKEGREY), _R(IDS_BMPGAL_DOGREY));
01051
01052 AttributeManager::HaveAskedAboutContoneColours = FALSE;
01053 AttributeManager::UserCancelledContoneColours = FALSE;
01054
01055 if (pBitmap == 0)
01056 return false;
01057
01058
01059 NodeAttribute *Attrib = new AttrBitmapTranspFill;
01060 if (Attrib == 0)
01061 return false;
01062
01063 (static_cast<AttrBitmapTranspFill *>(Attrib))->AttachBitmap(pBitmap);
01064
01065 if (pInfo->TagObjectValid)
01066 AttributeManager::ApplyAttribToNode(pObjectToUse, Attrib);
01067 else if (pInfo->pObjectValid)
01068 AttributeManager::ApplyAttribToNode(pInfo->pObject, Attrib);
01069 else
01070 AttributeManager::AttributeSelected(0, Attrib);
01071
01072 return true;
01073 }
01074 case SetBackground:
01075 {
01076 OpBackgroundParam Param;
01077 Param.pBitmap = pBitmap;
01078 Param.pDoc = pInfo->pTargetDoc;
01079 Param.pSpread = pInfo->pSpread;
01080
01081
01082 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_BACKGROUND);
01083
01084
01085 pOpDesc->Invoke(&Param);
01086 return true;
01087 }
01088 case AddToPage:
01089 {
01090 PageDropInfo DropInfo;
01091
01092 DropInfo.pDoc = pInfo->pTargetDoc;
01093 DropInfo.pSpread = pInfo->pSpread;
01094 DropInfo.DropPos = pInfo->DropPos;
01095
01096
01097 OpDescriptor* OpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpCreateNodeBitmap));
01098
01099
01100 OpDesc->Invoke(&OpParam((INT32)pBitmap,(INT32)&DropInfo));
01101 return true;
01102 }
01103 default:
01104 {
01105 ERROR3("Unknown fill type");
01106 return false;
01107 }
01108 }
01109 }
01110
01111 #endif // wxCamelot port
01112
01113
01114
01115
01116
01117
01118
01119 BOOL SGLibOil::TidyUp(void)
01120 {
01121 if(TmpSndName != NULL)
01122 {
01123 PathName TheFile(TmpSndName);
01124 FileDelete(&TheFile);
01125 TmpSndName = NULL;
01126 }
01127 return TRUE;
01128 }
01129
01130
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146 BOOL SGLibOil::FileCopy(PathName *Source, PathName *Destination)
01147 {
01148 PORTNOTETRACE("dialog","SGLibOil::FileCopy - do nothing");
01149 #ifndef EXCLUDE_FROM_XARALX
01150 if(Source == NULL || Destination == NULL)
01151 {
01152 ERROR3("SGLibOil::FileCopy Source or Destination files should not be null");
01153 return FALSE;
01154 }
01155
01156 if(!Destination->IsValid() || !Source->IsValid())
01157 {
01158 ERROR3("SGLibOil::FileCopy given invalid path");
01159 return FALSE;
01160 }
01161
01162 if(FileExists(Destination))
01163 {
01164 ERROR3("SGLibOil::FileCopy destination file already exists");
01165 return FALSE;
01166 }
01167
01168 if(!FileExists(Source))
01169 {
01170 ERROR3("SGLibOil::FileCopy source file doesn't exist");
01171 return FALSE;
01172 }
01173
01174
01175
01176
01177
01178
01179
01180 INT32 Size = SGLibOil::FileSize(Source);
01181 void *Buffer = CCMalloc(Size + 4);
01182
01183 if(Buffer != NULL)
01184 {
01185 CCDiskFile File(1024, FALSE, TRUE);
01186
01187
01188 try
01189 {
01190
01191 File.open( Source->GetPath(), ios::in | ios::binary );
01192 File.read( Buffer, Size );
01193 if(File.isOpen())
01194 File.close();
01195
01196
01197 File.open(Destination->GetPath(), ios::out | ios::binary);
01198 File.write(Buffer, Size);
01199 if(File.isOpen())
01200 File.close();
01201
01202 CCFree(Buffer);
01203
01204
01205 return TRUE;
01206 }
01207 catch( CFileException )
01208 {
01209
01210
01211 Error::ClearError();
01212 }
01213
01214 CCFree(Buffer);
01215 }
01216
01217
01218
01219
01220
01221 FILE *FPin = NULL;
01222 FILE *FPout = NULL;
01223
01224 #if defined(__WXMSW__)
01225 FPin = _tfopen((const TCHAR *)Source->GetPath(), "rb");
01226 FPout = _tfopen((const TCHAR *)Destination->GetPath(), "wb");
01227 #else
01228 PSTR pszSrc, pszDst;
01229 {
01230 size_t cchTmp = camWcstombs( NULL, Source->GetPath(), 0 ) + 1;
01231 pszSrc = PSTR( alloca( cchTmp ) );
01232 camWcstombs( pszSrc, Source->GetPath(), cchTmp );
01233 }
01234 {
01235 size_t cchTmp = camWcstombs( NULL, Destination->GetPath(), 0 ) + 1;
01236 pszDst = PSTR( alloca( cchTmp ) );
01237 camWcstombs( pszDst, Destination->GetPath(), cchTmp );
01238 }
01239
01240 FPin = fopen( pszSrc, "rb" );
01241 FPout = fopen( pszDst, "wb" );
01242 #endif
01243
01244 if(FPin != NULL || FPout != NULL)
01245 {
01246 TCHAR C;
01247 while(!feof(FPin))
01248 {
01249 C = _fgettc(FPin);
01250 if(!feof(FPin)) _fputtc(C, FPout);
01251 }
01252 fclose(FPin);
01253 fclose(FPout);
01254 return TRUE;
01255 }
01256
01257 if(FPin != NULL) fclose(FPin);
01258 if(FPout != NULL) fclose(FPout);
01259 #endif
01260 return FALSE;
01261 }
01262
01263
01264
01265
01266
01267
01268
01269
01270
01271
01272
01273
01274