~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric

« back to all changes in this revision

Viewing changes to contrib/Sharpen/Sharpen/FileOutputStream.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2011-06-27 17:03:13 UTC
  • mto: (1.8.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 54.
  • Revision ID: james.westby@ubuntu.com-20110627170313-6cvz3s19x6e9hqe9
ImportĀ upstreamĀ versionĀ 2.5.92+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
namespace Sharpen
 
2
{
 
3
        using System;
 
4
        using System.IO;
 
5
 
 
6
        internal class FileOutputStream : OutputStream
 
7
        {
 
8
                public FileOutputStream (FilePath file): this (file.GetPath (), false)
 
9
                {
 
10
                }
 
11
 
 
12
                public FileOutputStream (string file): this (file, false)
 
13
                {
 
14
                }
 
15
 
 
16
                public FileOutputStream (FilePath file, bool append) : this(file.GetPath (), append)
 
17
                {
 
18
                }
 
19
 
 
20
                public FileOutputStream (string file, bool append)
 
21
                {
 
22
                        try {
 
23
                                if (append) {
 
24
                                        base.Wrapped = File.Open (file, System.IO.FileMode.Append, FileAccess.Write);
 
25
                                } else {
 
26
                                        base.Wrapped = File.Open (file, System.IO.FileMode.Create, FileAccess.Write);
 
27
                                }
 
28
                        } catch (DirectoryNotFoundException) {
 
29
                                throw new FileNotFoundException ("File not found: " + file);
 
30
                        }
 
31
                }
 
32
 
 
33
                public FileChannel GetChannel ()
 
34
                {
 
35
                        return new FileChannel ((FileStream)base.Wrapped);
 
36
                }
 
37
        }
 
38
}