20 namespace Deveel.Data.Store {
24 public const int BufferSize = 1024 * 2;
27 if (String.IsNullOrEmpty(fileName))
28 throw new ArgumentNullException(
"fileName");
30 var fileMode = readOnly ? FileMode.Open : FileMode.OpenOrCreate;
31 var fileAccess = readOnly ? FileAccess.Read : FileAccess.ReadWrite;
33 var options = FileOptions.WriteThrough | FileOptions.Encrypted;
34 fileStream =
new System.IO.FileStream(fileName, fileMode, fileAccess, FileShare.None, BufferSize, options);
39 GC.SuppressFinalize(
this);
44 if (fileStream != null)
51 public string FileName {
get;
private set; }
53 public bool IsReadOnly {
get;
private set; }
55 public long Position {
56 get {
return fileStream.Position; }
60 get {
return fileStream.Length; }
64 get {
return File.Exists(FileName); }
67 public long Seek(
long offset, SeekOrigin origin) {
68 return fileStream.Seek(offset, origin);
72 fileStream.SetLength(value);
75 public int Read(byte[] buffer,
int offset,
int length) {
76 return fileStream.Read(buffer, offset, length);
79 public void Write(byte[] buffer,
int offset,
int length) {
80 fileStream.Write(buffer, offset, length);
83 public void Flush(
bool writeThrough) {
93 File.Delete(FileName);
void Dispose(bool disposing)
LocalFile(string fileName, bool readOnly)
long Seek(long offset, SeekOrigin origin)
void Flush(bool writeThrough)
int Read(byte[] buffer, int offset, int length)
void Write(byte[] buffer, int offset, int length)
System.IO.FileStream fileStream
void SetLength(long value)