public static byte[] ReadBytes(GTFS fs, long offset, int length, bool flip) { byte[] bytes = new byte[length]; long original = fs.Position; fs.Position = offset; //for (int i = 0; i < length; i++) //bytes[i] = (byte)fs.ReadByte(); fs.Read(bytes, 0, length); if (fs.GetType() == typeof(GTFS) && EnableGTFSView) { ((GTFS)fs).AddTrack(offset, length); } fs.Position = original; if (flip) { Array.Reverse(bytes); } return(bytes); }
public static byte[] ReadBytes(GTFS fs, int length, bool flip) { if (length < 0) { throw new Exception(); } byte[] bytes = new byte[length]; fs.Read(bytes, 0, length); //for (int i = 0; i < length i++) //bytes[i] = (byte)fs.ReadByte(); if (fs.GetType() == typeof(GTFS) && EnableGTFSView) { ((GTFS)fs).AddTrack(fs.Position - length, length); } if (flip) { Array.Reverse(bytes); } return(bytes); }
public static void WriteSubFile(GTFS fs, string newfile, long length) { FileStream nf = File.Create(newfile); byte[] buffer = new byte[length]; fs.Read(buffer, 0, buffer.Length); nf.Write(buffer, 0, buffer.Length); nf.Close(); }
public static void WriteSubFile(GTFS fs, string newfile, long length, long offset) { long last = fs.Position; FileStream nf = File.Create(newfile); byte[] buffer = new byte[length]; fs.Seek(offset, SeekOrigin.Begin); fs.Read(buffer, 0, buffer.Length); nf.Write(buffer, 0, buffer.Length); nf.Close(); fs.Position = last; }