Exemplo n.º 1
0
 public TarHeader(IDirectoryFolder dir,string basePath)
     : this(dir.CreateDate, Utility.TraceFullDirectoryPath(dir), basePath)
 {
     _size = 0;
     _typeFlag = (byte)EntryTypes.DIRECTORY;
     _name = (_name.EndsWith("/") ? _name : _name + "/");
 }
 internal void DeployPath(string url, IDirectoryFolder folder)
 {
     url = (url.StartsWith("/") ? url : "/" + url);
     url = (url.EndsWith("/") ? url.Substring(0, url.Length - 1) : url);
     lock (_paths)
     {
         if (_paths.ContainsKey(url))
             _paths.Remove(url);
         _paths.Add(url, folder);
     }
 }
 public PhysicalDirectoryFolder(DirectoryInfo dir,PhysicalDirectoryFolder parent)
 {
     _dir = dir;
     _parent = parent;
 }
Exemplo n.º 4
0
 public void AddDirectory(IDirectoryFolder di, string basePath) {
     _bw.Write(new TarHeader(di, basePath).Bytes);
     foreach (IDirectoryFolder d in di.Folders)
         AddDirectory(d, basePath);
     foreach (IDirectoryFile fi in di.Files)
         AddFile(fi, basePath);
 }
Exemplo n.º 5
0
 internal static string TraceFullDirectoryPath(IDirectoryFolder folder)
 {
     string ret = "";
     while (folder != null)
     {
         ret = "/" + folder.Name + ret;
         folder = folder.Parent;
     }
     return ret;
 }
 private string RenderFolderBrowser(IDirectoryFolder folder,Site site,HttpRequest request){
     StringBuilder sb = new StringBuilder();
     sb.AppendLine("<html><head><title>"+folder.Name+"</title>");
     sb.AppendLine("<script src=\"/jquery.js\" type=\"text/javascript\" language=\"javascript\"></script>");
     if (folder.StyleSheets != null)
     {
         foreach (string str in folder.StyleSheets)
             sb.AppendLine("<link type=\"text/css\" rel=\"Stylesheet\" href=\"" + str + "\" />");
     }
     else
     {
         sb.AppendLine("<style>");
         sb.AppendLine("body{margin:5px;background-color:#FFFFFF;color:#000000;}");
         sb.AppendLine("a.Folder, a.File{background-repeat:no-repeat;background-position:left center;display:block;padding:0;margin:0;padding-left:20px;height:25px;border-bottom:solid 1px black;text-decoration:none;}");
         sb.AppendLine("a.Folder{background-image:url(\"" + _folderIconPath + "\");}");
         sb.AppendLine("a.File{background-image:url(\"" + _fileIconPath + "\");}");
         sb.AppendLine("a.Alt{background-color:#CCCCCC;color:#333333;}");
         sb.AppendLine("a.Folder:hover,a.File:hover{background-color:#555555;color:#CCCCCC;}");
         sb.AppendLine("div.vmenu{border:1px solid #aaa;position:absolute;background:#fff;	display:none;font-size:0.75em;height:20px;background-position:center left;background-image:url('"+_downloadIconPath+"');background-repeat:no-repeat;width:75px;padding-left:20px;cursor:pointer;}");
         sb.AppendLine("</style>");
     }
     sb.AppendLine("<script type=\"text/javascript\">");
     sb.AppendLine("function GetMousePosition(event){");
     sb.AppendLine("if (event.clientX!=undefined){ return {left:event.clientX,top:event.clientY};}");
     sb.AppendLine("else if (event.layerX!=undefined){ return {left:event.layerX,top:event.layerY};}");
     sb.AppendLine("else if (event.offsetX!=undefined){return {left:event.offsetX,top:event.offsetY};}");
     sb.AppendLine("else if (event.pageX!=undefined){return {left:event.pageX,top:event.pageY};}");
     sb.AppendLine("else if (event.screenX!=undefined){return {left:event.screenX,top:event.screenY};}");
     sb.AppendLine("else if (event.x!=undefined){return {left:event.x,top:event.y};}");
     sb.AppendLine("return null;}");
     sb.AppendLine("</script>");
     sb.AppendLine("</head>");
     sb.AppendLine("<body>");
     sb.AppendLine("<a class=\"Folder\" href=\"" + request.URL.AbsolutePath + "\">.</a>");
     bool alt=true;
     if (folder.Parent != null)
     {
         alt = false;
         sb.AppendLine("<a class=\"Folder\" href=\"" + request.URL.AbsolutePath.Substring(0, request.URL.AbsolutePath.LastIndexOf("/")) + "\">..</a>");
     }
     foreach (IDirectoryFolder fold in folder.Folders)
     {
         sb.AppendLine("<a oncontextmenu=\"$(this).next().css({ left: GetMousePosition(event).left, top: GetMousePosition(event).top, zIndex: '101' }).show();return false;\" class=\"Folder " + (alt ? "Alt" : "") + "\" href=\"" + request.URL.AbsolutePath + "/" + fold.Name + "\">" + fold.Name + " [" + fold.CreateDate.ToString("ddd, MMM dd yyyy") + "]</a>");
         alt = !alt;
         sb.AppendLine("<div class=\"vmenu\" onmouseout=\"$(this).hide();\" onclick=\"location.href='"+request.URL.AbsolutePath+"/"+fold.Name+"/?DownloadPath=true';\">Download</div>");
     }
     foreach (IDirectoryFile file in folder.Files)
     {
         sb.AppendLine("<a class=\"File " + (alt ? "Alt" : "") + "\" href=\"" + request.URL.AbsolutePath + "/" + file.Name + "\">" + file.Name + " [" + file.CreateDate.ToString("ddd, MMM dd yyyy") + "]</a>");
         alt = !alt;
     }
     sb.AppendLine("</body></html>");
     return sb.ToString();
 }
 private void LocateObjectForPath(string path, IDirectoryFolder folder, out IDirectoryFolder resFold, out IDirectoryFile resFile)
 {
     string dirname = path.Substring(0, path.IndexOf("/"));
     path = path.Substring(dirname.Length + 1);
     IDirectoryFolder[] folders = folder.Folders;
     IDirectoryFile[] files = folder.Files;
     folder = null;
     foreach (IDirectoryFolder id in folders)
     {
         if (id.Name == dirname)
         {
             folder = id;
             break;
         }
     }
     resFile = null;
     resFold = null;
     bool isFile = false;
     if (folder == null)
     {
         foreach (IDirectoryFile fi in files)
         {
             if (fi.Name == dirname)
             {
                 isFile = true;
                 resFile = fi;
                 break;
             }
         }
     }
     if ((path == "/"||path=="") && !isFile)
         resFold = folder;
     if ((path != "/") && (resFold == null) && (resFile==null) && (folder!=null))
         LocateObjectForPath(path, folder, out resFold, out resFile);
         
 }
 private void AppendCompresssedFolder(string path,StreamWriter sw,int index,IDirectoryFolder ifold)
 {
     foreach (IDirectoryFile file in ifold.Files)
     {
         sw.Write(Encoding.Default.GetBytes(index.ToString() + "," + path.TrimStart('/') + "/" + file.Name + "," + file.CreateDate.ToUniversalTime().ToString() + "," + file.Length.ToString()+"\n"));
         BinaryReader br = new BinaryReader(file.ContentStream);
         while (br.BaseStream.Position < br.BaseStream.Length)
             sw.Write(br.ReadBytes(1024));
         sw.Write((byte)10);
         index++;
     }
     foreach (IDirectoryFolder folder in ifold.Folders)
     {
         AppendCompresssedFolder(path + "/" + folder.Name, sw, index, folder);
     }
 }
 public PhysicalDirectoryFile(FileInfo file,PhysicalDirectoryFolder folder)
 {
     _file = file;
     _folder = folder;
 }
Exemplo n.º 10
0
 public void DeployPath(string url, IDirectoryFolder folder)
 {
     lock (Handlers)
     {
         foreach (IRequestHandler irh in Handlers)
         {
             if (irh is DirectoryBrowsingHandler)
             {
                 ((DirectoryBrowsingHandler)irh).DeployPath(url, folder);
                 break;
             }
         }
     }
 }