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); } } }
public StdFSFile(string fullPath, string name, StdFSDir parent) { _name = name; _parent = parent; _path = fullPath; _readStreams = new List <Stream>(); //_writeStream = new Stream(); }
public StdFSDir(string fullPath, string name, StdFSDir parent) { _name = name; _dirs = new List <Dir422>(); _files = new List <File422>(); _parent = parent; _path = fullPath; }
// 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); }
public static StandardFileSystem Create(string rootDir) { if (!Directory.Exists(rootDir)) { return(null); } var root = new StdFSDir(rootDir, null); return(new StandardFileSystem(root)); }
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); } }
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); }
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); }
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); }
public void SParseDir() { StdFSDir sfd = new StdFSDir(dirName); StringAssert.AreEqualIgnoringCase("Debug", sfd.Name); }
public void SDirName() { StdFSDir d = new StdFSDir(dirName); StringAssert.AreEqualIgnoringCase("Debug", d.Name); }
public StdFSFile(string path, StdFSDir parent) { m_path = path; _parent = parent; _name = path.Split('/', '\\').Last(); }
public StandardFileSystem(StdFSDir root) { _root = root; }
StandardFileSystem(string rootDir) { root = new StdFSDir(rootDir, rootDir); }
private StandardFileSystem(string rootDir) { m_root = new StdFSDir(rootDir, rootDir); }
private StandardFileSystem(StdFSDir root) { m_root = root; }