Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fixed issue #3 #4

Merged
merged 1 commit into from
Feb 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/hexdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ int main(int argc, char** argv) {
ParseResult result = initialize_options(argc, argv);
const string filename = result["file"].as<string>();

std::basic_ifstream<unsigned char> input_stream = std::basic_ifstream<unsigned char>();

input_stream.open(filename, std::ios::binary);
std::ifstream input_stream;
input_stream.open(filename, std::ios::binary | std::ios::in);

if (!input_stream.is_open()) {
cerr << ERROR_HEADER << "Could not open file '" << filename << "'" << endl;
input_stream.clear();
return EXIT_FAILURE;
}

Expand All @@ -43,10 +43,10 @@ int main(int argc, char** argv) {
exit(EXIT_FAILURE);
}

unsigned char *file_content = (unsigned char *)malloc(file_size);
input_stream.read(file_content, file_size);
char *buffer = (char *)malloc(file_size);
input_stream.read(buffer, file_size);
input_stream.close();

unsigned char *file_content = (unsigned char *)buffer;

bool output_color = true;
if (result.count("output") || result.count("no-color")) output_color = false;
Expand Down