瀏覽代碼

Issue #254 Switches template reading to use jlib

Previously the template file reading used _open and read to read the
template files.  This changes switches over to using jlib, and sets
an attribute on all template files to ensure they only use ln.

Previously opening in text mode acheived the same.

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 14 年之前
父節點
當前提交
7f4953af04
共有 2 個文件被更改,包括 10 次插入7 次删除
  1. 1 0
      .gitattributes
  2. 9 7
      ecl/hqlcpp/hqlwcpp.cpp

+ 1 - 0
.gitattributes

@@ -9,3 +9,4 @@
 *.psd           -text
 *.doc           -text
 *.mk            -text
+rtl/ecltpl/*    eol=lf

+ 9 - 7
ecl/hqlcpp/hqlwcpp.cpp

@@ -149,14 +149,16 @@ bool CppWriterTemplate::loadTemplate(const char * filename, const char *dir)
     if(tpl.length())
         tpl.append(PATHSEPCHAR);
     tpl.append(filename);
-    int input_file = _open(tpl.toCharArray(), _O_TEXT | _O_RDONLY, _S_IREAD );
-    if (input_file == -1)
+
+    Owned<IFile> file = createIFile(tpl);
+    Owned<IFileIO> io = file->openShared(IFOread, IFSHread);
+    if (!io)
+        return false;
+    offset_t size = (size32_t)io->size();
+    if (size != (size32_t)size)
         return false;
-    len = (size32_t)_lseeki64(input_file,0,SEEK_END);
-    _lseeki64(input_file,0,SEEK_SET);
-    text = (char *)malloc(len);
-    len=read(input_file,text,len);              // may come in lower since text;
-    close(input_file);
+    text = (char *)malloc((size_t)size);
+    len=io->read(0, (size32_t)size, text);
     
     unsigned index=0;
     unsigned startLine = 0;