@@ -10,6 +10,30 @@ namespace ICSharpCode.SharpZipLib.Zip
1010 /// </summary>
1111 public class WindowsNameTransform : INameTransform
1212 {
13+ /// <summary>
14+ /// The maximum windows path name permitted.
15+ /// </summary>
16+ /// <remarks>This may not valid for all windows systems - CE?, etc but I cant find the equivalent in the CLR.</remarks>
17+ const int MaxPath = 260 ;
18+
19+ string _baseDirectory ;
20+ bool _trimIncomingPaths ;
21+ char _replacementChar = '_' ;
22+
23+ /// <summary>
24+ /// In this case we need Windows' invalid path characters.
25+ /// Path.GetInvalidPathChars() only returns a subset invalid on all platforms.
26+ /// </summary>
27+ static readonly char [ ] InvalidEntryChars = new char [ ] {
28+ '"' , '<' , '>' , '|' , '\0 ' , '\u0001 ' , '\u0002 ' , '\u0003 ' , '\u0004 ' , '\u0005 ' ,
29+ '\u0006 ' , '\a ' , '\b ' , '\t ' , '\n ' , '\v ' , '\f ' , '\r ' , '\u000e ' , '\u000f ' ,
30+ '\u0010 ' , '\u0011 ' , '\u0012 ' , '\u0013 ' , '\u0014 ' , '\u0015 ' , '\u0016 ' ,
31+ '\u0017 ' , '\u0018 ' , '\u0019 ' , '\u001a ' , '\u001b ' , '\u001c ' , '\u001d ' ,
32+ '\u001e ' , '\u001f ' ,
33+ // extra characters for masks, etc.
34+ '*' , '?' , ':'
35+ } ;
36+
1337 /// <summary>
1438 /// Initialises a new instance of <see cref="WindowsNameTransform"/>
1539 /// </summary>
@@ -113,23 +137,6 @@ public static bool IsValidName(string name)
113137 return result ;
114138 }
115139
116- /// <summary>
117- /// Initialise static class information.
118- /// </summary>
119- static WindowsNameTransform ( )
120- {
121- char [ ] invalidPathChars ;
122-
123- invalidPathChars = Path . GetInvalidPathChars ( ) ;
124- int howMany = invalidPathChars . Length + 3 ;
125-
126- InvalidEntryChars = new char [ howMany ] ;
127- Array . Copy ( invalidPathChars , 0 , InvalidEntryChars , 0 , invalidPathChars . Length ) ;
128- InvalidEntryChars [ howMany - 1 ] = '*' ;
129- InvalidEntryChars [ howMany - 2 ] = '?' ;
130- InvalidEntryChars [ howMany - 3 ] = ':' ;
131- }
132-
133140 /// <summary>
134141 /// Force a name to be valid by replacing invalid characters with a fixed value
135142 /// </summary>
@@ -206,21 +213,5 @@ public char Replacement {
206213 _replacementChar = value ;
207214 }
208215 }
209-
210- /// <summary>
211- /// The maximum windows path name permitted.
212- /// </summary>
213- /// <remarks>This may not valid for all windows systems - CE?, etc but I cant find the equivalent in the CLR.</remarks>
214- const int MaxPath = 260 ;
215-
216- #region Instance Fields
217- string _baseDirectory ;
218- bool _trimIncomingPaths ;
219- char _replacementChar = '_' ;
220- #endregion
221-
222- #region Class Fields
223- static readonly char [ ] InvalidEntryChars ;
224- #endregion
225216 }
226217}
0 commit comments