Ejemplo n.º 1
0
        public void ViewParameterFileTreeOutputForDiagnostics()
        {
            var rootDir = Path.GetFullPath(RelativePath);

            if (!Directory.Exists(rootDir))
            {
                context.WriteLine("Invalid path specified: {0}", rootDir);
                context.WriteLine("Press <enter> to exit...");
                return;
            }
            context.WriteLine("{0} = {1}", "RelativePath", RelativePath);
            context.WriteLine("{0} = {1}", "AbsolutePath", rootDir);

            var tree = new FileTree(rootDir);

            context.WriteLine("Total number of files in the tree: {0}", tree.NodeRegistry.Count);
            context.WriteLine("");
            context.WriteLine("Filename (property count)");
            context.WriteLine("");
            foreach (var f in tree.NodeRegistry)
            {
                context.WriteLine("{0} ({1})", f.Key, f.Value.Properties.Count);
            }
            PrintTreeForDiagnostics(tree);
        }
Ejemplo n.º 2
0
        //working for relative and absolute
        public static Response RemoveDirectory(string path)
        {
            var response = ResponseFormation.GetResponse();

            var directory = FileTree.GetDirectory(path);

            if (directory == null)
            {
                response.Message = "Directory does not exist";
            }
            else
            {
                DirectoryNode parent = FileTree.GetDirectory(PathHelpers.GetDirFromPath(path));
                FileTree.RemoveDirectory(parent, directory);

                //if local delete files from disk
                RemoveFilesByDirectory(directory);
                response.IsSuccess = true;
                response.Message   = "Directory removed successfully";
                FileTreeService.UpdateFileTree(FileTree.GetRootDirectory().SerializeToByteArray());

                //else forward
            }

            return(response);
        }
Ejemplo n.º 3
0
        //working for relative and absolute
        public static Response MoveDirectory(string curPath, string newPath)
        {
            var response = ResponseFormation.GetResponse();

            var directory = FileTree.GetDirectory(curPath);

            if (directory == null)
            {
                response.Message = $"Directory {curPath} does not exist";
            }
            else
            {
                DirectoryNode newParent = FileTree.GetDirectory(newPath);
                if (newParent == null)
                {
                    response.Message = $"Directory {newPath} does not exist";
                }
                else
                {
                    DirectoryNode curParent = FileTree.GetDirectory(PathHelpers.GetDirFromPath(curPath));
                    FileTree.RemoveDirectory(curParent, directory);
                    FileTree.AddDirectory(newParent, directory);

                    response.IsSuccess = true;
                    response.Message   = "Directory moved successfully";
                    FileTreeService.UpdateFileTree(FileTree.GetRootDirectory().SerializeToByteArray());
                }
            }

            return(response);
        }
Ejemplo n.º 4
0
        //working for relative and absolute
        public static Response ListContent(string path)
        {
            var response = ResponseFormation.GetResponse();

            var directory = FileTree.GetDirectory(path);

            if (directory == null)
            {
                response.Message = "Directory does not exist";
            }
            else
            {
                response.IsSuccess = true;
                string msg = "";
                foreach (var dir in directory.Directories)
                {
                    msg += dir.Name + "+\n";
                }
                foreach (var file in directory.Files)
                {
                    msg += file.Name + "\n";
                }

                response.Message = msg;
            }

            return(response);
        }
Ejemplo n.º 5
0
        //working for relative and absolute
        public static Response CreateDirectory(string path)
        {
            var response = ResponseFormation.GetResponse();

            var directory = FileTree.GetDirectory(path);

            if (directory != null)
            {
                response.Message = "Directory already exists";
            }
            else
            {
                directory = new DirectoryNode(PathHelpers.GetFilenameFromPath(path));
                var parentDirStr = PathHelpers.GetDirFromPath(path);
                var parent       = FileTree.GetDirectory(parentDirStr);
                if (parent == null)
                {
                    response.Message = $"Directory {parentDirStr} does not exist";
                }
                else
                {
                    FileTree.AddDirectory(parent, directory);
                    response.IsSuccess = true;
                    response.Message   = "Directory created successfully";
                    FileTreeService.UpdateFileTree(FileTree.GetRootDirectory().SerializeToByteArray());
                }
            }

            return(response);
        }
        /// <summary>
        /// Handles the upload.
        /// </summary>
        private void HandleUpload()
        {
            String   query    = Process.QueryEvents["mainvalue"];
            FileTree fileTree = new FileTree(Process);

            fileTree.SaveUploadedFiles(query);
        }
        /// <summary>
        /// Handles the remove file.
        /// </summary>
        private void HandleRemoveFile()
        {
            String   path     = Process.QueryEvents["mainvalue"];
            FileTree filetree = new FileTree(Process);

            filetree.DeleteFile(path);
        }
Ejemplo n.º 8
0
        public NameServer()
        {
            sr = new serialization();

            try
            {
                fileTree = sr.deserialize();
            }
            catch (Exception e)
            {
                Console.WriteLine("Can't deserialize file tree!");
                Console.WriteLine(e.Message);

                throw new Exception("Can't deserialize!");
            }

            try
            {
                listOfFileServers = sr.readFileServersList();
            }
            catch (Exception e)
            {
                Console.WriteLine("Can't read file servers list!");
                Console.WriteLine(e.Message);

                throw new Exception("Can't read list of file servers!");
            }
        }
Ejemplo n.º 9
0
        public void PropertiesClassGivesSameResultsAsParameterFileTree()
        {
            var rootDir   = Path.GetFullPath(RelativePath);
            var tree      = new FileTree(rootDir);
            var filesRead = 0;
            var propsRead = 0;

            foreach (var file in tree.NodeRegistry)
            {
                var pc = new PropertiesClass();
                Assert.IsTrue(System.IO.File.Exists(file.Key));
                using (var stream = new FileStream(file.Key, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    pc.Load(stream);
                    foreach (var prop in file.Value.Properties)
                    {
                        Assert.AreEqual(prop.Value, pc.GetProperty(prop.Key));
                        propsRead++;
                    }
                }
                filesRead++;
            }
            context.WriteLine("Total Files Parsed: {0}", filesRead);
            context.WriteLine("Total Properties Compared: {0}", propsRead);
        }
        /// <summary>
        /// ファイルビューのコンテキストメニュー [フォルダを削除]
        /// </summary>
        void RaiseFileViewDeleteFolderCommand()
        {
            var items = this.FileTree.First().Items.SourceCollection;

            foreach (var item in items)
            {
                var treeItem = item as FileTreeItem;
                if (treeItem.IsSelected)
                {
                    var path = treeItem._Directory.FullName;
                    if (OpenMessageBox(this.Title.Value, MessageBoxImage.Question, MessageBoxButton.OKCancel, MessageBoxResult.None,
                                       string.Format("{0} を削除してもよろしいですか?", path)) == MessageBoxResult.OK)
                    {
                        try {
                            Microsoft.VisualBasic.FileIO.FileSystem.DeleteDirectory(path,
                                                                                    Microsoft.VisualBasic.FileIO.UIOption.OnlyErrorDialogs,
                                                                                    Microsoft.VisualBasic.FileIO.RecycleOption.SendToRecycleBin,
                                                                                    Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing);
                        } catch (Exception e) {
                            OpenMessageBox(this.Title.Value, MessageBoxImage.Error, MessageBoxButton.OK, MessageBoxResult.OK, e.Message);
                        }
                        FileTree.Clear();
                        FileTree.Add(new FileTreeItem(this.ProjectFolderPath.Value));
                    }
                }
            }
        }
        public void CreateFileTreeTest()
        {
            FileTree tree = new FileTree();

            Assert.NotNull(tree.RootNode);
            Assert.Null(tree.SelectedNode);
        }
Ejemplo n.º 12
0
        public void WriteBinary(BinaryWriter w)
        {
            // Don't write database if empty (BinarySerializable will detect and delete file)
            if (IsEmpty)
            {
                return;
            }

            // Ensure the database has been converted to queryable/writable form
            ConvertToImmutable();

            w.Write(BinaryFileFormatVersion);

            // Write strings
            StringStore.WriteBinary(w);

            // Write symbol tree
            DeclaredMembers.WriteBinary(w);

            // Write details
            w.Write(DeclaredMemberDetails);

            // Write symbol locations
            w.Write(DeclaredMemberLocations);

            // Write file tree
            FileTree.WriteBinary(w);

            // Write search index
            Index.WriteBinary(w);

            // Write identity details (last; likely to change)
            // PackageIdentity must be last so DownloadCount can be seeked to
            Identity.WriteBinary(w);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Open a project
        /// </summary>
        /// <param name="fullpath">the full path of the xml file</param>
        public void Open(string fullpath)
        {
            // set project fullpath
            FileName = Path.GetFileName(fullpath);

            // set project save path
            string path = Path.GetDirectoryName(fullpath);

            ProjectPath = path;

            // load document
            XDocument document = XDocument.Load(fullpath, LoadOptions.SetLineInfo);

            // set project name
            XAttribute name = document.Root.Attribute("name");

            if (name == null)
            {
                throw new InvalidXMLException("project root node does not contain a name attribute");
            }
            ProjectName = name.Value;

            // load filetree from the xml
            FileTree.LoadFromXML(document.Root);
            ProjectIsOpen = true;
        }
Ejemplo n.º 14
0
        private StringBuilder GenerateNavigation(FileTree fileTree, string newDirectoryPath, StringBuilder sb = null)
        {
            (sb ?? (sb = new StringBuilder())).Append("<ul>");

            if (fileTree.SubDirectories.Count > 0)              // Dive in
            {
                foreach (var subDir in fileTree.SubDirectories)
                {
                    sb.Append($"<li>{subDir.Info.Name.Replace("-", " ")}");
                    GenerateNavigation(subDir, newDirectoryPath, sb);
                    sb.Append("</li>");
                }
            }

            var order            = fileTree.Files.FirstOrDefault(f => f.Name == ".order");
            var orderedFilesList = fileTree.Files;

            if (order != null)
            {
                orderedFilesList.Remove(order);
                var orderList = File.ReadAllLines(order.FullName).ToList();
                orderedFilesList = orderedFilesList.OrderBy(f => orderList.IndexOf(f.Name.Replace(".md", ""))).ToList();
            }

            foreach (var file in orderedFilesList)
            {
                string fileRelPath = file.FullName.Replace(SourceTree.Path, "").Replace("\\", "/").Replace(".md", ".html");
                sb.Append($"<li><aa class='link' data-file-path='{fileRelPath}'>{Path.GetFileNameWithoutExtension(file.Name).Replace("-", " ")}</aa></li>");
            }

            sb.Append("</ul>");

            return(sb);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 删除操作细节
        /// </summary>
        void deleteFiles()
        {
            string fileName;
            string key;

            while (FileNames.Count > 0)
            {
                fileName = FileNames.Dequeue();
                key      = KeyNames.Dequeue();
                if (key.Contains(FileTree.FILE_IDENTIFY_NAME))
                {
                    fileName += MyConfig.EXTEND_NAME_ENCRYP_FILE;
                    label_fileStatus.Invoke(new MethodInvoker(delegate
                    {
                        label_fileStatus.Text = "正在删除: " + Path.GetFileName(fileName);
                        label_fileStatus.SetBounds(142 - (label_fileStatus.Width / 2), label_fileStatus.Location.Y, label_fileStatus.Width, label_fileStatus.Height);
                    }
                                                              ));
                    File.Delete(fileName);
                }
                else if (key.Contains(FileTree.FOLDER_IDENTIFY_NAME))
                {
                    FileTree.deleteDirectory(fileName, label_fileStatus);
                }
            }
        }
Ejemplo n.º 16
0
        internal static void ReplaceBasic()
        {
            IProject proj = ProtoTestProj;

            foreach (var doc in proj.Documents)
            {
                CommonSyntaxTree syntax = doc.GetSyntaxTree();
                FileTree = syntax;
                FileRoot = (CompilationUnitSyntax)syntax.GetRoot();

                bool containingMethodToReplace = true;
                while (containingMethodToReplace)
                {
                    containingMethodToReplace = SearchAndReplaceMethodsForTextCSharp(doc, "thisTest.Verify");
                    FileTree = SyntaxTree.Create(FileRoot);
                    FileRoot = (CompilationUnitSyntax)FileTree.GetRoot();
                }
                var UsingStmtForDict = Syntax.QualifiedName(Syntax.IdentifierName("System.Collections"),
                                                            Syntax.IdentifierName("Generic"));
                FileRoot = FileRoot.AddUsings(Syntax.UsingDirective(UsingStmtForDict).NormalizeWhitespace()).NormalizeWhitespace();

                File.WriteAllText(doc.FilePath, FileRoot.ToString());

                //Console.WriteLine(result);
            }
        }
Ejemplo n.º 17
0
        private void fighterToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FileName = rootPath = String.Empty;
            _curFile = null;
            FileTree.Nodes.Clear();
            tabControl1.TabPages.Clear();
            isRoot = true;

            FolderSelectDialog dlg = new FolderSelectDialog();

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                FileTree.BeginUpdate();
                _curFighter = _manager.OpenFighter(dlg.SelectedPath);
                TreeNode nScript = new TreeNode("AnimCmd");
                foreach (uint u in from uint u in _curFighter.MotionTable where u != 0 select u)
                {
                    nScript.Nodes.Add(new CommandListGroup(_curFighter, u)
                    {
                        ToolTipText = $"[{u:X8}]"
                    });
                }
                TreeNode nParams = new TreeNode("Params");
                TreeNode nMscsb  = new TreeNode("MSCSB");
                FileTree.Nodes.AddRange(new TreeNode[] { nScript, nParams, nMscsb });
                FileTree.EndUpdate();

                Runtime.isRoot        = true;
                Runtime.rootPath      = dlg.SelectedPath;
                Runtime.Instance.Text = String.Format("Main Form - {0}", dlg.SelectedPath);
            }
        }
Ejemplo n.º 18
0
        private void RefreshFiles()
        {
            var files = _current?.IncludedFiles;

            if (files == null)
            {
                FileTree.Items.Clear();
                return;
            }


            var          pathd = new Dictionary <string, TreeViewItem>();
            TreeViewItem root  = null;

            foreach (var file in files)
            {
                FindAndParentItem(file, pathd, out var r);
                root = r ?? root;
            }

            FileTree.ItemsSource = new List <TreeViewItem>()
            {
                root
            };
            FileTree.UpdateLayout();
        }
Ejemplo n.º 19
0
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            if (_nodeCache == null)
            {
                _nodeCache = new TreeNode[FileTree.Nodes.Count];
                FileTree.Nodes.CopyTo(_nodeCache, 0);
            }
            bool addAll = string.IsNullOrEmpty(textBox1.Text);

            FileTree.BeginUpdate();
            FileTree.Nodes.Clear();

            foreach (TreeNode root in _nodeCache)
            {
                TreeNode n = (TreeNode)root.Clone();
                n.Nodes.Clear();
                foreach (TreeNode leaf in root.Nodes)
                {
                    if (addAll || leaf.Text.Contains(textBox1.Text, StringComparison.OrdinalIgnoreCase))
                    {
                        n.Nodes.Add(leaf);
                    }
                }
                FileTree.Nodes.Add(n);
            }
            FileTree.ExpandAll();
            FileTree.EndUpdate();
        }
