Ejemplo n.º 1
0
 // Updates folder sizes recursively
 private void RecursiveryRecalculateFoldersSizes(FileSystemNode node)
 {
     if (node != null && node.Item is FileInfo)
     {
         long size = (node.Item as FileInfo).Length;
         RecalculateParentFolderSize(node, size);
     }
 }
Ejemplo n.º 2
0
 private static FileSystemNode findDocSubNode(FileSystemNode parentNode, string name)
 {
     if (parentNode == null) return null;
     //
     FileSystemNode dirSubNode = parentNode.FindSub(name);
     if (dirSubNode != null) return dirSubNode;
     //
     return findDocFileSubNode(parentNode, name);
 }
Ejemplo n.º 3
0
    static private void NewSelectedFolderRow(DataTable t, FileSystemNode f)
    {
        DataRow r = t.NewRow();

        //just hard code the mapping and don'SelectedFoldersTable waste cycles making it generic
        r["IsExcluded"] = f.IsExcluded;
        r["FullPath"]   = f.FullPath;
        t.Rows.Add(r);
    }
Ejemplo n.º 4
0
    public void AddChild(string newName, string newPath)
    {
        var add = new FileSystemNode {
            Header = newName, NodeName = newName, FullPath = newPath
        };

        add.Expanded += Node_Expand;
        Items.Add(add);
    }
Ejemplo n.º 5
0
 private static List<string> createNamesList(FileSystemNode srcNode, FileSystemNode docNode)
 {
     List<string> result = new List<string>();
     //
     if (srcNode != null) foreach (FileSystemNode subNode in srcNode.SubNodes) addName(result, subNode.Name);
     if (docNode != null) foreach (FileSystemNode subNode in docNode.SubNodes) addName(result, subNode.Name);
     //
     return result;
 }
        public Task <IFileSystemNode> AddTextAsync(string text, AddFileOptions options = null, CancellationToken cancel = default(CancellationToken))
        {
            content = text;
            var node = new FileSystemNode();

            //node.DataBytes = Encoding.UTF8.GetBytes(text);
            node.Name = "123";
            return(Task.FromResult((IFileSystemNode)node));
        }
Ejemplo n.º 7
0
 public void DisplayDirectory(FileSystemNode node)
 {
     Blank();
     TryGetFiles(node.FullPath)?.ToList().ForEach(f => {
         var add = new RowEntity();
         add.TrySetMember(Column(0).BindName, f);
         AddRow(add);
     });
 }
Ejemplo n.º 8
0
        public IResource Load(FileSystemNode n)
        {
            Doom3MapData d = new Doom3MapData();

            d.Load(n.getStream());
            Doom3Map m = new Doom3Map(d);

            return(m);
        }
Ejemplo n.º 9
0
 public static FileSystemNode ToFilesystemNode(this FileInfo file, string mime = "")
 => FileSystemNode.CreateFile(
     file.Name,
     file.Directory.FullName,
     file.CreationTime,
     file.LastWriteTime,
     file.Length,
     Path.DirectorySeparatorChar.ToString(),
     mime);
Ejemplo n.º 10
0
 private void cbxBackupProfiles_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     using (Proc BackupProfile_s = new Proc("BackupProfile_s"))
     {
         BackupProfile_s["@BackupProfileID"] = cbxBackupProfiles.SelectedValue;
         gridIncrementalHistory.ItemsSource  = BackupProfile_s.Table0.DefaultView;
         FileSystemNode.LoadSelectedNodes(BackupProfile_s.Tables[1]);
     }
 }
Ejemplo n.º 11
0
 private void DemoList_SelectedIndexChanged(object sender, EventArgs e)
 {
     //DemoPlayer demo = DemoList.SelectedItems[0].Tag;
     if (DemoList.SelectedItems.Count > 0)
     {
         FileSystemNode n = (FileSystemNode)DemoList.SelectedItems[0].Tag;
         ShowDemoDetails(n);
     }
 }
Ejemplo n.º 12
0
        public void SearchByTree(FileSystem.NodeVisitCallback callback, string searchPath)
        {
            FileSystemNode searchRoot = this._root;

            if (!string.IsNullOrEmpty(searchPath))
            {
                searchRoot = this.GetFirstFile(searchPath) ?? searchRoot;
            }
            Visit(callback, searchRoot);
        }
Ejemplo n.º 13
0
 public void AppendTree(FileSystemNode node)
 {
     TryGetDirectories(node.FullPath)?.ToList().ForEach(d => {
         var child = Find(node, d);
         if (null != child)
         {
             AppendTree(child, d);
         }
     });
 }
Ejemplo n.º 14
0
        public IActionResult CreateDirectory(string base64Path, string newDirectoryName)
        {
            FileSystemNode model = FileSystem.GetNode(Base64.Base64Decode(base64Path ?? ""));

            if (model.IsDirectory)
            {
                FileSystem.CreateDirectory(model, newDirectoryName);
            }
            return(RedirectToAction("Browse", "FileExplorer", new { area = "FileManager", base64Path = model.NodePathBase64 }));
        }
