Bläddra i källkod

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 år sedan
förälder
incheckning
7f4953af04
2 ändrade filer med 10 tillägg och 7 borttagningar
  1. 1 0
      .gitattributes
  2. 9 7
      ecl/hqlcpp/hqlwcpp.cpp

+ 1 - 0
.gitattributes

@@ -9,3 +9,4 @@
 *.psd           -text
 *.psd           -text
 *.doc           -text
 *.doc           -text
 *.mk            -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())
     if(tpl.length())
         tpl.append(PATHSEPCHAR);
         tpl.append(PATHSEPCHAR);
     tpl.append(filename);
     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;
         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 index=0;
     unsigned startLine = 0;
     unsigned startLine = 0;