mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-10-15 19:54:52 +08:00
remove more unused code
This commit is contained in:
@@ -1,126 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace UglyToad.Pdf.IO
|
||||
{
|
||||
using System.IO;
|
||||
|
||||
public interface IInputStream : IDisposable
|
||||
{
|
||||
int read();
|
||||
|
||||
int read(byte[] b);
|
||||
|
||||
int read(byte[] b, int off, int len);
|
||||
|
||||
long available();
|
||||
}
|
||||
|
||||
public interface IOutputStream : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Flushes this output stream and forces any buffered output bytes to be written out.
|
||||
/// </summary>
|
||||
void flush();
|
||||
|
||||
/// <summary>
|
||||
/// Writes b.length bytes from the specified byte array to this output stream.
|
||||
/// </summary>
|
||||
void write(byte[] b);
|
||||
|
||||
/// <summary>
|
||||
/// Writes len bytes from the specified byte array starting at offset off to this output stream.
|
||||
/// </summary>
|
||||
void write(byte[] b, int off, int len);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the specified byte to this output stream.
|
||||
/// </summary>
|
||||
void write(int b);
|
||||
}
|
||||
|
||||
public class BinaryInputStream : IInputStream
|
||||
{
|
||||
private readonly MemoryStream memoryStream;
|
||||
private readonly BinaryReader reader;
|
||||
|
||||
public BinaryInputStream(byte[] bytes)
|
||||
{
|
||||
memoryStream = new MemoryStream(bytes);
|
||||
reader = new BinaryReader(memoryStream);
|
||||
}
|
||||
|
||||
public BinaryInputStream()
|
||||
{
|
||||
memoryStream = new MemoryStream();
|
||||
reader = new BinaryReader(memoryStream);
|
||||
}
|
||||
|
||||
public int read()
|
||||
{
|
||||
return reader.Read();
|
||||
}
|
||||
|
||||
public int read(byte[] b)
|
||||
{
|
||||
return read(b, 0, b.Length);
|
||||
}
|
||||
|
||||
public int read(byte[] b, int off, int len)
|
||||
{
|
||||
return reader.Read(b, off, len);
|
||||
}
|
||||
|
||||
public long available()
|
||||
{
|
||||
return memoryStream.Length - memoryStream.Position;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
reader.Dispose();
|
||||
memoryStream.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public class BinaryOutputStream : IOutputStream
|
||||
{
|
||||
private readonly MemoryStream memoryStream = new MemoryStream();
|
||||
private readonly BinaryWriter writer;
|
||||
|
||||
public BinaryOutputStream()
|
||||
{
|
||||
writer = new BinaryWriter(memoryStream);
|
||||
}
|
||||
|
||||
public void flush()
|
||||
{
|
||||
writer.Flush();
|
||||
}
|
||||
|
||||
public void write(byte[] b)
|
||||
{
|
||||
writer.Write(b);
|
||||
}
|
||||
|
||||
public void write(byte[] b, int off, int len)
|
||||
{
|
||||
writer.Write(b, len, off);
|
||||
}
|
||||
|
||||
public void write(int b)
|
||||
{
|
||||
writer.Write(b);
|
||||
}
|
||||
|
||||
public byte[] ToArray()
|
||||
{
|
||||
return memoryStream.ToArray();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
writer.Dispose();
|
||||
memoryStream.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,83 +0,0 @@
|
||||
namespace UglyToad.Pdf.IO
|
||||
{
|
||||
public class RandomAccessInputStream : IInputStream
|
||||
{
|
||||
private readonly IRandomAccessRead input;
|
||||
private long position;
|
||||
|
||||
/**
|
||||
* Creates a new RandomAccessInputStream, with a position of zero. The InputStream will maintain
|
||||
* its own position independent of the RandomAccessRead.
|
||||
*
|
||||
* @param randomAccessRead The RandomAccessRead to read from.
|
||||
*/
|
||||
public RandomAccessInputStream(IRandomAccessRead randomAccessRead)
|
||||
{
|
||||
input = randomAccessRead;
|
||||
position = 0;
|
||||
}
|
||||
|
||||
void restorePosition()
|
||||
{
|
||||
input.Seek(position);
|
||||
}
|
||||
|
||||
public long available()
|
||||
{
|
||||
restorePosition();
|
||||
long available = input.Length() - input.GetPosition();
|
||||
if (available > int.MaxValue)
|
||||
{
|
||||
return int.MaxValue;
|
||||
}
|
||||
return available;
|
||||
}
|
||||
|
||||
public int read()
|
||||
{
|
||||
restorePosition();
|
||||
if (input.IsEof())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int b = input.Read();
|
||||
position += 1;
|
||||
return b;
|
||||
}
|
||||
|
||||
public int read(byte[] b)
|
||||
{
|
||||
return read(b, 0, b.Length);
|
||||
}
|
||||
|
||||
public int read(byte[] b, int off, int len)
|
||||
{
|
||||
restorePosition();
|
||||
if (input.IsEof())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int n = input.Read(b, off, len);
|
||||
position += n;
|
||||
return n;
|
||||
}
|
||||
|
||||
public long skip(long n)
|
||||
{
|
||||
restorePosition();
|
||||
input.Seek(position + n);
|
||||
position += n;
|
||||
return n;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
input.Dispose();
|
||||
}
|
||||
|
||||
long IInputStream.available()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,42 +0,0 @@
|
||||
namespace UglyToad.Pdf.IO
|
||||
{
|
||||
public class RandomAccessOutputStream : IOutputStream
|
||||
{
|
||||
private readonly RandomAccessWrite writer;
|
||||
|
||||
/**
|
||||
* Constructor to create a new output stream which writes to the given RandomAccessWrite.
|
||||
*
|
||||
* @param writer The random access writer for output
|
||||
*/
|
||||
public RandomAccessOutputStream(RandomAccessWrite writer)
|
||||
{
|
||||
this.writer = writer;
|
||||
// we don't have to maintain a position, as each COSStream can only have one writer.
|
||||
}
|
||||
|
||||
public void write(byte[] b, int offset, int length)
|
||||
{
|
||||
writer.write(b, offset, length);
|
||||
}
|
||||
|
||||
public void flush()
|
||||
{
|
||||
}
|
||||
|
||||
public void write(byte[] b)
|
||||
{
|
||||
writer.write(b);
|
||||
}
|
||||
|
||||
public void write(int b)
|
||||
{
|
||||
writer.write(b);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
writer.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user