Initial commit

parents
Showing with 4190 additions and 0 deletions

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
*.ncrunch*
.*crunch*.local.xml
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.Publish.xml
*.pubxml
# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/
# Windows Azure Build Output
csx
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
App_Data/*.mdf
App_Data/*.ldf
#LightSwitch generated files
GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml
# =========================
# Windows detritus
# =========================
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Mac desktop service store files
.DS_Store
language: c
install:
- sudo apt-get install cmake mono-devel mono-gmcs
script:
- xbuild HexDump.msbuild /t:Build
notifications:
recipients:
- ethomson@edwardthomson.com
email:
on_success: change
on_failure: always
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<PropertyGroup>
<Configuration Condition="'$(Configuration)' == ''">Release</Configuration>
</PropertyGroup>
<Target Name="Build">
<MSBuild Projects="HexDump.sln" Targets="Build" Properties="Configuration=$(Configuration);TrackFileAccess=false" />
</Target>
</Project>

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HexDump", "HexDump\HexDump.csproj", "{3B5141B5-28A3-4B8D-B7CE-65E519961398}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3B5141B5-28A3-4B8D-B7CE-65E519961398}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3B5141B5-28A3-4B8D-B7CE-65E519961398}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3B5141B5-28A3-4B8D-B7CE-65E519961398}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3B5141B5-28A3-4B8D-B7CE-65E519961398}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/></startup>
</configuration>
using System;
using System.Collections.Generic;
using System.IO;
namespace HexDump
{
public class ConcatenatedStream : Stream
{
private readonly Stream[] streams;
private int currentStream = 0;
private long totalLength = -1;
public ConcatenatedStream(string[] filenames, FileMode mode, FileAccess access, FileShare share)
{
streams = new Stream[filenames.Length];
for (int i = 0; i < filenames.Length; i++)
{
streams[i] = new FileStream(filenames[i], mode, access, share);
}
}
public ConcatenatedStream(Stream[] streams)
{
this.streams = streams;
}
public override bool CanSeek
{
get
{
return true;
}
}
public override bool CanRead
{
get
{
return true;
}
}
public override bool CanWrite
{
get
{
return false;
}
}
public override long Length
{
get
{
if (totalLength < 0)
{
long sum = 0;
foreach (Stream stream in streams)
{
sum += streams.Length;
}
totalLength = sum;
}
return totalLength;
}
}
public override long Position
{
get
{
long pos = 0;
for (int i = 0; i < currentStream; i++)
{
pos += streams[i].Length;
}
pos += streams[currentStream].Position;
return pos;
}
set
{
long pos = value;
for (int i = 0; i < streams.Length; i++)
{
if (pos <= streams[i].Length)
{
streams[i].Position = pos;
currentStream = i;
return;
}
pos -= streams[i].Length;
}
throw new IOException(String.Format("Position {0} is past the end of buffers", value));
}
}
public override long Seek(long offset, SeekOrigin origin)
{
if (origin == SeekOrigin.Begin)
{
Position += offset;
}
else if (origin == SeekOrigin.Current)
{
Position = offset;
}
else if (origin == SeekOrigin.End)
{
Position -= offset;
}
return Position;
}
public override int Read(byte[] buffer, int offset, int count)
{
int tot = 0;
int remain = count;
while (remain > 0)
{
if (streams[currentStream].Position == streams[currentStream].Length)
{
if (currentStream + 1 == streams.Length)
{
break;
}
currentStream++;
}
int len = streams[currentStream].Read(buffer, offset, remain);
if (len == 0)
{
throw new IOException("Couldn't read from stream {0}, but not at EOF?", currentStream);
}
tot += len;
offset += len;
remain -= len;
}
return tot;
}
public override void SetLength(long value)
{
throw new NotImplementedException();
}
public override void Write(byte[] buffer, int offset, int count)
{
throw new NotImplementedException();
}
public override void Flush()
{
throw new NotImplementedException();
}
public override void Close()
{
foreach (Stream stream in streams)
{
stream.Close();
}
}
protected override void Dispose(bool disposing)
{
foreach (Stream stream in streams)
{
stream.Dispose();
}
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
namespace HexDump
{
public class ForwardSeekingStream : Stream
{
private Stream stream;
private long position = 0;
public ForwardSeekingStream(Stream stream)
{
this.stream = stream;
}
public override bool CanSeek
{
get
{
return true;
}
}
public override bool CanRead
{
get
{
return true;
}
}
public override bool CanWrite
{
get
{
return false;
}
}
public override long Length
{
get
{
throw new NotSupportedException();
}
}
public override long Position
{
get
{
return position;
}
set
{
Seek(value, SeekOrigin.Begin);
}
}
public override long Seek(long offset, SeekOrigin origin)
{
if (origin == SeekOrigin.Begin)
{
if (offset < position)
{
throw new IOException("Cannot rewind stream");
}
FastForward(offset - position);
}
else if (origin == SeekOrigin.Current)
{
FastForward(offset);
}
else if (origin == SeekOrigin.End)
{
throw new IOException("Cannot rewind stream");
}
return position;
}
private bool FastForward(long count)
{
byte[] buf = new byte[1024];
while (count > 0)
{
int ret = stream.Read(buf, 0, Math.Min((int)count, 1024));
if (ret == 0)
{
return false;
}
count -= ret;
position += ret;
}
return true;
}
public override int Read(byte[] buffer, int offset, int count)
{
int ret = stream.Read(buffer, offset, count);
if (ret > 0)
{
position += ret;
}
return ret;
}
public override void SetLength(long value)
{
throw new NotImplementedException();
}
public override void Write(byte[] buffer, int offset, int count)
{
throw new NotImplementedException();
}
public override void Flush()
{
throw new NotImplementedException();
}
public override void Close()
{
stream.Close();
}
protected override void Dispose(bool disposing)
{
stream.Dispose();
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Reflection;
namespace HexDump
{
public class HexDump
{
private class Options