Ejemplo n.º 15
0
        public IActionResult UploadFiles(string base64Path, IFormFileCollection uploadedFiles)
        {
            FileSystemNode model = FileSystem.GetNode(Base64.Base64Decode(base64Path ?? ""));

            if (model.IsDirectory)
            {
                FileSystem.SaveUploadedFiles(model, uploadedFiles);
            }
            return(RedirectToAction("Browse", "FileExplorer", new { area = "FileManager", base64Path = model.NodePathBase64 }));
        }
Ejemplo n.º 16
0
        public void ChangeDir(string destPath)
        {
            var dest = this.FindNode(destPath);

            if (dest == null)
            {
                throw new Exception("Invalid path");
            }

            this.location = dest;
        }
Ejemplo n.º 17
0
        public static async Task <string> AddAsync(string filename)
        {
            if (!File.Exists(filename))
            {
                return(null);
            }

            FileSystemNode node = await Client.FileSystem.AddFileAsync(filename);

            return(node.Hash);
        }
Ejemplo n.º 18
0
        public IResource Load(FileSystemNode n)
        {
            reader = new StreamReader(n.getStream());
            string[] line;
            anim = new Md5Anim();

            while ((line = ReadLineTokens()) != null)
            {
                switch (line[0])
                {
                case "numFrames":
                    anim.Frames = new Md5Frame[int.Parse(line[1])];
                    break;

                case "numJoints":
                    anim.NumJoints = int.Parse(line[1]);
                    break;

                case "frameRate":
                    anim.FrameRate = int.Parse(line[1]);
                    break;

                case "numAnimatedComponents":
                    anim.NumAnimatedComponents = int.Parse(line[1]);
                    break;

                case "hierarchy":
                    LoadHierarchy();
                    break;

                case "baseframe":
                    anim.BaseFrame = LoadFrame(true);
                    break;

                case "frame":
                    anim.Frames[int.Parse(line[1])] = LoadFrame(false);
                    break;

                case "MD5Version":
                    anim.Header.Version = int.Parse(line[1]);
                    if (anim.Header.Version != 10)
                    {
                        Console.WriteLine("md5 warning: version is not 10.");
                    }
                    break;

                case "commandline":
                    //HACK
                    break;
                }
            }

            return(anim);
        }
Ejemplo n.º 19
0
 private void OnSelect(object sender, RoutedEventArgs e)
 {
     try {
         TreeView       senderObj = sender as TreeView;
         FileSystemNode item      = senderObj.SelectedItem as FileSystemNode;
         grid.DisplayDirectory(item);
     }
     catch (Exception ex) {
         Console.WriteLine(ex.Message + "\r\n" + ex.StackTrace);
     }
 }
Ejemplo n.º 20
0
 public FileSystemNode(FileSystemNode Parent, string Name)
 {
     this.Parent  = Parent;
     this.SubPath = Name;
     if (Parent != null)
     {
         Parent.IsSelectedChanged += new Action(OnIsSelectedChanged);             //all children subscribe to their parent's IsSelectedChanged to support keeping IsExcluded in sync
     }
     //FlatList.Add(this);
     IsMissing = true; //this constructor fires first when we chain them so the FileSystemInfo based constructor gets final say on this flag
 }
Ejemplo n.º 21
0
        void m_SysTree_BeforeCollapse(object sender, TreeViewCancelEventArgs e)
        {
            FileSystemNode node = e.Node as FileSystemNode;

            if (node != null)
            {
                if (node.IsDesktop)
                {
                    e.Cancel = true;
                }
            }
        }
		public FileSystemNTFS(IFileSystemStore store) {
			Store = store;

			LoadBPB();

			_mftSector = (BPB_MFTStartCluster64 * BPB_SecPerClus);
			_MFT = new FileNTFS(MFTRecord.Load(0, this), "");
			_root = new FolderNTFS(MFTRecord.Load(5, this), "", true);

			_bitmapFile = new FileNTFS(MFTRecord.Load(6, this), "");
			_bitmap = _bitmapFile.GetBytes(0, _bitmapFile.StreamLength);
		}
Ejemplo n.º 23
0
        private void ModelViewerStart_Click(object sender, EventArgs e)
        {
            if (GameRunning)
            {
                if (Root.Instance.CurrentFlow is SpaceWar2006.Flows.Viewer)
                {
                    FileSystemNode n1 = (FileSystemNode)ModelList.SelectedItems[0].Tag;
                    ((SpaceWar2006.Flows.Viewer)Root.Instance.CurrentFlow).ChangeMesh(n1.GetFullPath());
                }
                else
                {
                    MessageBox.Show(this, "Stop the current game first.", "<°)))><", MessageBoxButtons.AbortRetryIgnore);
                }
                return;
            }

            GameRunning = true;

            Root r = Root.Instance;

            r.Authoritive = true;

            ViewerForm vf = new ViewerForm();

            vf.Show();
            r.ClientClient(new string[] { }, vf.glControl1);

            //r.ClientClient(new string[] { });
            IUserInterface ui = r.UserInterface;

            FileSystemNode n = (FileSystemNode)ModelList.SelectedItems[0].Tag;

            SpaceWar2006.Flows.Viewer v = new SpaceWar2006.Flows.Viewer(n.GetFullPath());
            Root.Instance.CurrentFlow = v;
            v.Start();
            r.CurrentFlow = v;



            v.Start();

            r.ClientLoop();

            //Cheetah.Root.Instance.LocalObjects.Remove(h);

            r.ResourceManager.UnloadAll();
            r.UserInterface.Dispose();
            r.UserInterface = null;
            vf.Close();

            GameRunning = false;
        }
Ejemplo n.º 24
0
        public async Task <IFileSystemNode> ListFileAsync(string path, CancellationToken cancel = default(CancellationToken))
        {
            var cid = await ipfs.ResolveIpfsPathToCidAsync(path, cancel).ConfigureAwait(false);

            var block = await ipfs.Block.GetAsync(cid, cancel).ConfigureAwait(false);

            // TODO: A content-type registry should be used.
            if (cid.ContentType == "dag-pb")
            {
                // fall thru
            }
            else if (cid.ContentType == "raw")
            {
                return(new FileSystemNode
                {
                    Id = cid,
                    Size = block.Size
                });
            }
            else if (cid.ContentType == "cms")
            {
                return(new FileSystemNode
                {
                    Id = cid,
                    Size = block.Size
                });
            }
            else
            {
                throw new NotSupportedException($"Cannot read content type '{cid.ContentType}'.");
            }

            var dag = new DagNode(block.DataStream);
            var dm  = Serializer.Deserialize <DataMessage>(dag.DataStream);
            var fsn = new FileSystemNode
            {
                Id    = cid,
                Links = dag.Links
                        .Select(l => new FileSystemLink
                {
                    Id   = l.Id,
                    Name = l.Name,
                    Size = l.Size
                })
                        .ToArray(),
                IsDirectory = dm.Type == DataType.Directory,
                Size        = (long)(dm.FileSize ?? 0)
            };


            return(fsn);
        }
Ejemplo n.º 25
0
        private void RecalculateParentFolderSize(FileSystemNode node, long extraSize)
        {
            if (node == null)
            {
                return;
            }

            if (node.Parent != null)
            {
                node.Parent.Size += extraSize;
                RecalculateParentFolderSize(node.Parent, extraSize);
            }
        }
Ejemplo n.º 26
0
        public IActionResult Browse(string base64Path)
        {
            FileSystemNode model = FileSystem.GetNode(Base64.Base64Decode(base64Path ?? ""));

            if (model.IsFile)
            {
                return(View("File", model));
            }
            else
            {
                return(View("Directory", model));
            }
        }
Ejemplo n.º 27
0
        public FileSystemNTFS(IFileSystemStore store)
        {
            Store = store;

            LoadBPB();

            _mftSector = (BPB_MFTStartCluster64 * BPB_SecPerClus);
            _MFT       = new FileNTFS(MFTRecord.Load(0, this), "");
            _root      = new FolderNTFS(MFTRecord.Load(5, this), "", true);

            _bitmapFile = new FileNTFS(MFTRecord.Load(6, this), "");
            _bitmap     = _bitmapFile.GetBytes(0, _bitmapFile.StreamLength);
        }
Ejemplo n.º 28
0
        private void BackupProfileSave_Click(object sender, RoutedEventArgs e)
        {
            DataRowView SelectedProfile = cbxBackupProfiles.SelectedItem as DataRowView;

            using (Proc BackupProfile_u = new Proc("BackupProfile_u"))
            {
                BackupProfile_u["@BackupProfileID"] = cbxBackupProfiles.SelectedValue;
                BackupProfile_u["@Name"]            = SelectedProfile["Name"];
                BackupProfile_u["@MediaSizeID"]     = SelectedProfile["MediaSizeID"];
                BackupProfile_u["@Folders"]         = FileSystemNode.GetSelected(SelectedFoldersTable);
                BackupProfile_u.ExecuteNonQuery();
            }
        }
Ejemplo n.º 29
0
        internal override FileRecoveryStatus GetChanceOfRecovery(FileSystemNode node)
        {
            FileNTFS file = node as FileNTFS;

            if (file == null)
            {
                return(FileRecoveryStatus.Unknown);
            }
            else
            {
                IEnumerable <IRun> runs = file.GetRuns();
                if (runs == null)
                {
                    // The data stream is resident, so recovery is trivial.
                    return(FileRecoveryStatus.Resident);
                }
                else
                {
                    ulong totalClusters = 0;
                    ulong usedClusters  = 0;
                    // Check the status of each cluster in the runs.
                    foreach (IRun run in runs)
                    {
                        if (run.HasRealClusters)
                        {
                            totalClusters += run.LengthInClusters;
                            for (ulong i = run.LCN; i < run.LengthInClusters; i++)
                            {
                                if (GetClusterStatus(run.LCN + i) == SectorStatus.Used ||
                                    GetClusterStatus(run.LCN + i) == SectorStatus.Bad)
                                {
                                    usedClusters++;
                                }
                            }
                        }
                    }
                    if (usedClusters == 0)
                    {
                        return(FileRecoveryStatus.MaybeOverwritten);
                    }
                    else if (usedClusters < totalClusters)
                    {
                        return(FileRecoveryStatus.PartiallyOverwritten);
                    }
                    else
                    {
                        return(FileRecoveryStatus.Overwritten);
                    }
                }
            }
        }
