示例#1
0
        public override bool ContainsDir(string dirName, bool recursive)
        {
            bool containsDir = false;

            if (!StdFSHelper.ContainsPathCharacters(dirName))
            {
                if (recursive)
                {
                    containsDir = ContainsDirRecursive(dirName);
                }
                else
                {
                    foreach (Dir422 childDir in _childDirs)
                    {
                        if (childDir.Name == dirName)
                        {
                            containsDir = true;
                            break;
                        }
                    }
                }
            }

            return(containsDir);
        }
示例#2
0
        public override File422 CreateFile(string fileName)
        {
            File422 memFile = null;

            if (!StdFSHelper.ContainsPathCharacters(fileName) ||
                string.IsNullOrEmpty(fileName))
            {
                //check if exists already
                if ((memFile = GetFile(fileName)) != null)
                {
                    using (Stream s = memFile.OpenReadWrite())
                    {
                        if (s != null)
                        {
                            //this 0's out the memory stream.
                            s.SetLength(0);
                        }
                    }
                }
                else
                {
                    memFile = new MemFSFile(fileName, this);
                    _childFiles.Add(memFile);
                }
            }

            return(memFile);
        }
示例#3
0
        //parent cannot be null
        public StdFSFile(string path, Dir422 parent)
        {
            _path   = path;
            _parent = parent;

            _name = StdFSHelper.getBaseFromPath(path);
        }
示例#4
0
        public override bool ContainsFile(string fileName, bool recursive)
        {
            bool containsFile = false;

            //return false immedietly if it contains those characters
            if (!StdFSHelper.ContainsPathCharacters(fileName))
            {
                if (recursive)
                {
                    containsFile = ContainsFileRecursive(fileName);
                }
                else
                {
                    foreach (File422 childFile in _childFiles)
                    {
                        if (childFile.Name == fileName)
                        {
                            containsFile = true;
                            break;
                        }
                    }
                }
            }

            return(containsFile);
        }
示例#5
0
        public override File422 CreateFile(string fileName)
        {
            File422 stdFile = null;

            //if at root of filesystem, gets rid of extra '/'
            string path = (_path == "/") ? "" : _path;

            if (!StdFSHelper.ContainsPathCharacters(fileName) ||
                string.IsNullOrEmpty(fileName))
            {
                //if we are at /a/b/, makes /a/b/c.txt
                //where c.txt is fileName
                path = path + "/" + fileName;

                //if already exists clear existing data.
                if (File.Exists(path))
                {
                    File.WriteAllText(path, "");
                }

                //if exists and not read-only contents are overwritten
                using (FileStream fs = File.Create(path))
                {
                    //set length to 0.
                    fs.SetLength(0);

                    //this is the parent
                    stdFile = new StdFSFile(path, this);
                }
            }

            return(stdFile);
        }
示例#6
0
        public override bool ContainsDir(string dirName, bool recursive)
        {
            bool containsDir = false;

            if (!StdFSHelper.ContainsPathCharacters(dirName))
            {
                if (recursive)
                {
                    containsDir = ContainsDirRecursive(dirName);
                }
                else
                {
                    //name is in format /a/b/c/d where d is base of the path
                    IList <Dir422> dirs = GetDirs();

                    foreach (Dir422 dir in dirs)
                    {
                        if (dir.Name == dirName)
                        {
                            containsDir = true;
                            break;
                        }
                    }
                }
            }

            return(containsDir);
        }
示例#7
0
        public override bool ContainsFile(string fileName, bool recursive)
        {
            bool containsFile = false;

            //return false immedietly if it contains those characters
            if (!StdFSHelper.ContainsPathCharacters(fileName))
            {
                if (recursive)
                {
                    containsFile = ContainsFileRecursive(fileName);
                }
                else
                {
                    //name is in format /a/b/c/d where d is base of the path
                    IList <File422> files = GetFiles();

                    foreach (File422 file in files)
                    {
                        //so this gets 'd'
                        if (file.Name == fileName)
                        {
                            containsFile = true;
                            break;
                        }
                    }
                }
            }

            return(containsFile);
        }
示例#8
0
        public StdFSDir(string path, Dir422 parent = null)
        {
            _path   = path;
            _parent = parent;

            if (parent != null)
            {
                _name = StdFSHelper.getBaseFromPath(path);
            }
            else
            {
                _name = path;
            }
        }
示例#9
0
        public override Dir422 CreateDir(string fileName)
        {
            Dir422 memDir = null;

            if (!StdFSHelper.ContainsPathCharacters(fileName) ||
                string.IsNullOrEmpty(fileName))
            {
                //check if already exists
                if ((memDir = GetDir(fileName)) == null)
                {
                    memDir = new MemFSDir(fileName, this);
                    _childDirs.Add(memDir);
                }
            }

            return(memDir);
        }
示例#10
0
        public override File422 GetFile(string fileName)
        {
            File422 file = null;

            if (!StdFSHelper.ContainsPathCharacters(fileName))
            {
                foreach (File422 childFile in _childFiles)
                {
                    if (childFile.Name == fileName)
                    {
                        file = childFile;
                        break;
                    }
                }
            }

            return(file);
        }
示例#11
0
        public override Dir422 GetDir(string dirName)
        {
            Dir422 dir = null;

            if (!StdFSHelper.ContainsPathCharacters(dirName))
            {
                foreach (Dir422 childDir in _childDirs)
                {
                    if (childDir.Name == dirName)
                    {
                        dir = childDir;
                        break;
                    }
                }
            }

            return(dir);
        }
示例#12
0
        public override File422 GetFile(string fileName)
        {
            File422         stdFile = null;
            IList <File422> files   = GetFiles();

            if (files.Count != 0 && !StdFSHelper.ContainsPathCharacters(fileName))
            {
                foreach (File422 file in files)
                {
                    if (file.Name == fileName)
                    {
                        stdFile = file;
                        break;
                    }
                }
            }

            return(stdFile);
        }
示例#13
0
        public override Dir422 GetDir(string dirName)
        {
            Dir422         stdDir = null;
            IList <Dir422> dirs   = GetDirs();

            if (dirs.Count != 0 && !StdFSHelper.ContainsPathCharacters(dirName))
            {
                foreach (Dir422 dir in dirs)
                {
                    if (dir.Name == dirName)
                    {
                        stdDir = dir;
                        break;
                    }
                }
            }

            return(stdDir);
        }
示例#14
0
        public override Dir422 CreateDir(string fileName)
        {
            Dir422 stdDir = null;

            //if at root of filesystem, gets rid of extra '/'
            string path = (_path == "/") ? "" : _path;

            if (!StdFSHelper.ContainsPathCharacters(fileName) ||
                string.IsNullOrEmpty(fileName))
            {
                //if we are at /a/b/, makes /a/b/c
                //where c is fileName
                path = path + "/" + fileName;

                Directory.CreateDirectory(path);

                //this is the parent
                stdDir = new StdFSDir(path, this);
            }

            return(stdDir);
        }