Skip to content

Commit c4f2a9b

Browse files
SND\markhor_cpSND\markhor_cp
authored andcommitted
Applied patch 14085 (14517 is a duplicate of earlier patches). Reworked the modified code. Fixed most of the hints of VS 2012. Code is successfully built.
git-svn-id: https://sevenzipsharp.svn.codeplex.com/svn@84075 9b283d60-5439-405e-af05-b73fd8c4d996
1 parent 4cdac95 commit c4f2a9b

6 files changed

Lines changed: 23 additions & 22 deletions

File tree

SevenZip/ArchiveUpdateCallback.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ public void Dispose()
780780

781781
private void IntEventArgsHandler(object sender, IntEventArgs e)
782782
{
783-
lock (this)
783+
lock (_files)
784784
{
785785
var pold = (byte) ((_bytesWrittenOld*100)/_bytesCount);
786786
_bytesWritten += e.Value;

SevenZip/LibraryManager.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ namespace SevenZip
3939
/// 7-zip library low-level wrapper.
4040
/// </summary>
4141
internal static class SevenZipLibraryManager
42-
{
42+
{
43+
/// <summary>
44+
/// Synchronization root for all locking.
45+
/// </summary>
46+
private static readonly object _syncRoot = new object();
47+
4348
#if !WINCE && !MONO
4449
/// <summary>
4550
/// Path to the 7-zip dll.
@@ -120,7 +125,7 @@ private static void Init()
120125
/// <param name="format">Archive format</param>
121126
public static void LoadLibrary(object user, Enum format)
122127
{
123-
lock (_libraryFileName)
128+
lock (_syncRoot)
124129
{
125130
if (_inArchives == null
126131
#if COMPRESS
@@ -164,7 +169,6 @@ public static void LoadLibrary(object user, Enum format)
164169
"Enum " + format + " is not a valid archive format attribute!");
165170
}
166171
}
167-
}
168172

169173
/*/// <summary>
170174
/// Gets the native 7zip library version string.
@@ -192,7 +196,7 @@ public static bool ModifyCapable
192196
{
193197
get
194198
{
195-
lock (_libraryFileName)
199+
lock (_syncRoot)
196200
{
197201
if (!_modifyCapabale.HasValue)
198202
{
@@ -256,7 +260,7 @@ public static LibraryFeature CurrentLibraryFeatures
256260
{
257261
get
258262
{
259-
lock (_libraryFileName)
263+
lock (_syncRoot)
260264
{
261265
if (_features != null && _features.HasValue)
262266
{
@@ -360,7 +364,7 @@ public static void FreeLibrary(object user, Enum format)
360364
var sp = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
361365
sp.Demand();
362366
#endif
363-
lock (_libraryFileName)
367+
lock (_syncRoot)
364368
{
365369
if (_modulePtr != IntPtr.Zero)
366370
{
@@ -434,7 +438,7 @@ public static void FreeLibrary(object user, Enum format)
434438
/// <param name="user">Archive format user.</param>
435439
public static IInArchive InArchive(InArchiveFormat format, object user)
436440
{
437-
lock (_libraryFileName)
441+
lock (_syncRoot)
438442
{
439443
if (_inArchives[user][format] == null)
440444
{
@@ -498,7 +502,7 @@ public static IInArchive InArchive(InArchiveFormat format, object user)
498502
/// <param name="user">Archive format user.</param>
499503
public static IOutArchive OutArchive(OutArchiveFormat format, object user)
500504
{
501-
lock (_libraryFileName)
505+
lock (_syncRoot)
502506
{
503507
if (_outArchives[user][format] == null)
504508
{

SevenZip/SevenZip2010.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
<WarningLevel>4</WarningLevel>
4747
<RegisterForComInterop>false</RegisterForComInterop>
4848
<DocumentationFile>bin\Debug\SevenZipSharp.xml</DocumentationFile>
49+
<RunCodeAnalysis>true</RunCodeAnalysis>
4950
</PropertyGroup>
5051
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
5152
<DebugType>pdbonly</DebugType>

SevenZip/SevenZipCompressor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@ public void CompressFilesEncrypted(
10991099
_archiveName = archiveName;
11001100
using (FileStream fs = GetArchiveFileStream(archiveName))
11011101
{
1102-
if (fs == null)
1102+
if (fs == null && _volumeSize == 0)
11031103
{
11041104
return;
11051105
}
@@ -1514,7 +1514,7 @@ public void CompressFileDictionary(
15141514
_archiveName = archiveName;
15151515
using (FileStream fs = GetArchiveFileStream(archiveName))
15161516
{
1517-
if (fs == null)
1517+
if (fs == null && _volumeSize == 0)
15181518
{
15191519
return;
15201520
}
@@ -1625,7 +1625,7 @@ public void CompressStreamDictionary(
16251625
_archiveName = archiveName;
16261626
using (FileStream fs = GetArchiveFileStream(archiveName))
16271627
{
1628-
if (fs == null)
1628+
if (fs == null && _volumeSize == 0)
16291629
{
16301630
return;
16311631
}

SevenZip/SevenZipExtractor.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,8 @@ public bool IsSolid
323323
{
324324
GetArchiveInfo(true);
325325
}
326-
if (_isSolid != null)
327-
{
328-
return _isSolid.Value;
329-
}
330-
throw new SevenZipException("_isSolid == null");
326+
Debug.Assert(_isSolid != null);
327+
return _isSolid.Value;
331328
}
332329
}
333330

@@ -344,11 +341,8 @@ public uint FilesCount
344341
{
345342
GetArchiveInfo(true);
346343
}
347-
if (_filesCount != null)
348-
{
349-
return _filesCount.Value;
350-
}
351-
throw new SevenZipException("_filesCount == null");
344+
Debug.Assert(_filesCount != null);
345+
return _filesCount.Value;
352346
}
353347
}
354348

@@ -766,6 +760,7 @@ private void CommonDispose()
766760
_archiveFileData = null;
767761
_archiveProperties = null;
768762
_archiveFileInfoCollection = null;
763+
_inStream.Dispose();
769764
_inStream = null;
770765
if (_openCallback != null)
771766
{

SevenZip/sdk/ICoder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public DataErrorException() : base("Data Error") {}
3131
/// <summary>
3232
/// The exception that is thrown when the value of an argument is outside the allowable range.
3333
/// </summary>
34+
[Serializable]
3435
internal class InvalidParamException : ApplicationException
3536
{
3637
public InvalidParamException() : base("Invalid Parameter") {}

0 commit comments

Comments
 (0)