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

Add ability to read GZip-Compressed log files #34

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jfontsaballs
Copy link

#33

@jfontsaballs
Copy link
Author

Magic number for recognizing a GZip file found in https://stackoverflow.com/questions/6059302/how-to-check-if-a-file-is-gzip-compressed

Copy link
Owner

@Scarfsail Scarfsail left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please look at my comment regardning .gz extension detections. Otherwise looks good, thanks for the contribution!

@@ -95,15 +96,28 @@ public void LoadLogEntries()
this.LogFileExists = true;
using (FileStream fs = File.Open(this.LogFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
using (TextReader sr = new StreamReader(fs, true))
var isGzip = false;
if (LogFileName.Contains(".gz"))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't be better to use EndsWith instead of Contains? I assume that we are interested only in files ending by .gz.
And I would also add StringComparer.OrdinalIgnoreCase option.

@@ -22,7 +23,20 @@ public void LoadFile(string fileName, int numberOfRowsToShow)
this.Text = fileName;
using (FileStream fs = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
using (TextReader sr = new StreamReader(fs))
var isGzip = false;
if (fileName.Contains(".gz"))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same comment as above. Otherwise no comments, thanks for the PR! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants