e807c022f9af04445630d81fc4661873824b15a5
[mono.git] / mcs / class / monodoc / Monodoc / storage / UncompiledDocStorage.cs
1 using System;
2 using System.IO;
3 using System.Linq;
4 using System.Collections.Generic;
5
6 namespace Monodoc.Storage
7 {
8         // A read-only storage to access ecma XML document based on a standard directory layout
9         // id are relative path inside the base doc directory
10         public class UncompiledDocStorage : IDocStorage
11         {
12                 readonly string basePath;
13
14                 public UncompiledDocStorage (string basePath)
15                 {
16                         this.basePath = basePath;
17                 }
18
19                 public bool SupportRevision {
20                         get {
21                                 return false;
22                         }
23                 }
24
25                 public IDocRevisionManager RevisionManager {
26                         get {
27                                 return null;
28                         }
29                 }
30
31                 public bool SupportChange {
32                         get {
33                                 return false;
34                         }
35                 }
36
37                 public string Store (string id, string text)
38                 {
39                         throw new NotSupportedException ();
40                 }
41
42                 public string Store (string id, byte[] data)
43                 {
44                         throw new NotSupportedException ();
45                 }
46
47                 public string Store (string id, Stream stream)
48                 {
49                         throw new NotSupportedException ();
50                 }
51
52                 public Stream Retrieve (string id)
53                 {
54                         var path = id;
55                         if ('/' != Path.DirectorySeparatorChar)
56                                 path = path.Replace ('/', Path.DirectorySeparatorChar);
57                         return File.OpenRead (Path.Combine (basePath, path));
58                 }
59
60                 public IEnumerable<string> GetAvailableIds ()
61                 {
62                         return Directory.EnumerateFiles (basePath, "*.xml", SearchOption.AllDirectories);
63                 }
64
65                 public void Dispose ()
66                 {
67                 }
68         }
69 }