2 // System.Web.Hosting.DefaultVirtualDirectory
5 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
9 // Copyright (c) 2006 Novell, Inc (http://www.novell.com)
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 using System.Collections;
37 namespace System.Web.Hosting {
39 class DefaultVirtualDirectory : VirtualDirectory
44 internal DefaultVirtualDirectory (string virtualPath)
51 if (phys_dir == null) {
52 string vpath = VirtualPath;
53 phys_dir = HostingEnvironment.MapPath (vpath);
54 virtual_dir = VirtualPathUtility.GetDirectory (vpath);
58 ArrayList AddDirectories (ArrayList list, string dir)
60 foreach (string name in Directory.GetDirectories (phys_dir)) {
61 string vdir = VirtualPathUtility.Combine (virtual_dir, name);
62 list.Add (new DefaultVirtualDirectory (vdir));
67 ArrayList AddFiles (ArrayList list, string dir)
69 foreach (string name in Directory.GetFiles (phys_dir)) {
70 string vdir = VirtualPathUtility.Combine (virtual_dir, name);
71 list.Add (new DefaultVirtualFile (vdir));
76 public override IEnumerable Children {
79 ArrayList list = new ArrayList ();
80 AddDirectories (list, phys_dir);
81 return AddFiles (list, phys_dir);
85 public override IEnumerable Directories {
88 ArrayList list = new ArrayList ();
89 return AddDirectories (list, phys_dir);
93 public override IEnumerable Files {
96 ArrayList list = new ArrayList ();
97 return AddFiles (list, phys_dir);