Ejemplo n.º 20
0
    public IObjects Get(IObjects request)
    {
        FileListRequest req = (FileListRequest)request;

        // получили запрос. там внутри есть пользователь и дерево нужно туда для него засунуть

        // вообще, для файлов установлена группа, которая может его смотреть. смотрим у пользователя какая категория есть.
        // если совпадает - можем ему показать этот файлик
        // если в директории нет файлов, которые может смотреть этот пользователь - и директорию ему не показываем


        //files = new WatchingFileRights();
        //users = new WatchingUsers();
        currentUser = request.User;

        // есть начальная директория. есть пользователь, есть набор прав для него, есть для каждого файла набор групп которым можно его читать
        FileTree answer = new FileTree();

        // сюда запишем дерево файлов
        answer.FileList = MakeTree(Treeroot);

        req.answer = answer;

        return(req);
    }
Ejemplo n.º 21
0
        private void OnLoginSucceeded(object sender, MessageEventArgs_201 message)
        {
            ConnectionManager.Messages.LoginSucceededEvent -= OnLoginSucceeded;

            OwnUserId = message.UserId;

            ConnectionManager.Commands.Who(1); //1 = Public Chat
            ConnectionManager.Commands.Ping(this);

            //Starts the heart beat pings to the server
            HeartBeat = new HeartBeatTimer(ConnectionManager);
            HeartBeat.StartTimer();

            PublicChat = new Chat(ConnectionManager.Messages, 1); // 1 = chat id for public chat
            News       = new News.News(ConnectionManager.Messages);

            FileRoot = new FileTree();
            FileRoot.Reload();

            Transfers = new Transfers.Transfers();

            if (Online != null)
            {
                Online();
            }
        }
