Esempio n. 1
0
        public override Dir422 CreateDir(string name)
        {
            //Check for any invalid characters in the file name ('/','\')
            //If filename has these characters, is null, or empty then return null
            //If a directory with the same name already exists, just return that directory.
            //If it does not exist, create it and return it.
            if (name.Contains("/") || name.Contains("\\"))
            {
                return(null);
            }

            if (ContainsDir(name, false))
            {
                return(GetDir(name));
            }
            else
            {
                try
                {
                    //Directory.CreateDirectory(m_path + "/" + name); //Linux
                    Directory.CreateDirectory(m_path + "\\" + name);           //Windows
                    StdFSDir newDir = new StdFSDir(m_path + "/" + name, this); //Windows
                    //StdFSDir newDir = new StdFSDir(m_path + "/" + name, this); //Linux
                    return(newDir);
                }
                catch { return(null); }
            }
        }
Esempio n. 2
0
 public StdFSFile(string fullPath, string name, StdFSDir parent)
 {
     _name        = name;
     _parent      = parent;
     _path        = fullPath;
     _readStreams = new List <Stream>();
     //_writeStream = new Stream();
 }
Esempio n. 3
0
 public StdFSDir(string fullPath, string name, StdFSDir parent)
 {
     _name   = name;
     _dirs   = new List <Dir422>();
     _files  = new  List <File422>();
     _parent = parent;
     _path   = fullPath;
 }
Esempio n. 4
0
        // Methods
        public static StandardFileSystem Create(string rootDir)
        {
            // create rootDir
            DirectoryInfo dir  = Directory.CreateDirectory(rootDir);
            string        cwd  = Directory.GetCurrentDirectory();
            StdFSDir      root = new StdFSDir(cwd + "/" + rootDir, rootDir, null);

            StandardFileSystem fileSystem = new StandardFileSystem(root);

            return(fileSystem);
        }
Esempio n. 5
0
        public static StandardFileSystem Create(string rootDir)
        {
            if (!Directory.Exists(rootDir))
            {
                return(null);
            }

            var root = new StdFSDir(rootDir, null);

            return(new StandardFileSystem(root));
        }
Esempio n. 6
0
        public override Dir422 GetDir(string name)
        {
            //Non recursive Search
            //Return null if name contains path characters (/\)
            //Return null if no directory with the given name is found.
            //Returns non-null Dir422 object if found
            if (name.Contains("/") || name.Contains("\\"))
            {
                return(null);
            }

            if (ContainsDir(name, false))
            {
                StdFSDir d = new StdFSDir(m_path + "\\" + name, this);
                return(d);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 7
0
        public override Dir422 CreateDir(string name)
        {
            StdFSDir newDir = new StdFSDir();

            // validate the name
            if (IsValidName(name))
            {
                // Create dir in actual fileSystem if not there
                Console.WriteLine("path: " + _path);
                Console.WriteLine("cwd = " + Directory.GetCurrentDirectory());
                Directory.CreateDirectory(_path + "/" + name);
                // Create a new stdDir ref
                newDir = new StdFSDir(_path + "/" + name, name, this);
                // Add that to the list of sub dirs for this dir
                _dirs.Add(newDir);
                return(newDir);
            }

            Console.WriteLine("CreateDir(): Invalid Name");
            return(null);
        }
Esempio n. 8
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);
        }
Esempio n. 9
0
        public override Dir422 GetDir(string name)
        {
            Console.WriteLine("GetDir()");
            // Console.WriteLine("cwd: " + _path);
            // Console.WriteLine("name: " + name);
            string dirPath = _path + "/" + name;

            //Console.WriteLine("Looking for " + dirPath);

            if (IsValidName(name))
            {
                if (Directory.Exists(dirPath))
                {
                    // Return dir
                    StdFSDir dir = new StdFSDir(dirPath, name, this);
                    return(dir);
                }
                Console.WriteLine("could not find dir with name: " + name);
                Console.WriteLine("Searched for: " + dirPath);
            }
            return(null);
        }
Esempio n. 10
0
        public void SParseDir()
        {
            StdFSDir sfd = new StdFSDir(dirName);

            StringAssert.AreEqualIgnoringCase("Debug", sfd.Name);
        }
Esempio n. 11
0
        public void SDirName()
        {
            StdFSDir d = new StdFSDir(dirName);

            StringAssert.AreEqualIgnoringCase("Debug", d.Name);
        }
Esempio n. 12
0
 public StdFSFile(string path, StdFSDir parent)
 {
     m_path  = path;
     _parent = parent;
     _name   = path.Split('/', '\\').Last();
 }
Esempio n. 13
0
 public StandardFileSystem(StdFSDir root)
 {
     _root = root;
 }
Esempio n. 14
0
 StandardFileSystem(string rootDir)
 {
     root = new StdFSDir(rootDir, rootDir);
 }
Esempio n. 15
0
 private StandardFileSystem(string rootDir)
 {
     m_root = new StdFSDir(rootDir, rootDir);
 }
Esempio n. 16
0
 private StandardFileSystem(StdFSDir root)
 {
     m_root = root;
 }