[ZipFile, ZipFileEntry] Add regions for sanity

This commit is contained in:
Matt Nadareski
2016-09-16 21:05:23 -07:00
parent 87488bea14
commit ba5151c6d8
2 changed files with 45 additions and 9 deletions

View File

@@ -111,6 +111,8 @@ namespace SabreTools.Helper
#endregion #endregion
#region Central Directory
/// <summary> /// <summary>
/// Find the end of the central directory signature /// Find the end of the central directory signature
/// </summary> /// </summary>
@@ -227,6 +229,10 @@ namespace SabreTools.Helper
bw.Write(_fileComment, 0, _fileComment.Length); bw.Write(_fileComment, 0, _fileComment.Length);
} }
#endregion
#region Zip64 Central Directory
/// <summary> /// <summary>
/// Read the end of the Zip64 central directory /// Read the end of the Zip64 central directory
/// </summary> /// </summary>
@@ -361,6 +367,10 @@ namespace SabreTools.Helper
bw.Write((uint)1); // total number of disks bw.Write((uint)1); // total number of disks
} }
#endregion
#region Open, Create, Close
/// <summary> /// <summary>
/// Open a new file as an archive /// Open a new file as an archive
/// </summary> /// </summary>
@@ -737,6 +747,10 @@ namespace SabreTools.Helper
_zipOpen = ZipOpenType.Closed; _zipOpen = ZipOpenType.Closed;
} }
#endregion
#region Read and Write
/// <summary> /// <summary>
/// Open the read file stream /// Open the read file stream
/// </summary> /// </summary>
@@ -885,6 +899,10 @@ namespace SabreTools.Helper
_entries[_entries.Count - 1].AddDirectory(); _entries[_entries.Count - 1].AddDirectory();
} }
#endregion
#region Helpers
/// <summary> /// <summary>
/// Scan every individual entry for validity /// Scan every individual entry for validity
/// </summary> /// </summary>
@@ -994,5 +1012,7 @@ namespace SabreTools.Helper
} }
} }
} }
#endregion
} }
} }

View File

@@ -155,15 +155,7 @@ namespace SabreTools.Helper
#endregion #endregion
/// <summary> #region Central Directory
/// Check if an entry equals another (use only name for now)
/// </summary>
/// <param name="zfe"></param>
/// <returns></returns>
public bool Equals(ZipFileEntry zfe)
{
return (String.Equals(_fileName, zfe.FileName, StringComparison.InvariantCultureIgnoreCase));
}
/// <summary> /// <summary>
/// Read the central directory entry from the input stream /// Read the central directory entry from the input stream
@@ -387,6 +379,10 @@ namespace SabreTools.Helper
// We have no file comment, so we don't have to write more // We have no file comment, so we don't have to write more
} }
#endregion
#region Header
/// <summary> /// <summary>
/// Read the local file header from the input stream /// Read the local file header from the input stream
/// </summary> /// </summary>
@@ -778,6 +774,10 @@ namespace SabreTools.Helper
bw.Write(extraField.ToArray(), 0, extraFieldLength); bw.Write(extraField.ToArray(), 0, extraFieldLength);
} }
#endregion
#region Read and Write
/// <summary> /// <summary>
/// Open the read file stream /// Open the read file stream
/// </summary> /// </summary>
@@ -946,6 +946,10 @@ namespace SabreTools.Helper
_zipstream.Seek(posNow, SeekOrigin.Begin); _zipstream.Seek(posNow, SeekOrigin.Begin);
} }
#endregion
#region Helpers
/// <summary> /// <summary>
/// Get the data from the current file, if not already checked /// Get the data from the current file, if not already checked
/// </summary> /// </summary>
@@ -1027,5 +1031,17 @@ namespace SabreTools.Helper
ds.WriteByte(03); ds.WriteByte(03);
ds.WriteByte(00); ds.WriteByte(00);
} }
/// <summary>
/// Check if an entry equals another (use only name for now)
/// </summary>
/// <param name="zfe"></param>
/// <returns></returns>
public bool Equals(ZipFileEntry zfe)
{
return (String.Equals(_fileName, zfe.FileName, StringComparison.InvariantCultureIgnoreCase));
}
#endregion
} }
} }