Ejemplo n.º 30
0
        private void SaveNode(FileSystemNode node = null)
        {
            if (_tree.HasSingleTopLevelNode())
            {
                return;
            }

            if (node == null)
            {
                node = _tree.GetPreLastTopLevelNode();
            }

            FlushNode(node);
        }
Ejemplo n.º 31
0
 private void Visit(FileSystem.NodeVisitCallback callback, FileSystemNode node)
 {
     if (!callback(node, 0, 1))
     {
         return;
     }
     if (node is Folder && !(node is HiddenDataStreamFileNTFS))                //No zip support yet
     {
         foreach (FileSystemNode child in node.GetChildren())
         {
             Visit(callback, child);
         }
     }
 }
Ejemplo n.º 32
0
        public IActionResult Download(string base64Path)
        {
            FileSystemNode model = FileSystem.GetNode(Base64.Base64Decode(base64Path ?? ""));

            if (model.IsFile)
            {
                return(File(System.IO.File.OpenRead(model.NodePath), model.MimeType, model.Name));
            }
            else
            {
                string zipName = model.Name + ".zip";
                return(File(FileSystem.DirectoryGetZipStream(model), FileSystem.GetMimeType(zipName), zipName));
            }
        }
Ejemplo n.º 33
0
    static private void RefreshIsSubSelected(FileSystemNode node)
    {
        FolderNode folder = node as FolderNode;

        if (node == null)
        {
            return;
        }

        node.IsSubSelected = folder.Children.Where(n => n.Value.IsSubSelected || n.Value.IsSelected).Count() > 0; //gotsta admit, the linq extensions sure do come in amazingly handy

        node.SetIsExcluded();                                                                                     //must do this after setting IsSubSelected since it depends on that property

        RefreshIsSubSelected(folder.Parent);
    }
        private void RecurseThroughContainer(FileSystemNode zipContainer, int level = 0)
        {
            foreach (var child in zipContainer.Children)
            {
                var tabs = Enumerable.Repeat("\t", level).Aggregate("", (a,b)=>a+b);
                if (child.IsFile)
                {
                    using (var stream = new StreamReader(child.InputStream))
                    {
                        Console.WriteLine("{0}{1} contents: {2}", tabs, child.Name, stream.ReadToEnd());
                    }
                }
                else
                {
                    Console.WriteLine("{0}file Name in zip {1}", tabs, child.Name);
                }

                RecurseThroughContainer(child, ++level);
            }
        }
Ejemplo n.º 35
0
 private static FileSystemNode CreateFileSystemDirNode(DirectoryInfo directoryInfo)
 {
     FileSystemNode result = new FileSystemNode(directoryInfo.Name, isDir: true);
     //
     //if (directoryInfo.  //(File.Exists(""))
     DocIgnore docIgnore = new DocIgnore(directoryInfo);
     //
     foreach (DirectoryInfo subDirectoryInfo in directoryInfo.EnumerateDirectories())
     {
         if (docIgnore.Ignore(subDirectoryInfo)) continue;
         result.AddSub(CreateFileSystemDirNode(subDirectoryInfo), docIgnore.UserIgnore(subDirectoryInfo));
     }
     //
     foreach (FileInfo fileInfo in directoryInfo.EnumerateFiles())
     {
         if (docIgnore.Ignore(fileInfo)) continue;
         result.AddFile(fileInfo.Name, docIgnore.UserIgnore(fileInfo));
     }
     //
     return result;
 }
Ejemplo n.º 36
0
 public IResource Load(FileSystemNode n)
 {
     Doom3MapData d = new Doom3MapData();
     d.Load(n.getStream());
     Doom3Map m = new Doom3Map(d);
     return m;
 }
Ejemplo n.º 37
0
        private void LoadNode(FileSystemNode node)
        {
            var nodes = new List<FileSystemNode>();

            AddNodes(nodes, node, true);

            if ((Mode & FileSystemTreeViewMode.FilesAndDirectories) != 0)
                AddNodes(nodes, node, false);

            try
            {
                BeginInvoke(
                    new InvokeDelegate<FileSystemNode, List<FileSystemNode>>((n, l) =>
                    {
                        BeginUpdate();

                        foreach (var item in l)
                        {
                            n.TreeNode.Nodes.Add(item.TreeNode);

                            OnNodeCreated(new FileSystemNodeEventArgs(item));
                        }

                        node.TreeNode.Expand();

                        EndUpdate();
                    }),
                    new object[] { node, nodes }
                );
            }
            catch (InvalidOperationException)
            {
                return;
            }

            StartResolver();
        }
