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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }