Skip to content

Commit

Permalink
Add InputFile::open_in_memory
Browse files Browse the repository at this point in the history
  • Loading branch information
veer66 committed Oct 27, 2023
1 parent 3be1a44 commit 75a3c6e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
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 75a3c6e

Please sign in to comment.