2002-08-16 Gonzalo Paniagua Javier <gonzalo@ximian.com>
[mono.git] / mcs / class / System.Web / System.Web.UI / BaseParser.cs
1 //
2 // System.Web.UI.BaseParser.cs
3 //
4 // Authors:
5 //      Duncan Mak  (duncan@ximian.com)
6 //      Gonzalo Paniagua Javier (gonzalo@ximian.com)
7 //
8 // (C) 2002 Ximian, Inc. (http://www.ximian.com)
9 //
10 using System.IO;
11 using System.Web;
12
13 namespace System.Web.UI
14 {
15         public class BaseParser
16         {
17                 private HttpContext context;
18                 private string baseDir;
19                 private string baseVDir;
20                 private string vPath;
21
22                 internal string MapPath (string path)
23                 {
24                         return MapPath (path, true);
25                 }
26
27                 internal string MapPath (string path, bool allowCrossAppMapping)
28                 {
29                         return context.Request.MapPath (path, baseVDir, allowCrossAppMapping);
30                 }
31
32                 internal string PhysicalPath (string path)
33                 {
34                         if (Path.DirectorySeparatorChar != '/')
35                                 path = path.Replace ('/', '\\');
36                                 
37                         return Path.GetFullPath (Path.Combine (baseVDir, path));
38                 }
39
40                 internal HttpContext Context
41                 {
42                         get {
43                                 return context;
44                         }
45                 }
46
47                 internal string BaseDir
48                 {
49                         get {
50                                 if (baseDir == null)
51                                         baseDir = MapPath (baseVDir, false);
52
53                                 return baseDir;
54                         }
55                 }
56
57                 internal string BaseVirtualDir
58                 {
59                         get {
60                                 return baseVDir;
61                         }
62                 }
63
64                 internal string CurrentVirtualPath
65                 {
66                         get {
67                                 return vPath;
68                         }
69                 }
70         }
71
72 }
73