public bool CreateFile(string name) { if (string.IsNullOrWhiteSpace(name)) { return(false); } var uniqueName = name; int i = 1; // If file name already exists, append a (1), (2), etc.. while (ObjectSystemsDict.ContainsKey(uniqueName)) { var dotIndex = name.LastIndexOf('.') - 1; if (dotIndex < 0) { return(false); } uniqueName = name.Insert(dotIndex, $" ({i})"); i++; } var file = new File(uniqueName, GetFullPath(uniqueName), this); return(AddObjectSystem(file)); }
public bool DeleteObject(ObjectSystem objectSystem) { if (!ObjectSystemsDict.ContainsKey(objectSystem.Name)) { return(false); } return(ObjectSystemsDict.Remove(objectSystem.Name) && ObjectSystems.Remove(objectSystem)); }
private bool AddObjectSystem(ObjectSystem objectSystem) { if (ObjectSystemsDict.ContainsKey(objectSystem.Name)) { return(false); } ObjectSystemsDict.Add(objectSystem.Name, objectSystem); ObjectSystems.Add(objectSystem); return(true); }
public bool CreateDirectory(string name) { if (string.IsNullOrWhiteSpace(name)) { return(false); } var uniqueName = name; int i = 1; // If file name already exists, append a (1), (2), etc.. while (ObjectSystemsDict.ContainsKey(uniqueName)) { uniqueName = name.Insert(name.Length - 1, $" ({i})"); i++; } var directory = new Directory(uniqueName, GetFullPath(uniqueName), this); return(AddObjectSystem(directory)); }