Ejemplo n.º 38
0
        private static NavNode CreateNavNode(FileSystemNode srcParentNode, FileSystemNode docParentNode)
        {
            if (userIgnore(srcParentNode)) return null;
            if (userIgnore(docParentNode)) return null;
            //
            NavNode result = new NavNode("root", NavNodeKind.Dir);
            result.Name = (srcParentNode != null) ? srcParentNode.Name : docParentNode.Name;
            //
            List<string> names = createNamesList(srcParentNode, docParentNode);
            if (names.Count <= 0) return null;
            //
            foreach(string name in names)
            {
                //if (name == "collection.js.html")
                //{
                //    Debug.WriteLine("0");
                //}
                //
                FileSystemNode srcNode = findSubNode(srcParentNode, name);
                FileSystemNode docNode = findDocSubNode(docParentNode, name); // name, name+".html", name+".xml"
                FileSystemNodeKind srcNodeKind = calcNodeKind(srcNode);
                FileSystemNodeKind docNodeKind = calcNodeKind(docNode);
                //
                //if (docNodeKind == FileSystemNodeKind.None)
                //{
                //    // dir/none, file/none
                //    //if (srcNode == null)
                //    //{
                //    //    Debug.WriteLine("1");
                //    //}
                //    result.AddSub(new NavNode(srcNode.Name, NavNodeKind.Placeholder));
                //}
                //else if (docNodeKind == FileSystemNodeKind.File)
                //{
                //    // dir/file, file/file, none/file
                //    result.AddSub(new NavNode(docNode.Name, NavNodeKind.Page));
                //}
                //else
                //{
                //    // dir/dir, dir/file, file/dir, none/dir
                //    result.AddSub(CreateNavNode(srcNode, docNode));
                //}


                switch (srcNodeKind)
                {
                    case FileSystemNodeKind.Dir:
                        switch (docNodeKind)
                        {
                            case FileSystemNodeKind.Dir:
                                // dir/dir
                                result.AddSub(CreateNavNode(srcNode, docNode));
                                break;
                            case FileSystemNodeKind.File:
                                result.AddSub(CreateNavNode(srcNode, docNode));
                                break;
                            case FileSystemNodeKind.None:
                                // dir/none
                                result.AddSub(CreateNavNode(srcNode, docNode));
                                break;
                        }
                        break;
                    case FileSystemNodeKind.File:
                        switch (docNodeKind)
                        {
                            case FileSystemNodeKind.Dir:
                                // file/dir
                                NavNode navNode = CreateNavNode(srcNode, docNode);
                                FileSystemNode docFileNode = findDocFileSubNode(docParentNode, name);
                                if (docFileNode != null)
                                {
                                    navNode.Name = docFileNode.Name;
                                    navNode.Kind = NavNodeKind.DirPage;
                                }
                                result.AddSub(navNode);
                                break;
                            case FileSystemNodeKind.File:
                                // file/file
                                if (!userIgnore(docNode))
                                {
                                    result.AddSub(new NavNode(docNode.Name, NavNodeKind.Page));
                                }
                                break;
                            case FileSystemNodeKind.None:
                                // file/none
                                result.AddSub(new NavNode(srcNode.Name, NavNodeKind.Placeholder));
                                break;
                        }
                        break;
                    case FileSystemNodeKind.None:
                        switch (docNodeKind)
                        {
                            case FileSystemNodeKind.Dir:
                                // none/dir
                                result.AddSub(CreateNavNode(srcNode, docNode));
                                break;
                            case FileSystemNodeKind.File:
                                // none/file
                                if (!userIgnore(docNode))
                                {
                                    FileSystemNode docDirNode = findSubNode(docParentNode, NavNode.CalcDisplayName(name));
                                    if (docDirNode == null)
                                    {
                                        result.AddSub(new NavNode(docNode.Name, NavNodeKind.Page));
                                    }
                                }
                                break;
                            case FileSystemNodeKind.None:
                                // none/none, impossible
                                throw new Exception("impossible case found");
                        }
                        break;
                }
            }
            //
            if (result.SubNodes.Count > 0)
            {
                result.SortSubNodes();
                return result;
            }
            return null;
        }
