From 25d2b971007fbe8892fca303da22c2bde92e3f41 Mon Sep 17 00:00:00 2001 From: Peter van der Weerd Date: Thu, 2 Feb 2023 12:55:17 +0100 Subject: [PATCH] Updated the way commandline params are passed (fixing a bug loading unquoted files from the shell ext) Fixed a NPE in OnLoadComplete() Updated dates --- Source/FormMain.cs | 43 ++++++++++++++----------------- Source/Program.cs | 7 +++-- Source/Properties/AssemblyInfo.cs | 6 ++--- help.html | 6 ++--- help.md | 4 +-- 5 files changed, 32 insertions(+), 34 deletions(-) diff --git a/Source/FormMain.cs b/Source/FormMain.cs index 591d275..3649730 100644 --- a/Source/FormMain.cs +++ b/Source/FormMain.cs @@ -266,20 +266,13 @@ private void FormMain_Load (object sender, EventArgs e) { if (width > 300) Width = width; if (height > 200) Height = height; - //In NetCore the cmdline contains the dll as the first param - var lexer = new Lexer (Environment.CommandLine); - int i = 1; - Lexer.Token t; - while (true) { - t = lexer.NextToken (); - if (t == null || t.Type == Lexer.TokenType.Eof) break; - if (t.Type != Lexer.TokenType.Value) continue; - if (--i < 0) { - String startFile = t.Text; - if (File.Exists (startFile)) LoadFile (startFile); - else if (Directory.Exists (startFile)) ShowOpenDialogAndLoad (startFile); - break; - }; + //Parse the arguments from our main entrypoint + var args = Program.Arguments; + if (args.Length>0) { + String startFile = args[0]; + if (File.Exists (startFile)) LoadFile (startFile); + else if (Directory.Exists (startFile)) ShowOpenDialogAndLoad (startFile); + else statusLabelMain.Text = Invariant.Format ("ERROR: {0} does not exist.", startFile); } } @@ -836,30 +829,32 @@ void ILogFileCallback.OnLoadComplete (Result result) { indicateFinished (); setSearchStatus (""); menuFileClose.Enabled = true; - logger.Log ("Detected2: {0}", result.LogFile.DetectedEncoding.Current.CodePage); - setEncodingComboFromEncoding (result.LogFile.DetectedEncoding.Current); + var sb = new StringBuilder (); + + if (result.Error != null) { + sb.Append (" [ERROR]"); + statusLabelMain.Text = sb.ToString(); + result.ThrowIfError (); + } var lf = result.LogFile; - var sb = new StringBuilder (); + logger.Log ("Detected2: {0}", lf.DetectedEncoding.Current.CodePage); + setEncodingComboFromEncoding (lf.DetectedEncoding.Current); + sb.AppendFormat (Invariant.Culture, "{0:n0} lines / {1}", lf.LineCount, Pretty.PrintSize (lf.Size)); if (lf.SkippedLines > 0) { sb.AppendFormat (Invariant.Culture, ", ({0:n0} skipped)", lf.SkippedLines); } - if (result.Error != null) { - sb.Append (" [ERROR]"); - statusLabelMain.Text = sb.ToString(); - result.ThrowIfError (); - } else if (result.Cancelled) { + if (result.Cancelled) { sb.Append (" [PARTIAL LOADED]"); } else { sb.Append (", # Duration: "); sb.Append (Pretty.PrintElapsedMs ((int)result.Duration.TotalMilliseconds)); } statusLabelMain.Text = sb.ToString (); + setLogFile (lf); - //The logfile will not be set if we had errors. The state of the logfile is unpredictable then... - if (result.Error == null) setLogFile (result.LogFile); }), null); } diff --git a/Source/Program.cs b/Source/Program.cs index 81876c1..d14af06 100644 --- a/Source/Program.cs +++ b/Source/Program.cs @@ -18,12 +18,15 @@ using System.Windows.Forms; namespace Bitmanager.BigFile { - static class Program { + public static class Program { + public static String[] Arguments; + /// /// The main entry point for the application. /// [STAThread] - static void Main () { + static void Main (String[] args) { + Arguments = args; Application.EnableVisualStyles (); Application.SetCompatibleTextRenderingDefault (false); Application.Run (new FormMain ()); diff --git a/Source/Properties/AssemblyInfo.cs b/Source/Properties/AssemblyInfo.cs index 6043d02..a9864d5 100644 --- a/Source/Properties/AssemblyInfo.cs +++ b/Source/Properties/AssemblyInfo.cs @@ -26,11 +26,11 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("De Bitmanager")] [assembly: AssemblyProduct("BigFile")] -[assembly: AssemblyCopyright("Copyright © 2022 De Bitmanager")] +[assembly: AssemblyCopyright("Copyright © 2023 De Bitmanager")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] -[assembly: AssemblyVersion("1.1.2022.1221")] -[assembly: AssemblyFileVersion("1.1.2022.1221")] +[assembly: AssemblyVersion("1.1.2023.0202")] +[assembly: AssemblyFileVersion("1.1.2023.0202")] diff --git a/help.html b/help.html index 16ff5f2..c9c8ca7 100644 --- a/help.html +++ b/help.html @@ -593,7 +593,7 @@ help
-

BigFile (V1.1.2022.1221)

BigFile is meant as a viewer for large files on Windows. Like 'less' on Unix systems. Typical used as a viewer for:

  • very large logfiles
  • very large json dumps
  • very large xml-dums
  • etc

NB: If the interface shows a big yellow exclamation mark, you probably miss the Bitmanager Core Components. Bigfile will work, but much slower. The core components can be downloaded from (https://bitmanager.nl/distrib).

The following provides a brief help guide for the core operations of BigFile.

 

History

BigFile is inspired by Mark Woan's LogViewer (https://github.com/woanware/LogViewer) +

BigFile (V1.1.2023.0202)

BigFile is meant as a viewer for large files on Windows. Like 'less' on Unix systems. Typical used as a viewer for:

  • very large logfiles
  • very large json dumps
  • very large xml-dums
  • etc

NB: If the interface shows a big yellow exclamation mark, you probably miss the Bitmanager Core Components. Bigfile will work, but much slower. The core components can be downloaded from (https://bitmanager.nl/distrib).

The following provides a brief help guide for the core operations of BigFile.

 

History

BigFile is inspired by Mark Woan's LogViewer (https://github.com/woanware/LogViewer) Unfortunately BigFile diverged way too far from the original logviewer, so I decided it deserves its own place.

 

Opening a file

Either use the File->Open menu item or drag and drop a file onto the list

BigFile can open .zip and .gz files directly. The content will be loaded into memory and served from there. gz-files will be loaded via an internal zlib implementation if found, or via SharpZLib (slower!) .zip files will be loaded via the internal .Net zip-classes.

In case of a zip archive, the largest sub-file will be loaded. Also, a dropdown box with all entries from the zip file is shown. Selecting a different entry from that dropdown will load the associated zip entry from the archive.

The load process is done in the background but regularly sends a partial loaded file to the user-interface, to make it possible to view the file before it is completely loaded.

All background processing can be cancelled by pressing the escape-key, or by clicking in the progress bar.

Limiting the load size

The header contains a box 'load limits'. You can specify how many lines (or bytes) to skip before start loading. Also you can specify how many bytes should be loaded as a maximum.

The format is <skip>/<max load size>

Examples 
10000Skips the first 10000 lines
10000/1gbSkips the first 10000 lines and then loads a maximum of 1 gigabyte
/1gbSkips nothing, but loads a maximum of 1 gigabyte
100kbSkips 100 kilobytes and then loads everything from there
1g/1gSkips 1 gigabyte and then loads a maximum of 1 gigabyte

 

If the searchbox contains any of AND, OR, NOT, the search is considered to be a boolean search. Otherwise it is a 1-term search. Also, search types can be specified via a ':'. Following types are supported:

  • no type: case insensitive search
  • cs: case sensitive search
  • regex or r: case insensitive search by a regex
  • rcs: case sensitive search by a regex

Example

  • (Paris AND r:on$) NOT cs:Amsterdam @@ -609,9 +609,9 @@ goto the next hit in the record
  • ? or CTRL-F3 goto the previous hit in the record
  • CTRL-up goto the previous line.
  • CTRL-down -goto the next line.

 

Memory

Non zip/gz files can be served from disk or from memory. Compressed files are always served from memory.

Because the content is splitted into lines, the content needs to be read completely for non compressed files as well. So using a memory buffer makes sense there as well.

For very large files it is difficult to keep them in memory. Bigfile uses LZW compression to compress large chunks of memory. Because LZW is extremely fast, this combination is typically faster when the system would need to swap memory.

On my laptop Bigfile loads a 2GB gz json file in 20 secongs into memory (raw: 15GB, LZW compressed ~3GB).

The exact behavior can be configured via tools->settings.

 

Copy Line(s)

The selected line's contents can be copied to the clipboard via the list context menu. There is a maximum limit of 10000 lines. Also, big lines (> 10MB) will be truncated to prevent an out-of-memory

 

Export

The export function can export

  • all lines
  • selected lines
  • matched lines

The export is always line based. Meaning that if splitting of large lines is active, and one selects only a part of the line, the complete line will be exported. +goto the next line.

 

Memory

Non zip/gz files can be served from disk or from memory. Compressed files are always served from memory.

Because the content is splitted into lines, the content needs to be read completely for non compressed files as well. So using a memory buffer makes sense there as well.

For very large files it is difficult to keep them in memory. Bigfile uses LZW compression to compress large chunks of memory. Because LZW is extremely fast, this combination is typically faster when the system would need to swap memory.

On my laptop Bigfile loads a 2GB gz json file in ~20 secongs into memory (raw: 15GB, LZW compressed ~3GB).

The exact behavior can be configured via tools->settings.

 

Copy Line(s)

The selected line's contents can be copied to the clipboard via the list context menu. There is a maximum limit of 10000 lines. Also, big lines (> 10MB) will be truncated to prevent an out-of-memory

 

Export

The export function can export

  • all lines
  • selected lines
  • matched lines

The export is always line based. Meaning that if splitting of large lines is active, and one selects only a part of the line, the complete line will be exported. GZip compression of the export file is possible by selecting a .gz extension.

Currently, exported lines are terminated by a windows crlf.

The export functionality is accessed via the 'tools' menu.

 

Command line

The 1st parameter is the file or directory to be opened. If the parameter indicates a directory, an open file dialog box is shown with the supplied directory as initial directory.

 

Credits

 

Changes

V1.1.2022.1221

 

Changes

V1.1.2023.0202

  • Replaced the grid completely, in order to support more than 100M lines (the limit of a ListView). Also, the grid is much faster.
  • Better line-width calculations.
  • Possibility to skip the first lines/bytes and to limit the #bytes to load.
  • Showing tooltips with row-properties.

V1.0.2022.0621 (June 2022)

  • Moved to NetCore
  • Fixed duplicate entries in file history.
  • Better UTF16 support, BOM detecting
  • Much faster line splitting

V0.94 (aug 2021)

  • Copy to clipboard wasn't always working
  • Lots of internal stuf. Some UI changes.
  • Bugfixes.

V0.93 (may 2020)

  • Gzip saving of export files is supported.
  • More (de-)selection possibilities. Selections are now handled by the logfile itself, since the ListView was way too slow.
  • Line view supports expansion of json, if the json contained strings with encoded json.
  • Bugfixes.

V0.92 (feb 2020)

  • Gzip loading is now done via an internal zlib implementation. This shaves off some 10-20% of load times for big .gz files, and there is no need for searching for an gzip.exe.
  • Extra view-as mode: auto. Content type of a line will be detected and the line will be formatted using this content type.
  • Searching of terms in the detail view
  • Revamp of the detail view UI
  • Bugfixes

V0.914 (jun 2019)

  • When loading files with big lines, the lines are splitted in smaller, partial lines. By default, the size of a partial line is 2048.
  • Very big lines (above currently 10MB) will be truncated in the detail view.
  • Detail view is more stable during loading of a file. Partial loads are propagated to the detail view and a view disconnects itself when the logfile is closed
  • Bugfixes

V0.913

  • Loading of zip entries is implemented
  • Export functionality implemented
  • Bugfixes

V0.912

  • Bugfixes
  • Limited support for loading zip files
  • The detail view for a line is reusing the window. Also csv-view.
  • Recent files/folders are administrated
  • Faster startup
  • Shell extensions
diff --git a/help.md b/help.md index 17d5a1b..0a957b0 100644 --- a/help.md +++ b/help.md @@ -1,4 +1,4 @@ -# BigFile (V1.1.2022.1221) +# BigFile (V1.1.2023.0202) BigFile is meant as a viewer for large files on Windows. Like 'less' on Unix systems. Typical used as a viewer for: @@ -193,7 +193,7 @@ I used his Grid as a starting point. ## Changes -#### V1.1.2022.1221 +#### V1.1.2023.0202 - Replaced the grid completely, in order to support more than 100M lines (the limit of a ListView). Also, the grid is *much* faster. - Better line-width calculations.