Skip to content

Commit

Permalink
Updated the way commandline params are passed (fixing a bug loading u…
Browse files Browse the repository at this point in the history
…nquoted files from the shell ext)

Fixed a NPE in OnLoadComplete()
Updated dates
  • Loading branch information
pweerd committed Feb 2, 2023
1 parent 5d79df3 commit 25d2b97
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 34 deletions.
43 changes: 19 additions & 24 deletions Source/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
}

Expand Down
7 changes: 5 additions & 2 deletions Source/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@
using System.Windows.Forms;

namespace Bitmanager.BigFile {
static class Program {
public static class Program {
public static String[] Arguments;

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main () {
static void Main (String[] args) {
Arguments = args;
Application.EnableVisualStyles ();
Application.SetCompatibleTextRenderingDefault (false);
Application.Run (new FormMain ());
Expand Down
6 changes: 3 additions & 3 deletions Source/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
6 changes: 3 additions & 3 deletions help.html
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@
</style><title>help</title>
</head>
<body class='typora-export os-windows'><div class='typora-export-content'>
<div id='write' class=''><h1 id='bigfile-v1120221221'><span>BigFile (V1.1.2022.1221)</span></h1><p><span>BigFile is meant as a viewer for large files on Windows. Like &#39;less&#39; on Unix systems. Typical used as a viewer for:</span></p><ul><li><span>very large logfiles</span></li><li><span>very large json dumps</span></li><li><span>very large xml-dums</span></li><li><span>etc</span></li></ul><p><span>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 (</span><a href='https://bitmanager.nl/distrib' target='_blank' class='url'>https://bitmanager.nl/distrib</a><span>).</span></p><p><span>The following provides a brief help guide for the core operations of BigFile.</span></p><p>&nbsp;</p><h2 id='history'><span>History</span></h2><p><span>BigFile is inspired by Mark Woan&#39;s LogViewer (</span><a href='https://github.com/woanware/LogViewer' target='_blank' class='url'>https://github.com/woanware/LogViewer</a><span>)</span>
<div id='write' class=''><h1 id='bigfile-v1120230202'><span>BigFile (V1.1.2023.0202)</span></h1><p><span>BigFile is meant as a viewer for large files on Windows. Like &#39;less&#39; on Unix systems. Typical used as a viewer for:</span></p><ul><li><span>very large logfiles</span></li><li><span>very large json dumps</span></li><li><span>very large xml-dums</span></li><li><span>etc</span></li></ul><p><span>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 (</span><a href='https://bitmanager.nl/distrib' target='_blank' class='url'>https://bitmanager.nl/distrib</a><span>).</span></p><p><span>The following provides a brief help guide for the core operations of BigFile.</span></p><p>&nbsp;</p><h2 id='history'><span>History</span></h2><p><span>BigFile is inspired by Mark Woan&#39;s LogViewer (</span><a href='https://github.com/woanware/LogViewer' target='_blank' class='url'>https://github.com/woanware/LogViewer</a><span>)</span>
<span>Unfortunately BigFile diverged way too far from the original logviewer, so I decided it deserves its own place.</span></p><p>&nbsp;</p><h2 id='opening-a-file'><span>Opening a file</span></h2><p><span>Either use the File-&gt;Open menu item or drag and drop a file onto the list</span></p><p><span>BigFile can open </span><strong><span>.zip</span></strong><span> and </span><strong><span>.gz</span></strong><span> 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.</span></p><p><span>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.</span></p><p><span>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.</span></p><p><span>All background processing can be cancelled by pressing the escape-key, or by clicking in the progress bar.</span></p><h4 id='limiting-the-load-size'><span>Limiting the load size</span></h4><p><span>The header contains a box &#39;load limits&#39;. 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.</span></p><p><span>The format is </span><code>&lt;skip&gt;/&lt;max load size&gt;</code></p><figure><table><thead><tr><th><span>Examples</span></th><th>&nbsp;</th></tr></thead><tbody><tr><td><span>10000</span></td><td><span>Skips the first 10000 lines</span></td></tr><tr><td><span>10000/1gb</span></td><td><span>Skips the first 10000 lines and then loads a maximum of 1 gigabyte</span></td></tr><tr><td><span>/1gb</span></td><td><span>Skips nothing, but loads a maximum of 1 gigabyte</span></td></tr><tr><td><span>100kb</span></td><td><span>Skips 100 kilobytes and then loads everything from there</span></td></tr><tr><td><span>1g/1g</span></td><td><span>Skips 1 gigabyte and then loads a maximum of 1 gigabyte</span></td></tr></tbody></table></figure><p>&nbsp;</p><p><a name="search"></a></p><h2 id='search'><span>Search</span></h2><p><span>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.</span>
<span>Also, search types can be specified via a &#39;:&#39;.</span>
<span>Following types are supported:</span></p><ul><li><span>no type: case </span><em><strong><span>in</span></strong></em><span>sensitive search</span></li><li><span>cs: case sensitive search</span></li><li><span>regex or r: case </span><em><strong><span>in</span></strong></em><span>sensitive search by a regex</span></li><li><span>rcs: case sensitive search by a regex</span></li></ul><h4 id='example'><span>Example</span></h4><ul><li><span>(Paris AND r:on$) NOT cs:Amsterdam</span>
Expand All @@ -609,9 +609,9 @@
<span>goto the next hit in the record</span></li><li><span>? or CTRL-F3</span>
<span>goto the previous hit in the record</span></li><li><span>CTRL-up</span>
<span>goto the previous line.</span></li><li><span>CTRL-down</span>
<span>goto the next line.</span></li></ul><p>&nbsp;</p><h2 id='memory'><span>Memory</span></h2><p><span>Non zip/gz files can be served from disk or from memory. Compressed files are always served from memory.</span></p><p><span>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.</span></p><p><span>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.</span></p><p><span>On my laptop Bigfile loads a 2GB gz json file in 20 secongs into memory (raw: 15GB, LZW compressed ~3GB).</span></p><p><span>The exact behavior can be configured via tools-&gt;settings.</span></p><p>&nbsp;</p><h2 id='copy-lines'><span>Copy Line(s)</span></h2><p><span>The selected line&#39;s contents can be copied to the clipboard via the list context menu. There is a maximum limit of 10000 lines. Also, big lines (&gt; 10MB) will be truncated to prevent an out-of-memory</span></p><p>&nbsp;</p><h2 id='export'><span>Export</span></h2><p><span>The export function can export</span></p><ul><li><span>all lines</span></li><li><span>selected lines</span></li><li><span>matched lines</span></li></ul><p><span>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.</span>
<span>goto the next line.</span></li></ul><p>&nbsp;</p><h2 id='memory'><span>Memory</span></h2><p><span>Non zip/gz files can be served from disk or from memory. Compressed files are always served from memory.</span></p><p><span>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.</span></p><p><span>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.</span></p><p><span>On my laptop Bigfile loads a 2GB gz json file in ~20 secongs into memory (raw: 15GB, LZW compressed ~3GB).</span></p><p><span>The exact behavior can be configured via tools-&gt;settings.</span></p><p>&nbsp;</p><h2 id='copy-lines'><span>Copy Line(s)</span></h2><p><span>The selected line&#39;s contents can be copied to the clipboard via the list context menu. There is a maximum limit of 10000 lines. Also, big lines (&gt; 10MB) will be truncated to prevent an out-of-memory</span></p><p>&nbsp;</p><h2 id='export'><span>Export</span></h2><p><span>The export function can export</span></p><ul><li><span>all lines</span></li><li><span>selected lines</span></li><li><span>matched lines</span></li></ul><p><span>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.</span>
<span>GZip compression of the export file is possible by selecting a .gz extension.</span></p><p><span>Currently, exported lines are terminated by a windows crlf.</span></p><p><span>The export functionality is accessed via the &#39;tools&#39; menu.</span></p><p>&nbsp;</p><h2 id='command-line'><span>Command line</span></h2><p><span>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.</span></p><p>&nbsp;</p><h2 id='credits'><span>Credits</span></h2><ul><li><span>Mark Woan (</span><a href='https://www.woanware.co.uk' target='_blank' class='url'>https://www.woanware.co.uk</a><span>)</span></li><li><span>Tomasz Rewak ( </span><a href='https://github.com/TomaszRewak/DynamicGrid' target='_blank' class='url'>https://github.com/TomaszRewak/DynamicGrid</a><span>)</span>
<span>I used his Grid as a starting point.</span></li><li><span>SharpZipLib (</span><a href='https://github.com/icsharpcode/SharpZipLib' target='_blank' class='url'>https://github.com/icsharpcode/SharpZipLib</a><span>)</span></li><li><span>LZ4 - Fast LZ compression algorithm (</span><a href='http://fastcompression.blogspot.com/p/lz4.html' target='_blank' class='url'>http://fastcompression.blogspot.com/p/lz4.html</a><span>)</span></li><li><span>ZLib (</span><a href='https://github.com/madler/zlib' target='_blank' class='url'>https://github.com/madler/zlib</a><span>)</span></li><li><span>Icons8 (</span><a href='https://icons8.com' target='_blank' class='url'>https://icons8.com</a><span>)</span></li></ul><p>&nbsp;</p><h2 id='changes'><span>Changes</span></h2><h4 id='v1120221221'><span>V1.1.2022.1221</span></h4><ul><li><span>Replaced the grid completely, in order to support more than 100M lines (the limit of a ListView).</span>
<span>I used his Grid as a starting point.</span></li><li><span>SharpZipLib (</span><a href='https://github.com/icsharpcode/SharpZipLib' target='_blank' class='url'>https://github.com/icsharpcode/SharpZipLib</a><span>)</span></li><li><span>LZ4 - Fast LZ compression algorithm (</span><a href='http://fastcompression.blogspot.com/p/lz4.html' target='_blank' class='url'>http://fastcompression.blogspot.com/p/lz4.html</a><span>)</span></li><li><span>ZLib (</span><a href='https://github.com/madler/zlib' target='_blank' class='url'>https://github.com/madler/zlib</a><span>)</span></li><li><span>Icons8 (</span><a href='https://icons8.com' target='_blank' class='url'>https://icons8.com</a><span>)</span></li></ul><p>&nbsp;</p><h2 id='changes'><span>Changes</span></h2><h4 id='v1120230202'><span>V1.1.2023.0202</span></h4><ul><li><span>Replaced the grid completely, in order to support more than 100M lines (the limit of a ListView).</span>
<span>Also, the grid is </span><em><span>much</span></em><span> faster.</span></li><li><span>Better line-width calculations.</span></li><li><span>Possibility to skip the first lines/bytes and to limit the </span><span>#</span><span>bytes to load.</span></li><li><span>Showing tooltips with row-properties.</span></li></ul><h4 id='v1020220621-june-2022'><span>V1.0.2022.0621 (June 2022)</span></h4><ul><li><span>Moved to NetCore</span></li><li><span>Fixed duplicate entries in file history.</span></li><li><span>Better UTF16 support, BOM detecting</span></li><li><span>Much faster line splitting</span></li></ul><h4 id='v094-aug-2021'><span>V0.94 (aug 2021)</span></h4><ul><li><span>Copy to clipboard wasn&#39;t always working</span></li><li><span>Lots of internal stuf. Some UI changes.</span></li><li><span>Bugfixes.</span></li></ul><h4 id='v093-may-2020'><span>V0.93 (may 2020)</span></h4><ul><li><span>Gzip saving of export files is supported.</span></li><li><span>More (de-)selection possibilities. Selections are now handled by the logfile itself, since the ListView was way too slow.</span></li><li><span>Line view supports expansion of json, if the json contained strings with encoded json.</span></li><li><span>Bugfixes.</span></li></ul><h4 id='v092-feb-2020'><span>V0.92 (feb 2020)</span></h4><ul><li><span>Gzip loading is now done via an internal zlib implementation.</span>
<span>This shaves off some 10-20% of load times for big .gz files, and there is no need for searching for an gzip.exe.</span></li><li><span>Extra view-as mode: auto.</span>
<span>Content type of a line will be detected and the line will be formatted using this content type.</span></li><li><span>Searching of terms in the detail view</span></li><li><span>Revamp of the detail view UI</span></li><li><span>Bugfixes</span></li></ul><h4 id='v0914-jun-2019'><span>V0.914 (jun 2019)</span></h4><ul><li><span>When loading files with big lines, the lines are splitted in smaller, partial lines. By default, the size of a partial line is 2048.</span></li><li><span>Very big lines (above currently 10MB) will be truncated in the detail view.</span></li><li><span>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</span></li><li><span>Bugfixes</span></li></ul><h4 id='v0913'><span>V0.913</span></h4><ul><li><span>Loading of zip entries is implemented</span></li><li><span>Export functionality implemented</span></li><li><span>Bugfixes</span></li></ul><h4 id='v0912'><span>V0.912</span></h4><ul><li><span>Bugfixes</span></li><li><span>Limited support for loading zip files</span></li><li><span>The detail view for a line is reusing the window. Also csv-view.</span></li><li><span>Recent files/folders are administrated</span></li><li><span>Faster startup</span></li><li><span>Shell extensions</span></li></ul></div></div>
Expand Down
4 changes: 2 additions & 2 deletions help.md
Original file line number Diff line number Diff line change
@@ -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:

Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 25d2b97

Please sign in to comment.