20 namespace Deveel.Data.Store {
26 private readonly
object objectLock =
new object();
29 if (String.IsNullOrEmpty(filePath))
30 throw new ArgumentNullException(
"filePath");
40 public string FilePath {
get;
private set; }
42 public bool IsOpen {
get;
private set; }
46 GC.SuppressFinalize(
this);
62 return File.Exists(FilePath);
68 get {
return IsOpen ? file.
Length :
new FileInfo(FilePath).Length; }
71 public bool IsReadOnly {
get;
private set; }
78 File.Delete(FilePath);
85 public void Open(
bool readOnly) {
89 IsReadOnly = readOnly;
103 public int Read(
long position, byte[] buffer,
int offset,
int length) {
106 length =
System.Math.Max(0,
System.Math.Min(length, (
int)(Length - position)));
108 if (position < Length) {
109 file.
Seek(position, SeekOrigin.Begin);
110 count = file.
Read(buffer, offset, length);
117 public void Write(
long position, byte[] buffer,
int offset,
int length) {
119 throw new IOException();
123 length =
System.Math.Max(0,
System.Math.Min(length, (
int)(Length - position)));
124 if (position < Length) {
125 file.
Seek(position, SeekOrigin.Begin);
126 file.
Write(buffer, offset, length);
134 }
catch (IOException) {
FileStoreData(string filePath)
void Write(long position, byte[] buffer, int offset, int length)
Writes a given buffer into the block, starting at the absolute position given.
long Seek(long offset, SeekOrigin origin)
void Flush(bool writeThrough)
bool Delete()
Deletes the data block.
int Read(byte[] buffer, int offset, int length)
void Flush()
Flushes the data written in the temporary store of the block to the underlying medium.
void Close()
Closes the block and make it unavailable.
void Write(byte[] buffer, int offset, int length)
An interface for low level store data access methods.
A data store that is backed by a file located at the path given.
void Open(bool readOnly)
Opens the data block and make it ready to be accessed.
int Read(long position, byte[] buffer, int offset, int length)
Reads a given amount of data from the block, starting at the absolute position given and copying into...
void SetLength(long value)
Sets the length of the data block.
void Dispose(bool disposing)
void SetLength(long value)