Skip to content

Commit

Permalink
Add InputFile::open_in_memory (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
veer66 authored Oct 27, 2023
1 parent 3be1a44 commit 6fd3325
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ AC_PREREQ(2.52)

m4_define([PKG_VERSION_MAJOR], [3])
m4_define([PKG_VERSION_MINOR], [7])
m4_define([PKG_VERSION_PATCH], [4])
m4_define([PKG_VERSION_PATCH], [5])

# Bump if the ABI (not API) changed in a backwards-incompatible manner
m4_define([PKG_VERSION_ABI], [3])
Expand Down
8 changes: 8 additions & 0 deletions lttoolbox/input_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ InputFile::open(const char* fname)
return (infile != nullptr);
}

bool
InputFile::open_in_memory(char *input_buffer)
{
close();
infile = fmemopen(input_buffer, strlen(input_buffer), "rb");
return (infile != nullptr);
}

void
InputFile::open_or_exit(const char* fname)
{
Expand Down
1 change: 1 addition & 0 deletions lttoolbox/input_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class InputFile
InputFile();
~InputFile();
bool open(const char* fname = nullptr);
bool open_in_memory(char* input_buffer);
void open_or_exit(const char* fname = nullptr);
void close();
void wrap(FILE* newinfile);
Expand Down

0 comments on commit 6fd3325

Please sign in to comment.