--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+internal partial class Interop
+{
+ internal partial class Kernel32
+ {
+ internal const int MAX_PATH = 260;
+ }
+}
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.GetTempPathW.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.Globalization.cs" Condition="'$(EnableDummyGlobalizationImplementation)' != 'true'" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.LockFile.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.MAX_PATH.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.OutputDebugString.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.ReadFile_SafeHandle_IntPtr.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.ReadFile_SafeHandle_NativeOverlapped.cs" />
(char)31
};
- // The max total path is 260, and the max individual component length is 255.
- // For example, D:\<256 char file name> isn't legal, even though it's under 260 chars.
- internal const int MaxPath = 260;
-
// Expands the given path to a fully qualified path.
public static string GetFullPath(string path)
{
public static string GetTempPath()
{
- StringBuilder sb = StringBuilderCache.Acquire(MaxPath);
- uint r = Interop.Kernel32.GetTempPathW(MaxPath, sb);
+ StringBuilder sb = StringBuilderCache.Acquire(Interop.Kernel32.MAX_PATH);
+ uint r = Interop.Kernel32.GetTempPathW(Interop.Kernel32.MAX_PATH, sb);
if (r == 0)
throw Win32Marshal.GetExceptionForLastWin32Error();
return GetFullPath(StringBuilderCache.GetStringAndRelease(sb));
{
string path = GetTempPath();
- StringBuilder sb = StringBuilderCache.Acquire(MaxPath);
+ StringBuilder sb = StringBuilderCache.Acquire(Interop.Kernel32.MAX_PATH);
uint r = Interop.Kernel32.GetTempFileNameW(path, "tmp", 0, sb);
if (r == 0)
throw Win32Marshal.GetExceptionForLastWin32Error();
/// <exception cref="System.IndexOutOfRangeException">
/// Thrown when index less than 0 or index greater than or equal to Length
/// </exception>
-
public ref readonly T this[int index]
{
#if PROJECTN
#if PLATFORM_UNIX
throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives);
#else
- if (System.IO.Path.MaxPath < name.Length)
+ if (Interop.Kernel32.MAX_PATH < name.Length)
{
- throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, Path.MaxPath), nameof(name));
+ throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, Interop.Kernel32.MAX_PATH), nameof(name));
}
#endif
}
#if PLATFORM_UNIX
throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives);
#else
- if (System.IO.Path.MaxPath < name.Length)
+ if (Interop.Kernel32.MAX_PATH < name.Length)
{
- throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, Path.MaxPath), nameof(name));
+ throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, Interop.Kernel32.MAX_PATH), nameof(name));
}
#endif
}
throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
}
- if (null != name && System.IO.Path.MaxPath < name.Length)
+ if (null != name && Interop.Kernel32.MAX_PATH < name.Length)
{
- throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, Path.MaxPath), nameof(name));
+ throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, Interop.Kernel32.MAX_PATH), nameof(name));
}
#if !PLATFORM_UNIX
private static void VerifyNameForCreate(string name)
{
- if (name != null && (Path.MaxPath < name.Length))
+ if (name != null && (Interop.Kernel32.MAX_PATH < name.Length))
{
- throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, Path.MaxPath), nameof(name));
+ throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, Interop.Kernel32.MAX_PATH), nameof(name));
}
}
#endif
private void CreateMutexCore(bool initiallyOwned, string name, out bool createdNew)
{
#if !PLATFORM_UNIX
- Debug.Assert(name == null || name.Length <= Path.MaxPath);
+ Debug.Assert(name == null || name.Length <= Interop.Kernel32.MAX_PATH);
#endif
uint mutexFlags = initiallyOwned ? Win32Native.CREATE_MUTEX_INITIAL_OWNER : 0;
#if PLATFORM_UNIX
throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives);
#else
- if (name.Length > Path.MaxPath)
- throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, Path.MaxPath), nameof(name));
+ if (name.Length > Interop.Kernel32.MAX_PATH)
+ throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, Interop.Kernel32.MAX_PATH), nameof(name));
#endif
}
throw new ArgumentNullException(nameof(name), SR.ArgumentNull_WithParamName);
if (name.Length == 0)
throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
- if (name.Length > Path.MaxPath)
- throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, Path.MaxPath), nameof(name));
+ if (name.Length > Interop.Kernel32.MAX_PATH)
+ throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, Interop.Kernel32.MAX_PATH), nameof(name));
//Pass false to OpenSemaphore to prevent inheritedHandles
SafeWaitHandle myHandle = Win32Native.OpenSemaphore(AccessRights, false, name);
try
{
- StringBuilder fileMuiPath = StringBuilderCache.Acquire(Path.MaxPath);
- fileMuiPath.Length = Path.MaxPath;
- int fileMuiPathLength = Path.MaxPath;
+ StringBuilder fileMuiPath = StringBuilderCache.Acquire(Interop.Kernel32.MAX_PATH);
+ int fileMuiPathLength = Interop.Kernel32.MAX_PATH;
int languageLength = 0;
long enumerator = 0;