Esempio n. 1
0
        public IFile GetFile(string name, ActionIfMissing actionIfMissing)
        {
            var file = this.files.GetValueOrDefault(name);
            if (actionIfMissing != ActionIfMissing.ReturnNull)
                file = file ?? new MemoryFile(this, name, false);

            return file;
        }
Esempio n. 2
0
        public ILocation GetLocation(string path, ActionIfMissing actionIfMissing = ActionIfMissing.ThrowException)
        {
            if (!Directory.Exists(path) && actionIfMissing != ActionIfMissing.ReturnAsIs) {
                if (actionIfMissing == ActionIfMissing.CreateNew) {
                    Directory.CreateDirectory(path);
                }
                else if (actionIfMissing == ActionIfMissing.ReturnNull) {
                    return null;
                }
                else if (actionIfMissing == ActionIfMissing.ThrowException) {
                    throw new FileNotFoundException("Location was not found.", path);
                }
            }

            return new Location(path);
        }
Esempio n. 3
0
        public IFile GetFile(string name, ActionIfMissing actionIfMissing = ActionIfMissing.ReturnNull)
        {
            var path = System.IO.Path.Combine(this.Path, name);
            if (!System.IO.File.Exists(path) && actionIfMissing != ActionIfMissing.ReturnAsIs) {
                if (actionIfMissing == ActionIfMissing.CreateNew) {
                    System.IO.File.Create(path).Close();
                }
                else if (actionIfMissing == ActionIfMissing.ReturnNull) {
                    return null;
                }
                else if (actionIfMissing == ActionIfMissing.ThrowException) {
                    throw new FileNotFoundException("File was not found.", path);
                }
            }

            return new File(path, this);
        }
Esempio n. 4
0
 public ILocation GetLocation(string path, ActionIfMissing actionIfMissing)
 {
     return new MemoryLocation { Path = path };
 }
Esempio n. 5
0
 public IFile GetFile(string path, ActionIfMissing actionIfMissing)
 {
     throw new NotImplementedException();
 }
Esempio n. 6
0
 public IFile GetFile(string path, ActionIfMissing actionIfMissing = ActionIfMissing.ReturnNull)
 {
     return this.GetLocation(Path.GetDirectoryName(path))
                .GetFile(Path.GetFileName(path), actionIfMissing);
 }
Esempio n. 7
0
 public ILocation GetLocation(string name, ActionIfMissing actionIfMissing = ActionIfMissing.ReturnNull)
 {
     var path = System.IO.Path.Combine(this.Path, name);
     return new FileSystem().GetLocation(path, actionIfMissing);
 }
Esempio n. 8
0
 public ILocation GetLocation(string path, ActionIfMissing actionIfMissing = ActionIfMissing.ReturnNull)
 {
     return new MemoryLocation { Path = this.Path + "/" + path };
 }