Hello,
I'm trying to manage the file tree outside of sharpcompress.
I found method AddEntry will return nothing so I had to enumerate Entries each time after I add a file.
Then I make a patch
I'm trying to manage the file tree outside of sharpcompress.
I found method AddEntry will return nothing so I had to enumerate Entries each time after I add a file.
Then I make a patch
diff --git a/SharpCompress/Archive/AbstractWritableArchive.cs b/SharpCompress/Archive/AbstractWritableArchive.cs
index c03f549..8e3b276 100644
--- a/SharpCompress/Archive/AbstractWritableArchive.cs
+++ b/SharpCompress/Archive/AbstractWritableArchive.cs
@@ -67,28 +67,32 @@ namespace SharpCompress.Archive
}
}
- public void AddEntry(string filePath, Stream source,
+ public TEntry AddEntry(string filePath, Stream source,
long size = 0, DateTime? modified = null)
{
- newEntries.Add(CreateEntry(filePath, source, size, modified, false));
+ var entry = CreateEntry(filePath, source, size, modified, false);
+ newEntries.Add(entry);
RebuildModifiedCollection();
+ return entry;
}
- public void AddEntry(string filePath, Stream source, bool closeStream,
+ public TEntry AddEntry(string filePath, Stream source, bool closeStream,
long size = 0, DateTime? modified = null)
{
- newEntries.Add(CreateEntry(filePath, source, size, modified, closeStream));
+ var entry = CreateEntry(filePath, source, size, modified, closeStream);
+ newEntries.Add(entry);
RebuildModifiedCollection();
+ return entry;
}
#if !PORTABLE && !NETFX_CORE
- public void AddEntry(string filePath, FileInfo fileInfo)
+ public TEntry AddEntry(string filePath, FileInfo fileInfo)
{
if (!fileInfo.Exists)
{
throw new ArgumentException("FileInfo does not exist.");
}
- AddEntry(filePath, fileInfo.OpenRead(), true, fileInfo.Length, fileInfo.LastWriteTime);
+ return AddEntry(filePath, fileInfo.OpenRead(), true, fileInfo.Length, fileInfo.LastWriteTime);
}
#endif
If you think it's reasonable please merge it, thank you for the work.