public FileMeta Save(string filename, string content, int offset) { if (filename == null) { throw new ArgumentNullException(nameof(filename)); } if (this.metas.ContainsKey(filename)) { throw new AlreadyExistsException("Filename already exists."); } if (content == null) { throw new ArgumentNullException(nameof(content)); } var size = content.Length; if (this.IsMemoryCollisionsExists(offset, size)) { throw new InvalidOperationException("Found possible violation of memory consistency."); } var meta = new FileMeta(filename, offset, size); this.metas.Add(meta.Filename, meta); if (!this.IsValidBounds(offset, size)) { throw new ArgumentOutOfRangeException(nameof(offset), "Found violation of storage boundaries."); } this.WriteContent(content, offset); return(meta); }
private bool Equals(FileMeta other) { return(string.Equals(this.Filename, other.Filename) && this.Offset == other.Offset && this.Size == other.Size); }