コード例 #1
0
        private static ulong GetInputBuffer(StringBuffer content, bool isUnc, out StringBuffer buffer)
        {
            ulong length = content.Length;
            length += isUnc ? (ulong)PathInternal.UncExtendedPrefixToInsert.Length : (ulong)PathInternal.ExtendedPathPrefix.Length;
            buffer = new StringBuffer(length);

            if (isUnc)
            {
                buffer.CopyFrom(bufferIndex: 0, source: PathInternal.UncExtendedPathPrefix);
                ulong prefixDifference = (ulong)(PathInternal.UncExtendedPathPrefix.Length - PathInternal.UncPathPrefix.Length);
                content.CopyTo(bufferIndex: prefixDifference, destination: buffer, destinationIndex: (ulong)PathInternal.ExtendedPathPrefix.Length, count: content.Length - prefixDifference);
                return prefixDifference;
            }
            else
            {
                ulong prefixSize = (ulong)PathInternal.ExtendedPathPrefix.Length;
                buffer.CopyFrom(bufferIndex: 0, source: PathInternal.ExtendedPathPrefix);
                content.CopyTo(bufferIndex: 0, destination: buffer, destinationIndex: prefixSize, count: content.Length);
                return prefixSize;
            }
        }
コード例 #2
0
ファイル: LongPathHelper.cs プロジェクト: nietras/coreclr
        private static uint GetInputBuffer(StringBuffer content, bool isDosUnc, out StringBuffer buffer)
        {
            uint length = content.Length;

            length += isDosUnc
                ? (uint)PathInternal.UncExtendedPrefixLength - PathInternal.UncPrefixLength
                : PathInternal.DevicePrefixLength;

            buffer = new StringBuffer(length);

            if (isDosUnc)
            {
                // Put the extended UNC prefix (\\?\UNC\) in front of the path
                buffer.CopyFrom(bufferIndex: 0, source: PathInternal.UncExtendedPathPrefix);

                // Copy the source buffer over after the existing UNC prefix
                content.CopyTo(
                    bufferIndex: PathInternal.UncPrefixLength,
                    destination: buffer,
                    destinationIndex: PathInternal.UncExtendedPrefixLength,
                    count: content.Length - PathInternal.UncPrefixLength);

                // Return the prefix difference
                return (uint)PathInternal.UncExtendedPrefixLength - PathInternal.UncPrefixLength;
            }
            else
            {
                uint prefixSize = (uint)PathInternal.ExtendedPathPrefix.Length;
                buffer.CopyFrom(bufferIndex: 0, source: PathInternal.ExtendedPathPrefix);
                content.CopyTo(bufferIndex: 0, destination: buffer, destinationIndex: prefixSize, count: content.Length);
                return prefixSize;
            }
        }
コード例 #3
0
ファイル: StringBufferTests.cs プロジェクト: rajeevkb/corefx
 public void CopyFromStringThrowsIndexingBeyondStringLength(string value, int index, int count)
 {
     using (var buffer = new StringBuffer())
     {
         Assert.Throws<ArgumentOutOfRangeException>(() => { buffer.CopyFrom(0, value, index, count); });
     }
 }
コード例 #4
0
ファイル: StringBufferTests.cs プロジェクト: rajeevkb/corefx
 public void CopyFromStringThrowsIndexingBeyondBufferLength()
 {
     using (var buffer = new StringBuffer())
     {
         Assert.Throws<ArgumentOutOfRangeException>(() => { buffer.CopyFrom(1, ""); });
     }
 }
コード例 #5
0
ファイル: StringBufferTests.cs プロジェクト: rajeevkb/corefx
 public void CopyFromStringThrowsOnNull()
 {
     using (var buffer = new StringBuffer())
     {
         Assert.Throws<ArgumentNullException>(() => { buffer.CopyFrom(0, null); });
     }
 }
コード例 #6
0
ファイル: StringBufferTests.cs プロジェクト: rajeevkb/corefx
 public void CopyFromString(string content, string source, ulong bufferIndex, int sourceIndex, int count, string expected)
 {
     using (var buffer = new StringBuffer(content))
     {
         buffer.CopyFrom(bufferIndex, source, sourceIndex, count);
         Assert.Equal(expected, buffer.ToString());
     }
 }