public override Stream GetOutputStream(string name, out IContentEntry entry) { ThrowIfObjectDisposed(); ThrowIfObjectNotUpdating(); name = NormalizePath(name); IContentEntry oldEntry; if (entries.TryGetValue(name, out oldEntry)) { if (oldEntry is IDisposable) { (oldEntry as IDisposable).Dispose(); } var source = new MemoryStream(); var updateEntry = new UpdateEntry(name, source, DateTime.Now, true, EntryOperation.AddOrUpdate); entries[name] = updateEntry; entry = updateEntry; return(updateEntry.Source.GetOutputStream()); } else { var source = new MemoryStream(); var updateEntry = new UpdateEntry(name, source, DateTime.Now, true, EntryOperation.AddOrUpdate); entry = updateEntry; entries.Add(name, updateEntry); return(updateEntry.Source.GetOutputStream()); } }
public override Stream GetOutputStream(string name, out IContentEntry entry) { ThrowIfObjectDisposed(); ThrowIfObjectNotUpdating(); MemoryEntry oldEntry; if (entries.TryGetValue(name, out oldEntry)) { oldEntry.Dispose(); var source = new MemoryStream(); var memoryEntry = new MemoryEntry(name, source, DateTime.Now, true); entries[name] = memoryEntry; entry = memoryEntry; return memoryEntry.Source.GetOutputStream(); } else { var source = new MemoryStream(); var memoryEntry = new MemoryEntry(name, source, DateTime.Now, true); entry = memoryEntry; entries.Add(name, memoryEntry); return memoryEntry.Source.GetOutputStream(); } }
/// <summary> /// 获取到输出流,不管是否已经存在,都返回一个空的用于写的流,该方法可能使用 MemoryStream 作为缓存,在 CommitUpdate() 之后才进行变换;在使用该方法之前需要调用 BeginUpdate();(推荐在using语法内使用) /// </summary> /// <exception cref="ObjectDisposedException"></exception> /// <exception cref="InvalidOperationException"></exception> /// <exception cref="IOException">文件被占用</exception> public virtual Stream GetOutputStream(IContentEntry entry) { if (entry == null) { throw new ArgumentNullException(nameof(entry)); } return(GetOutputStream(entry.Name)); }
/// <summary> /// 移除指定资源;在使用该方法之前需要调用 BeginUpdate(); /// </summary> /// <exception cref="ObjectDisposedException"></exception> /// <exception cref="InvalidOperationException"></exception> /// <exception cref="IOException">文件被占用</exception> public virtual bool Remove(IContentEntry entry) { if (entry == null) { throw new ArgumentNullException(nameof(entry)); } return(Remove(entry.Name)); }
public override Stream GetOutputStream(string name, out IContentEntry entry) { ThrowIfObjectDisposed(); ThrowIfObjectNotUpdating(); string filePath = Path.Combine(DirectoryPath, name); string directory = Path.GetDirectoryName(filePath); Directory.CreateDirectory(directory); entry = CreateEntry(filePath, name); return(new FileStream(filePath, FileMode.Create, FileAccess.ReadWrite, FileShare.None)); }
public override Stream GetInputStream(IContentEntry entry) { if (entry is Entry) { var zipEntry = (Entry)entry; return(zipEntry.ZipArchiveEntry.OpenEntryStream()); } else { return(GetInputStream(entry.Name)); } }
internal ZipArchiveEntry InternalGetEntry(IContentEntry contentEntry) { if (contentEntry is Entry) { var zipEntry = (Entry)contentEntry; return(zipEntry.ZipArchiveEntry); } else { return(InternalGetEntry(contentEntry.Name)); } }
public override Stream GetInputStream(IContentEntry entry) { ThrowIfObjectDisposed(); var directoryContentEntry = (DirectoryContentEntry)entry; if (File.Exists(directoryContentEntry.FilePath)) { return(new FileStream(directoryContentEntry.FilePath, FileMode.Open, FileAccess.Read, FileShare.Read)); } else { throw new FileNotFoundException(); } }
public override Stream GetInputStream(IContentEntry entry) { if (entry == null) { throw new ArgumentNullException(nameof(entry)); } ThrowIfObjectDisposed(); Entry zipContentEntry = entry as Entry; if (zipContentEntry != null) { return(GetInputStream(zipContentEntry.ZipEntry)); } else { return(GetInputStream(entry.Name)); } }
public override Stream GetOutputStream(string name, out IContentEntry entry) { throw new NotImplementedException(); }
public override Stream GetOutputStream(IContentEntry entry) { return(base.GetOutputStream(entry)); }
/// <summary> /// 获取到输出流,不管是否已经存在,都返回一个空的用于写的流,该方法可能使用 MemoryStream 作为缓存,在 CommitUpdate() 之后才进行变换;在使用该方法之前需要调用 BeginUpdate();(推荐在using语法内使用) /// </summary> /// <exception cref="ObjectDisposedException"></exception> /// <exception cref="InvalidOperationException"></exception> /// <exception cref="IOException">文件被占用</exception> public abstract Stream GetOutputStream(string name, out IContentEntry entry);