DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
FileStream.cs
Go to the documentation of this file.
1 //
2 // Copyright 2010-2015 Deveel
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 using System;
18 using System.IO;
19 
20 namespace Deveel.Data.Store {
21  public sealed class FileStream : Stream {
22  public IFile File { get; private set; }
23 
24  public FileStream(IFile file) {
25  if (file == null)
26  throw new ArgumentNullException("file");
27 
28  File = file;
29  }
30 
31  public override void Flush() {
32  File.Flush(true);
33  }
34 
35  public override long Seek(long offset, SeekOrigin origin) {
36  return File.Seek(offset, origin);
37  }
38 
39  public override void SetLength(long value) {
40  File.SetLength(value);
41  }
42 
43  public override int Read(byte[] buffer, int offset, int count) {
44  return File.Read(buffer, offset, count);
45  }
46 
47  public override void Write(byte[] buffer, int offset, int count) {
48  File.Write(buffer, offset, count);
49  }
50 
51  public override bool CanRead {
52  get { return true; }
53  }
54 
55  public override bool CanSeek {
56  get { return true; }
57  }
58 
59  public override bool CanWrite {
60  get { return !File.IsReadOnly; }
61  }
62 
63  public override long Length {
64  get { return File.Length; }
65  }
66 
67  public override long Position {
68  get { return File.Position; }
69  set { Seek(value, SeekOrigin.Begin); }
70  }
71 
72  protected override void Dispose(bool disposing) {
73  File = null;
74  base.Dispose(disposing);
75  }
76  }
77 }
override void Write(byte[] buffer, int offset, int count)
Definition: FileStream.cs:47
override void Dispose(bool disposing)
Definition: FileStream.cs:72
override void SetLength(long value)
Definition: FileStream.cs:39
override long Seek(long offset, SeekOrigin origin)
Definition: FileStream.cs:35
override int Read(byte[] buffer, int offset, int count)
Definition: FileStream.cs:43