Ejemplo n.º 39
0
		void m_SysTree_BeforeExpand(object sender, TreeViewCancelEventArgs e)
		{
			FileSystemNode node = e.Node as FileSystemNode;

			if (node != null)
			{
				if (!node.IsDesktop)
				{
					if (node.Nodes.Count == 1 && (node.CanHaveChilds))
					{
						node.Nodes.Clear();

						string path = node.Path;

						string[] dirs = Directory.GetDirectories(path);

						foreach (string dir in dirs)
						{
							string dirName = GetDirName(dir);

							DirectoryInfo infoDir = new DirectoryInfo(dir);

							bool noAccess = infoDir.GetAccessControl().AreAccessRulesProtected;

							if (noAccess) continue;

							FileSystemNode newDir = new FileSystemNode(dirName,
								dir, true, "folder", m_ShowFiles);

							node.Nodes.Add(newDir);
						}

						if (m_ShowFiles)
						{
							string[] files = Directory.GetFiles(path);

							foreach (string file in files)
							{
								string dirName = GetDirName(file);

								FileSystemNode newDir = new FileSystemNode(dirName,
									file, false, GetIconForFile(file), m_ShowFiles);

								node.Nodes.Add(newDir);
							}
						}
					}
					else
					{
						if (node is DriveNode)
						{
							DriveNode drvnode = node as DriveNode;

							if (!drvnode.IsReady)
							{
								e.Cancel = true;

								if (m_ShowMessage)
									MessageBox.Show(drvnode.Path +  " Is Not Ready","Device Error:",
										MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
								return;
							}

						}
					}
				}
			}
		}
Ejemplo n.º 40
0
 public FileSystemNodeEventArgs(FileSystemNode node)
 {
     Node = node;
 }
Ejemplo n.º 41
0
        public IResource Load(FileSystemNode n)
        {
            reader = new StreamReader(n.getStream());
            string[] line;
            model = new Md5Model();

            while ((line = ReadLineTokens()) != null)
            {
                switch (line[0])
                {
                    case "numJoints":
                        model.Joints = new Md5Joint[int.Parse(line[1])];
                        break;
                    case "numMeshes":
                        model.Meshes = new Md5Mesh[int.Parse(line[1])];
                        break;
                    case "joints":
                        LoadJoints();
                        break;
                    case "mesh":
                        LoadMesh();
                        break;
                    case "MD5Version":
                        model.Header.Version = int.Parse(line[1]);
                        if (model.Header.Version != 10)
                            Console.WriteLine("md5 warning: version is not 10.");
                        break;
                    case "commandline":
                        //HACK
                        break;
                }
            }

            return model;
        }
		private void Visit(FileSystem.NodeVisitCallback callback, FileSystemNode node) {
			if (!callback(node, 0, 1)) {
				return;
			}
			if (node is Folder && !(node is HiddenDataStreamFileNTFS)) {  //No zip support yet
				foreach (FileSystemNode child in node.GetChildren()) {
					Visit(callback, child);
				}
			}
		}
Ejemplo n.º 43
0
 void ShowDemoDetails(FileSystemNode demo)
 {
     DemoFile.Text = demo.info.FullName;
 }
Ejemplo n.º 44
0
 private static FileSystemNode findSubNode(FileSystemNode parentNode, string name)
 {
     if (parentNode == null) return null;
     return parentNode.FindSub(name);
 }
Ejemplo n.º 45
0
 private static FileSystemNodeKind calcNodeKind(FileSystemNode node)
 {
     if (node == null) return FileSystemNodeKind.None;
     if (node.IsDir) return FileSystemNodeKind.Dir;
     return FileSystemNodeKind.File;
 }
Ejemplo n.º 46
0
 private static string calcDocNodeName(FileSystemNode srcNode)
 {
     string docSuffix = srcNode.IsDir ? "" : ".html";
     return srcNode.Name + docSuffix;
 }
Ejemplo n.º 47
0
 private static NavNode CreateNavNode_Old(FileSystemNode srcNode, FileSystemNode docNode)
 {
     NavNode result = new NavNode("root", NavNodeKind.Dir);
     //
     if (docNode != null)
     {
         result.Name = docNode.Name;
         //
         foreach (FileSystemNode docSubNode in docNode.SubNodes)
         {
             if (docSubNode.IsDir)
             {
                 FileSystemNode srcSubNode = FileSystemNode.FindSub(srcNode, docSubNode.Name);
                 NavNode resultSubNode = CreateNavNode(srcSubNode, docSubNode);
                 if (resultSubNode != null)
                 {
                     FileSystemNode docFileSubNode = docNode.FindSub(docSubNode.Name + ".html");
                     if (docFileSubNode != null)
                     {
                         // doc dir and doc file, e.g. "collection.js" dir and "collection.js.html" file:
                         //
                         resultSubNode.Name += ".html";
                         resultSubNode.Kind = NavNodeKind.DirPage;
                     }
                     result.AddSub(resultSubNode);
                 }
             }
             else
             {
                 FileSystemNode docDirSubNode = docNode.FindSub(NavNode.CalcDisplayName(docSubNode.Name));
                 if (docDirSubNode == null)
                 {
                     NavNode resultSubNode = new NavNode(docSubNode.Name, NavNodeKind.Page);
                     result.AddSub(resultSubNode);
                 }
                 else
                 {
                     // the pair NavNodeKind.DirPage file, e.g. "collection.js.html"
                 }
             }
         }
     }
     //
     if (srcNode != null)
     {
         result.Name = srcNode.Name;
         //
         foreach (FileSystemNode srcSubNode in srcNode.SubNodes)
         {
             FileSystemNode docSubNode = FileSystemNode.FindSub(docNode, calcDocNodeName(srcSubNode));
             if (docSubNode == null)
             {
                 // the src js file is not documented yet:
                 //
                 if (srcSubNode.IsDir)
                 {
                     NavNode resultSubNode = CreateNavNode(srcSubNode, docSubNode);
                     if (resultSubNode != null) result.AddSub(resultSubNode);
                 }
                 else
                 {
                     NavNode resultSubNode = new NavNode(srcSubNode.Name, NavNodeKind.Placeholder);
                     result.AddSub(resultSubNode);
                 }
             }
         }
     }
     //
     if (result.SubNodes.Count > 0)
     {
         result.SortSubNodes();
         return result;
     }
     //
     return null;
 }
Ejemplo n.º 48
0
 public bool CanLoad(FileSystemNode n)
 {
     return n.info != null && (n.info.Extension.ToLower() == ".proc");
 }
Ejemplo n.º 49
0
 private static FileSystemNode findDocFileSubNode(FileSystemNode parentNode, string name)
 {
     if (parentNode == null) return null;
     //
     FileSystemNode htmlSubNode = parentNode.FindSub(name + ".html");
     if (htmlSubNode != null) return htmlSubNode;
     //
     FileSystemNode xmlSubNode = parentNode.FindSub(name + ".xml");
     if (xmlSubNode != null) return xmlSubNode;
     //
     return null;
 }
Ejemplo n.º 50
0
 public ZipContainer(FileSystemNode fsn)
 {
     _name = fsn.Name;
     _parent = null;
     Zip = new SevenZipExtractor(fsn.InputStream);
 }
Ejemplo n.º 51
0
 bool IResourceLoader.CanLoad(FileSystemNode n)
 {
     return n.info != null && n.info.Extension.ToLower() == ".terrain";
 }
		internal override FileRecoveryStatus GetChanceOfRecovery(FileSystemNode node) {
			FileNTFS file = node as FileNTFS;
			if (file == null) {
				return FileRecoveryStatus.Unknown;
			} else {
				IEnumerable<IRun> runs = file.GetRuns();
				if (runs == null) {
					// The data stream is resident, so recovery is trivial.
					return FileRecoveryStatus.Resident;
				} else {
					ulong totalClusters = 0;
					ulong usedClusters = 0;
					// Check the status of each cluster in the runs.
					foreach (IRun run in runs) {
						if (run.HasRealClusters) {
							totalClusters += run.LengthInClusters;
							for (ulong i = run.LCN; i < run.LengthInClusters; i++) {
								if (GetClusterStatus(run.LCN + i) == SectorStatus.Used
										|| GetClusterStatus(run.LCN + i) == SectorStatus.Bad) {
									usedClusters++;
								}
							}
						}
					}
					if (usedClusters == 0) {
						return FileRecoveryStatus.MaybeOverwritten;
					} else if (usedClusters < totalClusters) {
						return FileRecoveryStatus.PartiallyOverwritten;
					} else {
						return FileRecoveryStatus.Overwritten;
					}
				}
			}
		}
Ejemplo n.º 53
0
        IResource IResourceLoader.Load(FileSystemNode n)
        {
            StreamReader r = new StreamReader(n.getStream());
            string line;

            string header = r.ReadLine().Trim();
            if (header != "TERRAINTEXT")
                return null;

            IHeightMap hm = null;
            Texture color = null;
            Texture detail = null;
            float size = 1;
            float heightscale = 1;
            int patchsize = 33;

            while ((line = r.ReadLine()) != null)
            {
                line = line.Trim();
                if (line.Length == 0 || line.StartsWith("#"))
                    continue;

                string[] split = line.Split(new char[] { ':' });
                string key = split[0].Trim();
                string val = split[1].Trim();

                switch (key)
                {
                    case "colormap":
                        color = Root.Instance.ResourceManager.LoadTexture(val);
                        break;
                    case "heightmap":
                        hm = Root.Instance.ResourceManager.LoadHeightMap(val);
                        break;
                    case "detailmap":
                        detail = Root.Instance.ResourceManager.LoadTexture(val);
                        break;
                    case "patchsize":
                        patchsize = int.Parse(val);
                        break;
                    case "heightscale":
                        heightscale = float.Parse(val);
                        break;
                    case "size":
                        size = float.Parse(val);
                        break;
                }

            }

            Terrain t = new Terrain(hm, color, detail,size,heightscale,patchsize);

            return t;
        }
Ejemplo n.º 54
0
        public IResource Load(FileSystemNode n)
        {
            reader = new StreamReader(n.getStream());
            string[] line;
            anim = new Md5Anim();

            while ((line = ReadLineTokens()) != null)
            {
                switch (line[0])
                {
                    case "numFrames":
                        anim.Frames = new Md5Frame[int.Parse(line[1])];
                        break;
                    case "numJoints":
                        anim.NumJoints = int.Parse(line[1]);
                        break;
                    case "frameRate":
                        anim.FrameRate = int.Parse(line[1]);
                        break;
                    case "numAnimatedComponents":
                        anim.NumAnimatedComponents = int.Parse(line[1]);
                        break;
                    case "hierarchy":
                        LoadHierarchy();
                        break;
                    case "baseframe":
                        anim.BaseFrame = LoadFrame(true);
                        break;
                    case "frame":
                        anim.Frames[int.Parse(line[1])]=LoadFrame(false);
                        break;
                    case "MD5Version":
                        anim.Header.Version = int.Parse(line[1]);
                        if (anim.Header.Version != 10)
                            Console.WriteLine("md5 warning: version is not 10.");
                        break;
                    case "commandline":
                        //HACK
                        break;
                }
            }

            return anim;
        }
Ejemplo n.º 55
0
        private void AddNodes(List<FileSystemNode> nodes, FileSystemNode node, bool directories)
        {
            var items = new List<string>();

            foreach (string path in (directories ? Directory.GetDirectories(node.FileInfo.FullName) : Directory.GetFiles(node.FileInfo.FullName)))
            {
                items.Add(Path.GetFileName(path));
            }

            items.Sort((a, b) => String.Compare(a, b, true));

            foreach (string item in items)
            {
                var subNode = CreateNode(Path.Combine(node.FileInfo.FullName, item));

                if (subNode != null)
                    nodes.Add(subNode);
            }
        }
Ejemplo n.º 56
0
		void Populate()
		{
			string Desktop = System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

			FileSystemNode desk = new FileSystemNode("Desktop", Desktop, false, "desktop", m_ShowFiles);			
		
			desk.IsDesktop = true;

			m_SysTree.Nodes.Add(desk);

			string mydocs = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

			FileSystemNode docs = new FileSystemNode("MyDocuments", mydocs, true, "mydocs", m_ShowFiles);

			desk.Nodes.Add(docs);

		//	int index = 3;
//
			//Icon ico = Icon.ExtractAssociatedIcon("c:\\windows\\Explorer.exe",index);

			//Bitmap bmp = ico.ToBitmap();

			m_SysTree.ImageList.Images.Add("desktop", Properties.Resources.desktop);

		//	ico = Icon.ExtractAssociatedIcon("c:\\windows\\Explorer.exe", index);

			m_SysTree.ImageList.Images.Add("mydocs", Properties.Resources.folder_document);
			m_SysTree.ImageList.Images.Add("folder", Properties.Resources.folder);

			m_SysTree.ImageList.Images.Add("hd", Properties.Resources.diskdrive);
			m_SysTree.ImageList.Images.Add("cdrom", Properties.Resources.cd);
			m_SysTree.ImageList.Images.Add("network", Properties.Resources.harddisk_network);

			DriveInfo[] drives = DriveInfo.GetDrives();

			foreach (DriveInfo drive in drives)
			{
				desk.Nodes.Add(new DriveNode(drive));
			}
			

			desk.Expand();
		}
Ejemplo n.º 57
0
        private FileSystemNode CreateNode(string path)
        {
            var fileInfo = new FileInfo(path);

            if (!_showHidden && (fileInfo.Attributes & FileAttributes.Hidden) != 0)
                return null;

            int imageIndex;

            if ((fileInfo.Attributes & FileAttributes.Directory) != 0)
            {
                imageIndex = _folderIcon;
            }
            else
            {
                string dummyName = "dummy" + Path.GetExtension(path);

                imageIndex = _systemImageList.AddShellIcon(dummyName, ShellIconType.UseFileAttributes);
            }

            string name = String.IsNullOrEmpty(fileInfo.Name) ? fileInfo.FullName : fileInfo.Name;

            var node = new FileSystemNode(new TreeNode(name, imageIndex, imageIndex), fileInfo);

            if ((fileInfo.Attributes & FileAttributes.Directory) != 0)
            {
                if (!DirectoryContainsItems(fileInfo))
                    node.IsLoaded = true;
                else
                    node.TreeNode.Nodes.Add(new TreeNode("Loading..."));
            }

            _iconResolveQueue.Enqueue(node);

            return node;
        }
Ejemplo n.º 58
0
		public FileSystemNode GetFileSystemNode(String path) {
			LoadData();
			if (_node == null) {
				if (IsDirectory) {
					_node = new FolderNTFS(this, path);
				} else if (_namedDataAttributes.Count > 0) {
					_node = new HiddenDataStreamFileNTFS(this, path);
				} else {
					_node = new FileNTFS(this, path);
				}
			}
			return _node;
		}
Ejemplo n.º 59
0
 private static bool userIgnore(FileSystemNode fileSystemNode)
 {
     if (!Globals.OutSettings.DevOutMode)
     {
         if ((fileSystemNode != null) && (fileSystemNode.UserIgnore)) return true;
     }
     //
     return false;
 }