Skip to content

Commit

Permalink
Issue #254 Switches template reading to use jlib
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ghalliday committed Aug 23, 2011
1 parent cf2ced3 commit 7f4953a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
*.psd -text
*.doc -text
*.mk -text
rtl/ecltpl/* eol=lf
16 changes: 9 additions & 7 deletions ecl/hqlcpp/hqlwcpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7f4953a

Please sign in to comment.