当前位置: 首页>>代码示例>>C#>>正文


C# FileNode.addParent方法代码示例

本文整理汇总了C#中FileNode.addParent方法的典型用法代码示例。如果您正苦于以下问题:C# FileNode.addParent方法的具体用法?C# FileNode.addParent怎么用?C# FileNode.addParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileNode的用法示例。


在下文中一共展示了FileNode.addParent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: write

    public virtual int write(string path, int flags, string buffer, int offset, int length)
    {
        string workPath = "/";
        FileNode aNode;
        string[] pathArray = path.Split('/');
        int counter = 0;
        string loadPath = "";
        FileNode newDir;
        FileNode newfile;

        while (counter <= pathArray.Length - 2)
        {
            if (workPath == "/")
                workPath = workPath + pathArray[counter];
            else
                workPath = workPath + '/' + pathArray[counter];
            counter++;
        }

        if (flags == writeFlags.DELETE)
        {
            //unlink a node
            counter = 0;
            aNode = this.walk(path);

            if (aNode.getType() == fileTypes.Mount)
            {
                loadPath = this.parsePath(aNode, path);
                return (aNode.getMount().write(loadPath, flags, buffer, offset, length));
            }
            if (aNode.getType() == fileTypes.Symlink)
            {
                string[] fileStruct = path.Split('/');
                string remPath = aNode.getName() + "/" + fileStruct[fileStruct.Length - 1];
                return (this.write(remPath, flags, buffer, offset, length));
            }
            if (aNode.getType() == fileTypes.Union)
            {
                string[] fileStruct = path.Split('/');
                counter = 0;

                while (counter < aNode.getDirList().Count)
                {
                    string remPath = aNode.getDirList()[counter] + "/" + fileStruct[fileStruct.Length - 1];
                    this.write(remPath, flags, buffer, offset, length);
                    counter++;
                }
                return 0;
            }
            FileNode prevNode = aNode.getPrev();
            FileNode nextNode = aNode.getNext();

            while (aNode.getParent().getDirList()[counter].getName() != aNode.getName() && counter < aNode.getParent().getDirList().Count)
            {
                counter++;
            }

            prevNode.setNext(nextNode);
            nextNode.setPrev(prevNode);
            return 0;
        }

        if (flags == writeFlags.CREATEDIR)
        {
            aNode = this.walk(workPath);

            if (aNode.getType() == 1 && buffer == "1")
            {
                newDir =  new FileNode(pathArray[pathArray.Length - 1], fileTypes.Directory);
                newDir.addParent(aNode);
                aNode.addChild(newDir);

                if (aNode.countChildren() > 0)
                {
                    newDir.setPrev(aNode.getDirList().ElementAt(aNode.countChildren()-1));
                }

                if (aNode.countChildren() >= 2)
                {
                    aNode.getDirList()[aNode.countChildren() - 2].setNext(newDir);
                }

                this.touched(aNode);
                return 0;
            }
            else if (aNode.getType() == fileTypes.Symlink)
            {
                return (this.write(aNode.getSym() + "/" + pathArray[pathArray.Length - 1], flags, buffer, offset, length));
            }

            else if (aNode.getType() == fileTypes.Mount)
            {
                loadPath = this.parsePath(aNode, path);
                return (aNode.getMount().write(loadPath, flags, buffer, offset, length));
            }
            else if (aNode.getType() == fileTypes.Union)
            {
                loadPath = this.parsePath(aNode, path);
                int count = 0;
                while (count < aNode.getDirList().Count)
//.........这里部分代码省略.........
开发者ID:Softsurve,项目名称:Silver-Iodide,代码行数:101,代码来源:agi.cs

示例2: mount

    public fileSystem mount(int mode, string fsTypeName, string mountPoint, string[] args)
    {
        string workPath = "/";
        FileNode aNode;
        string[] pathArray = mountPoint.Split('/');
        int counter = 0;
        fileSystem toMount = null;
        /*
        if (fsTypeName == "localfs")
            toMount = new LocalFS();
        if (fsTypeName == "timefs")
            toMount = new ClockFS();
        if (fsTypeName == "winfs")
            toMount = new WinFS();
        if (fsTypeName == "sysfs")
            toMount = new SysFS(args[0]);
        if (fsTypeName == "homefs")
            toMount = new HomeFS();
        if (fsTypeName == "procfs")
            toMount = new ProcFS();
        if (fsTypeName == "xmppfs")
            toMount = new XMPPFS();
        */
        while (counter <= pathArray.Length - 2)
        {
            if (workPath == "/")
                workPath = workPath + pathArray[counter];
            else
                workPath = workPath + '/' + pathArray[counter];
            counter++;
        }

        aNode = this.walk(workPath);
        //parse list of available filesystems for the one we've been asked to mount
        //while (counter < vfsList.length && vfsList[counter].Name != fs_type)
        //{
        //    counter++;
        //}

        if (aNode.getType() == 1)//&& vfsList[counter].Name == fs_type)
        {
            var count = 0;
            if (aNode.getDirList().Count > 0)
            {
                while (count < aNode.getData().Length - 1 && aNode.getDirList()[count].getName() != pathArray[pathArray.Length - 1])
                {
                    count++;
                }
                aNode.getDirList();
            }

            FileNode newFile = new FileNode(pathArray[pathArray.Length - 1], fileTypes.Mount);

            newFile.addParent(aNode);
            aNode.addChild(newFile);

            if (aNode.countChildren() > 0)
            {
                newFile.setPrev(aNode.getDirList().ElementAt(aNode.countChildren() - 1));
            }

            if (aNode.countChildren() >= 2)
            {
                aNode.getDirList()[aNode.countChildren() - 2].setNext(newFile);
            }

            this.touched(aNode);
            newFile.setMount(toMount);
            return toMount.onmount(mountPoint);// serverAddress, fs_type, mountPoint, user, pass, argv));
           }
           else
            return null;
    }
开发者ID:Softsurve,项目名称:Silver-Iodide,代码行数:73,代码来源:agi.cs


注:本文中的FileNode.addParent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。