Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1579,7 +1579,7 @@ private void AddUpdate(ZipUpdate update)
{
contentsEdited_ = true;

int index = FindExistingUpdate(update.Entry.Name);
int index = FindExistingUpdate(update.Entry);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is FindExistingUpdate changed here?

The FindExistingUpdate(ZipEntry) method should probably just call FindExistingUpdate(string) for DRYness, but that's for another issue...


if (index >= 0)
{
Expand Down Expand Up @@ -2489,7 +2489,9 @@ private int FindExistingUpdate(string fileName)
{
int result = -1;

string convertedName = GetTransformedFileName(fileName);
string convertedName = IsDirectoryName(fileName)
? GetTransformedDirectoryName(fileName)
: GetTransformedFileName(fileName);

if (updateIndex_.ContainsKey(convertedName))
{
Expand All @@ -2511,6 +2513,15 @@ private int FindExistingUpdate(string fileName)
return result;
}

private bool IsDirectoryName(string name)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetTransformedFileName is only referenced in FindExistingUpdate, perhaps GetTransformedFileName, GetTransformedDirectoryName and IsDirectoryName should be reduced to a single function called GetTransformedEntryName? The two former ones are almost identical.

{
int nameLength = name.Length;
bool result =
((nameLength > 0) &&
((name[nameLength - 1] == '/') || (name[nameLength - 1] == '\\')));
return result;
}

/// <summary>
/// Get an output stream for the specified <see cref="ZipEntry"/>
/// </summary>
Expand Down