private const int CommonSenseLimit    = 1024; // for benchmarks that use args like "new string('a', 200_000)"

        internal static string GetTraceFilePath(DiagnoserActionParameters details, DateTime creationTime, string fileExtension)
        {
            string nameNoLimit = GetFilePathNoLimits(details, creationTime, fileExtension);

            int limit = PathFeatures.AreAllLongPathsAvailable() ? CommonSenseLimit : WindowsOldPathLimit;

            if (nameNoLimit.Length <= limit)
            {
                return(nameNoLimit);
            }

            return(GetLimitedFilePath(details, creationTime, fileExtension, limit));
        }
Exemplo n.º 2
0
        public void GetFullPath_MaxPathNotTooLong()
        {
            string value = @"C:\" + new string('a', 255) + @"\";

            if (PathFeatures.AreAllLongPathsAvailable())
            {
                // Shouldn't throw anymore
                Path.GetFullPath(value);
            }
            else
            {
                Assert.Throws <PathTooLongException>(() => Path.GetFullPath(value));
            }
        }
Exemplo n.º 3
0
        public IEnumerable <object> RecursiveDepthData()
        {
            yield return(10);

            // Length of the path can be 260 characters on netfx.
            if (PathFeatures.AreAllLongPathsAvailable())
            {
                yield return(100);

                // Most Unix distributions have a maximum path length of 1024 characters (1024 UTF-8 bytes).
                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    yield return(1000);
                }
            }
        }
Exemplo n.º 4
0
        public void GetFullPath_NormalizedLongPathTooLong()
        {
            // Try out a long path that normalizes down to more than MaxPath
            string    curDir   = Directory.GetCurrentDirectory();
            const int Iters    = 260;
            var       longPath = new StringBuilder(curDir, curDir.Length + (Iters * 4));

            for (int i = 0; i < Iters; i++)
            {
                longPath.Append(Path.DirectorySeparatorChar).Append('a').Append(Path.DirectorySeparatorChar).Append('.');
            }

            if (PathFeatures.AreAllLongPathsAvailable())
            {
                // Now no longer throws unless over ~32K
                Assert.NotNull(Path.GetFullPath(longPath.ToString()));
            }
            else
            {
                Assert.Throws <PathTooLongException>(() => Path.GetFullPath(longPath.ToString()));
            }
        }