MoltenMercury/libWyvernzora/Core/StreamTools.cs

(开头部分) 6KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

/*===================================================
 * LibHex2\\Core\\StreamTools.cs
 * -------------------------------------------------------------------------------
 * Copyright (C) Aragorn Wyvernzora 2011
 * -------------------------------------------------------------------------------
 *  This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * ===================================================
 */

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace libWyvernzora
{
    /// <summary>
    /// Class that extends I/O ability of Stream-derived classes
    /// </summary>
    public static class StreamTools
    {
        public static Byte[] ReadBytes( Stream s, Int32 count)
        {
            Byte[] buffer = new Byte[count];
            s.Read(buffer, 0, count);
            return buffer;
        }
        public static void WriteBytes( Stream s, Byte[] src)
        { s.Write(src, 0, src.Length); }

        //Advanced reading functions that require explicit byte-sequence param
        public static SByte ReadSByte( Stream s)
        { return HexTools.Sign(Convert.ToByte(s.ReadByte())); }
        public static Int16 ReadI16( Stream s, BitSequence seq = BitSequence.LittleEndian)
        { return HexTools.HEXtoI16(ReadBytes(s, 2), seq); }
        public static UInt16 ReadU16(Stream s, BitSequence seq = BitSequence.LittleEndian)
        { return HexTools.HEXtoU16(ReadBytes(s,2), seq); }
        public static Int32 ReadI32(Stream s, BitSequence seq = BitSequence.LittleEndian)
        { return HexTools.HEXtoI32(ReadBytes(s,4), seq); }
        public static UInt32 ReadU32(Stream s, BitSequence seq = BitSequence.LittleEndian)
        { return HexTools.HEXtoU32(ReadBytes(s,4), seq); }
        public static Int64 ReadI64(Stream s, BitSequence seq = BitSequence.LittleEndian)
        { return HexTools.HEXtoI64(ReadBytes(s,8), seq); }
        public static UInt64 ReadU64(Stream s, BitSequence seq = BitSequence.LittleEndian)
        { return HexTools.HEXtoU64(ReadBytes(s,8), seq); }
        public static Single ReadF32(Stream s, BitSequence seq = BitSequence.LittleEndian)
        { return HexTools.HEXtoF32(ReadBytes(s,4), seq); }
        public static Double ReadF64(Stream s, BitSequence seq = BitSequence.LittleEndian)
        { return HexTools.HEXtoF64(ReadBytes(s,8), seq); }
后面还有 86 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。