Пример #1
0
        /// <summary>
        /// Reading the path from the image and converting it to byte[][] directly
        /// this saves us an array copy and conversions to and from String
        /// </summary>
        /// <param name="in">input to read from</param>
        /// <returns>
        /// the array each element of which is a byte[] representation
        /// of a path component
        /// </returns>
        /// <exception cref="System.IO.IOException"/>
        public static byte[][] ReadPathComponents(DataInput @in)
        {
            DeprecatedUTF8 ustr = TlData.Get().UStr;

            ustr.ReadFields(@in);
            return(DFSUtil.Bytes2byteArray(ustr.GetBytes(), ustr.GetLength(), unchecked ((byte
                                                                                          )Path.SeparatorChar)));
        }
Пример #2
0
        /// <exception cref="System.Exception"/>
        public virtual void TestString(string str)
        {
            string pathString = str;

            byte[][] oldPathComponents = INode.GetPathComponents(pathString);
            byte[][] newPathComponents = DFSUtil.Bytes2byteArray(Sharpen.Runtime.GetBytesForString
                                                                     (pathString, Charsets.Utf8), unchecked ((byte)Path.SeparatorChar));
            if (oldPathComponents[0] == null)
            {
                NUnit.Framework.Assert.IsTrue(oldPathComponents[0] == newPathComponents[0]);
            }
            else
            {
                NUnit.Framework.Assert.IsTrue("Path components do not match for " + pathString, Arrays
                                              .DeepEquals(oldPathComponents, newPathComponents));
            }
        }