Ejemplo n.º 22
0
        static void Main(string[] args)
        {
            var rootDir = Path.GetFullPath(RelativePath);

            Console.WriteLine(NameValueFormat, "RelativePath", RelativePath);
            Console.WriteLine(NameValueFormat, "RootDir", rootDir);

            if (!Directory.Exists(rootDir))
            {
                Console.WriteLine("Invalid path specified: {0}", rootDir);
                Console.WriteLine("Press <enter> to exit...");
                Console.ReadLine();
                return;
            }
            var tree = new FileTree(rootDir);

            Console.WriteLine();
            var writer = new StreamWriter("tree.txt", false);

            writer.Write(tree.ToString());
            writer.Write(Environment.NewLine);
            writer.Write(tree.ToXml());
            writer.Flush();
            writer.Close();
            Process.Start("tree.txt");
            Console.WriteLine();

            Console.WriteLine("Press <enter> to exit...");
            Console.ReadLine();
        }
Ejemplo n.º 23
0
        public static void FileManager(ParameterValue[] args)
        {
            if (args.Length == 1)
            {
                switch (args[0].Parameter.Names[0])
                {
                case "list":
                    if (FileTree.Current.Children == null)
                    {
                        FileTree.Current.GenerateChildren();
                    }
                    GameConsole.Log(FileTree.Current.ShortName);
                    foreach (var child in FileTree.Current.Children)
                    {
                        GameConsole.Log("-\t" + child.ShortName);
                    }
                    break;

                case "home":
                    FileTree = new FileTree(args[0].GetAsFile());
                    GameConsole.Log("Home set to " + FileTree.Root.ShortName);
                    break;

                case "reset":
                    FileTree = new FileTree();
                    GameConsole.Log("Home (re-)set to " + FileTree.Root.ShortName);
                    break;

                default:
                    throw new NotImplementedException();
                }
            }
        }
