@@ -4,7 +4,6 @@ namespace DotNet.Testcontainers.Images
4
4
using System . Collections . Generic ;
5
5
using System . IO ;
6
6
using System . Linq ;
7
- using System . Runtime . InteropServices ;
8
7
using System . Text ;
9
8
using System . Text . RegularExpressions ;
10
9
using System . Threading ;
@@ -150,7 +149,7 @@ public async Task<string> Tar(CancellationToken ct = default)
150
149
{
151
150
var entry = TarEntry . CreateTarEntry ( relativeFilePath ) ;
152
151
entry . TarHeader . Size = inputStream . Length ;
153
- entry . TarHeader . Mode = GetFileMode ( absoluteFilePath ) ;
152
+ entry . TarHeader . Mode = GetUnixFileMode ( absoluteFilePath ) ;
154
153
155
154
await tarOutputStream . PutNextEntryAsync ( entry , ct )
156
155
. ConfigureAwait ( false ) ;
@@ -188,21 +187,22 @@ private static IEnumerable<string> GetFiles(string directory)
188
187
}
189
188
190
189
/// <summary>
191
- /// Gets the file mode for a given file.
190
+ /// Gets the Unix file mode of the file on the path .
192
191
/// </summary>
193
- /// <param name="path ">The path to the file.</param>
194
- /// <returns>The file mode for the <see cref="TarEntry"/> </returns>
195
- private static int GetFileMode ( string path )
192
+ /// <param name="filePath ">The path to the file.</param>
193
+ /// <returns>The Unix file mode of the file on the path. </returns>
194
+ private static int GetUnixFileMode ( string filePath )
196
195
{
197
196
#if NET7_0_OR_GREATER
198
- if ( ! RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
197
+ if ( ! OperatingSystem . IsWindows ( ) )
199
198
{
200
- return ( int ) File . GetUnixFileMode ( path ) ;
199
+ return ( int ) File . GetUnixFileMode ( filePath ) ;
201
200
}
202
201
#endif
203
202
204
- // Default to 755 for Windows and fallback to 755 for Unix when
205
- // `GetUnixFileMode` is not available.
203
+ // Default to 755 for Windows and fall back to 755 for Unix when `GetUnixFileMode`
204
+ // is not available.
205
+ _ = filePath ;
206
206
return ( int ) Unix . FileMode755 ;
207
207
}
208
208
}
0 commit comments