Browse Source

cmTextTemplate.c : Changed cmTextTemplateTest() to use cmFsMakeUserDirFn() to make platform independent.

master
kevin 8 years ago
parent
commit
c69942fb96
1 changed files with 10 additions and 3 deletions
  1. 10
    3
      cmTextTemplate.c

+ 10
- 3
cmTextTemplate.c View File

8
 #include "cmLinkedHeap.h"
8
 #include "cmLinkedHeap.h"
9
 #include "cmText.h"
9
 #include "cmText.h"
10
 #include "cmFile.h"
10
 #include "cmFile.h"
11
+#include "cmFileSys.h"
11
 #include "cmJson.h"
12
 #include "cmJson.h"
12
 #include "cmTextTemplate.h"
13
 #include "cmTextTemplate.h"
13
 
14
 
547
 {
548
 {
548
   cmTtRC_t rc = kOkTtRC;
549
   cmTtRC_t rc = kOkTtRC;
549
   cmTt_t* p = _cmTtHandleToPtr(h);
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
     return cmErrMsg(&p->err,kFileFailTtRC,"The file '%s' could not be opened.",cmStringNullGuard(fn));
554
     return cmErrMsg(&p->err,kFileFailTtRC,"The file '%s' could not be opened.",cmStringNullGuard(fn));
554
 
555
 
555
   rc = _cmTtWriteNode(p,p->tree,fh);
556
   rc = _cmTtWriteNode(p,p->tree,fh);
810
   }
811
   }
811
   else
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
   cmTtPrintTree(h,&ctx->rpt);
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
   cmTextTemplateFinalize(&h);
825
   cmTextTemplateFinalize(&h);
819
 
826
 
820
   return rc;
827
   return rc;

Loading…
Cancel
Save