Ejemplo n.º 24
0
 public static bool FolderExists(string path)
 {
     try
     {
         if (Settings.Data[2] == "0") // game
         {
             return(FileTree.ContainsKey(path.Replace(@"\"[0], @"/"[0])));
         }
         else if (Settings.Data[2] == "1") // online
         {
             /* ??? */
         }
         else if (Settings.Data[2] == "2") // extracted
         {
             bool exists = Directory.Exists(Settings.Data[8] + @"\" + path);
             return(exists);
         }
         return(false);
     }
     catch
     {
         Debug.Log("CASC Error: Can't check if the folder exists.");
         return(false);
     }
 }
Ejemplo n.º 25
0
 /// <summary>
 /// 导入文件线程
 /// </summary>
 void threadImportItems()
 {
     try
     {
         string newFileName;
         for (int i = 0; i < ItemsPath.Length; i++)
         {
             if (File.Exists(ItemsPath[i]))
             {
                 newFileName = FileTree.importFile(ItemsPath[i],
                                                   CurrentPath + "/" + Path.GetFileName(ItemsPath[i]));
                 /* 加密 */
                 CMDComand.encryptFile(newFileName, newFileName, fileKey);
                 label_fileStatus.Invoke(new MethodInvoker(delegate
                 {
                     label_fileStatus.Text = "正在处理: " + Path.GetFileName(ItemsPath[i]);
                     label_fileStatus.SetBounds(142 - (label_fileStatus.Width / 2), label_fileStatus.Location.Y, label_fileStatus.Width, label_fileStatus.Height);
                 }
                                                           ));
             }
             else if (Directory.Exists(ItemsPath[i]))
             {
                 FileTree.importDirectory(ItemsPath[i], CurrentPath + "/" + Path.GetFileName(ItemsPath[i]), label_fileStatus, fileKey);
             }
         }
         MethodInvoker methodInvoker = new MethodInvoker(closeForm);
         BeginInvoke(methodInvoker);
     }
     catch (Exception e)
     {
         Reporter.reportBug(e.ToString());
     }
 }
Ejemplo n.º 26
0
        /// <summary>
        /// Checks if we have to recreate rootDirectory.
        /// This is needed because old versions of this storage created too
        /// much different files in the same dir, and Samsung's RFS has a bug
        /// that after the 13.000th creation fails. So if cache is not already
        /// in expected version let's destroy everything (if not in expected
        /// version... there's nothing to reuse here anyway).
        /// </summary>
        private void RecreateDirectoryIfVersionChanges()
        {
            bool recreateBase = false;

            if (!_rootDirectory.Exists)
            {
                recreateBase = true;
            }
            else if (!_versionDirectory.Exists)
            {
                recreateBase = true;
                FileTree.DeleteRecursively(_rootDirectory);
            }

            if (recreateBase)
            {
                try
                {
                    FileUtils.Mkdirs(_versionDirectory);
                }
                catch (CreateDirectoryException)
                {
                    // Not the end of the world, when saving files we will try to
                    // create missing parent dirs
                    _cacheErrorLogger.LogError(
                        CacheErrorCategory.WRITE_CREATE_DIR,
                        typeof(DefaultDiskStorage),
                        "version directory could not be created: " + _versionDirectory);
                }
            }
        }
Ejemplo n.º 27
0
        private void fileToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog dlg = new OpenFileDialog())
            {
                dlg.Filter = "ACMD Binary (*.bin)|*.bin| All Files (*.*)|*.*";
                DialogResult result = dlg.ShowDialog();
                if (result == DialogResult.OK)
                {
                    FileName = rootPath = string.Empty;
                    tabControl1.TabPages.Clear();
                    isRoot = false;

                    if ((_curFile = Manager.OpenFile(dlg.FileName)) == null)
                    {
                        return;
                    }

                    FileTree.BeginUpdate();
                    foreach (CommandList cml in _curFile.EventLists.Values)
                    {
                        FileTree.Nodes.Add(new CommandListNode($"[{cml.AnimationCRC:X8}]", cml));
                    }
                    FileTree.EndUpdate();

                    FileName = dlg.FileName;
                    Text     = $"Main Form - {FileName}";
                }
            }
        }
        /// <summary>
        /// 新規プロジェクト作成ダイアログを開く
        /// </summary>
        void RaiseNewProjectCommand()
        {
            var notification = new NewProjectNotification {
                Title = "New Project"
            };

            notification.ProjectName    = this.ProjectName.Value;
            notification.BaseFolderPath = this.BaseFolderPath.Value;
            notification.ProjectComment = this.ProjectComment.Value;
            NewProjectRequest.Raise(notification);
            if (notification.Confirmed)
            {
                this.ProjectName.Value    = notification.ProjectName;
                this.BaseFolderPath.Value = notification.BaseFolderPath;
                this.ProjectComment.Value = notification.ProjectComment;
                if (Directory.Exists(this.ProjectFolderPath.Value))
                {
                    OpenMessageBox(this.Title.Value, MessageBoxImage.Error, MessageBoxButton.OK, MessageBoxResult.OK,
                                   this.ProjectFolderPath.Value + "は既に存在しています。新しい名前を指定してください。");
                }
                else
                {
                    Directory.CreateDirectory(this.ProjectFolderPath.Value);
                    // コメントを出力
                    using (var fs = new FileStream(Path.Combine(this.ProjectFolderPath.Value, "Comment.txt"), FileMode.CreateNew)) {
                        using (var sw = new StreamWriter(fs)) {
                            sw.WriteLine(this.ProjectComment.Value);
                        }
                    }
                    FileTree.Clear();
                    FileTree.Add(new FileTreeItem(this.ProjectFolderPath.Value));
                }
            }
        }
Ejemplo n.º 29
0
        public bool Convert()
        {
            List <SyntaxError> errors = null;
            Tree tree = null;

            // Parsing order: File, Declaration, Statement, Expression
            for (int step = 0; step < 4; step++)
            {
                Scanner            scanner       = new Scanner(Source, Version);
                Parser             parser        = new Parser();
                List <SyntaxError> parsingErrors = new List <SyntaxError>();

                switch (step)
                {
                case 0:
                    tree = parser.ParseFile(scanner, parsingErrors);
                    break;

                case 1:
                    tree = parser.ParseDeclaration(scanner, parsingErrors);
                    break;

                case 2:
                    tree = parser.ParseStatement(scanner, parsingErrors);
                    break;

                case 3:
                    tree = parser.ParseExpression(scanner, parsingErrors);
                    break;
                }

                if (scanner.IsEndOfFile)
                {
                    errors = parsingErrors;
                    if (errors.Count == 0)
                    {
                        break;
                    }
                }
            }

            if (tree is FileTree)
            {
                tree = new FileTree(FileType.Module, FileName, ((FileTree)tree).Declarations, tree.Span);
            }

            string result  = string.Empty;
            bool   success = (errors.Count == 0);

            if (success)
            {
                result = OutputCode(tree);
            }

            this.Result = result;
            this.Errors = errors;

            return(success);
        }
Ejemplo n.º 30
0
        //working for relative and absolute
        public static Response RemoveFile(string path)
        {
            var response = ResponseFormation.GetResponse();

            string dirPath  = PathHelpers.GetDirFromPath(path);
            string filename = PathHelpers.GetFilenameFromPath(path);

            var directory = FileTree.GetDirectory(dirPath);

            if (directory == null)
            {
                response.Message = string.Format(ResponseMessages.DirectoryNotFound, dirPath);
            }
            else
            {
                var file = FileTree.GetFile(directory, filename);
                if (file == null)
                {
                    response.Message = string.Format(ResponseMessages.FileNotFound, filename, dirPath);
                }
                else if (file.IPAddresses.Exists(x => x.Equals(State.LocalEndPoint.ToString())) &&
                         File.Exists(Path.Combine(State.GetRootDirectory().FullName, file.ImplicitName)))
                {
                    RemoveFileFromDisk(file.ImplicitName);
                    FileTree.RemoveFile(directory, file);
                    response.IsSuccess = true;
                    response.Message   = "Succesfully Deleted";
                    FileTreeService.UpdateFileTree(FileTree.GetRootDirectory().SerializeToByteArray());

                    if (file.IPAddresses.Count > 1)
                    {
                        var remoteIps = file.IPAddresses.Where(x => !x.Equals(State.LocalEndPoint.ToString())).ToList();
                        if (remoteIps != null)
                        {
                            foreach (var ip in remoteIps)
                            {
                                var socket = ServerList.GetServerList()
                                             .FirstOrDefault(x => x.IPPort.Equals(ip)).Socket;
                                var request = new Request
                                {
                                    Type       = "FileService",
                                    Method     = "RemoveFileFromDisk",
                                    Parameters = new object[] { file.ImplicitName }
                                };
                                ServerCommunication.Send(socket, request.SerializeToByteArray());
                            }
                        }
                    }
                }
                else
                {
                    // send request to remote server
                    response.IsSuccess = true;
                    response.Message   = "Forwarded";
                    response.Command   = Command.forwarded;
                }
            }
            return(response);
        }
Ejemplo n.º 31
0
 private void Init_Tree()
 {
     tr = new FileTree();
     tr.Height = tabPage1.Height;
     tr.Width = tabPage1.Width;
     tr.Visible = true;
     tabPage1.Controls.Add(tr);
     tr.AfterSelect += new TreeViewEventHandler(tr_AfterSelect);
     //this.toolStripComboBox1.Click += new System.EventHandler(this.toolStripComboBox1_Click);
 }
Ejemplo n.º 32
0
 public RepositoryViewModel(Repository repository, FileTree fileFolder)
     : this(repository)
 {
     FileFolder = fileFolder;
 }
Ejemplo n.º 33
0
        internal void AddFileTree (DirectoryInfo info) {
            if (this.FileTree != null)
                throw new ArgumentException ();

            this.FileTree = FileTree.CreateFileTree (this, info);
        }