|
@@ -8,6 +8,7 @@
|
8
|
8
|
#include "cmLinkedHeap.h"
|
9
|
9
|
#include "cmText.h"
|
10
|
10
|
#include "cmFile.h"
|
|
11
|
+#include "cmFileSys.h"
|
11
|
12
|
#include "cmJson.h"
|
12
|
13
|
#include "cmTextTemplate.h"
|
13
|
14
|
|
|
@@ -547,9 +548,9 @@ cmTtRC_t cmTextTemplateWrite( cmTtH_t h, const cmChar_t* fn )
|
547
|
548
|
{
|
548
|
549
|
cmTtRC_t rc = kOkTtRC;
|
549
|
550
|
cmTt_t* p = _cmTtHandleToPtr(h);
|
550
|
|
- cmFileH_t fh;
|
|
551
|
+ cmFileH_t fh = cmFileNullHandle;
|
551
|
552
|
|
552
|
|
- if( cmFileOpen(&fh,fn,kReadFileFl,p->err.rpt) != kOkFileRC )
|
|
553
|
+ if( cmFileOpen(&fh,fn,kWriteFileFl,p->err.rpt) != kOkFileRC )
|
553
|
554
|
return cmErrMsg(&p->err,kFileFailTtRC,"The file '%s' could not be opened.",cmStringNullGuard(fn));
|
554
|
555
|
|
555
|
556
|
rc = _cmTtWriteNode(p,p->tree,fh);
|
|
@@ -810,11 +811,17 @@ cmTtRC_t cmTextTemplateTest( cmCtx_t* ctx, const cmChar_t* fn )
|
810
|
811
|
}
|
811
|
812
|
else
|
812
|
813
|
{
|
813
|
|
- cmTextTemplateApply(h,"/home/kevin/src/cmtest/src/cmtest/data/tmpl_src.js");
|
|
814
|
+ const cmChar_t* fn = cmFsMakeUserDirFn("src/cmtest/src/cmtest/data/","tmpl_src.js");
|
|
815
|
+ cmTextTemplateApply(h,fn);
|
|
816
|
+ cmFsFreeFn(fn);
|
814
|
817
|
}
|
815
|
818
|
|
816
|
819
|
cmTtPrintTree(h,&ctx->rpt);
|
817
|
820
|
|
|
821
|
+ const cmChar_t* fn1 = cmFsMakeUserDirFn("temp","tmpl_out.txt");
|
|
822
|
+ cmTextTemplateWrite(h, fn1 );
|
|
823
|
+ cmFsFreeFn(fn1);
|
|
824
|
+
|
818
|
825
|
cmTextTemplateFinalize(&h);
|
819
|
826
|
|
820
|
827
|
return rc;
|