Beispiel #1
0
 protected VfsControllerBase(ITracer tracer, IEnvironment environment, string rootPath)
 {
     if (rootPath == null)
     {
         throw new ArgumentNullException("rootPath");
     }
     Tracer = tracer;
     Environment = environment;
     RootPath = Path.GetFullPath(rootPath.TrimEnd(Path.DirectorySeparatorChar));
     MediaTypeMap = new MediaTypeMap();
 }
Beispiel #2
0
 protected VfsControllerBase(ITracer tracer, IEnvironment environment, string rootPath)
 {
     if (rootPath == null)
     {
         throw new ArgumentNullException("rootPath");
     }
     Tracer       = tracer;
     Environment  = environment;
     RootPath     = Path.GetFullPath(rootPath.TrimEnd(Path.DirectorySeparatorChar));
     MediaTypeMap = new MediaTypeMap();
 }
Beispiel #3
0
        private IEnumerable <VfsStatEntry> GetDirectoryResponse(DirectoryInfoBase info)
        {
            Contract.Assert(info != null);
            string baseAddress = Request.RequestUri.AbsoluteUri;

            foreach (FileSystemInfoBase fileSysInfo in info.GetFileSystemInfos())
            {
                bool   isDirectory   = (fileSysInfo.Attributes & FileAttributes.Directory) != 0;
                string mime          = isDirectory ? _directoryMediaType.ToString() : MediaTypeMap.GetMediaType(fileSysInfo.Extension).ToString();
                string unescapedHref = isDirectory ? fileSysInfo.Name + UriSegmentSeparator : fileSysInfo.Name;
                long   size          = isDirectory ? 0 : ((FileInfoBase)fileSysInfo).Length;

                yield return(new VfsStatEntry
                {
                    Name = fileSysInfo.Name,
                    MTime = fileSysInfo.LastWriteTimeUtc,
                    Mime = mime,
                    Size = size,
                    Href = baseAddress + Uri.EscapeUriString(unescapedHref),
                });
            }
        }