~ubuntu-branches/ubuntu/hoary/monodevelop/hoary

« back to all changes in this revision

Viewing changes to src/Libraries/SharpAssembly/src/SharpAssembly/PE/StreamHeader.cs

  • Committer: Bazaar Package Importer
  • Author(s): Brandon Hale
  • Date: 2004-10-07 11:51:11 UTC
  • Revision ID: james.westby@ubuntu.com-20041007115111-pxcqnwfxyq5mhcx5
Tags: 0.5.1-3
Use dh_netdeps in debian/rules and debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// StreamHeader.cs
 
2
// Copyright (C) 2003 Mike Krueger
 
3
// 
 
4
// This library is free software; you can redistribute it and/or
 
5
// modify it under the terms of the GNU Lesser General Public
 
6
// License as published by the Free Software Foundation; either
 
7
// version 2.1 of the License, or (at your option) any later version.
 
8
// 
 
9
// This library is distributed in the hope that it will be useful,
 
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
// Lesser General Public License for more details.
 
13
// 
 
14
// You should have received a copy of the GNU Lesser General Public
 
15
// License along with this library; if not, write to the Free Software
 
16
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
17
 
 
18
 
 
19
using System;
 
20
using System.IO;
 
21
 
 
22
namespace MonoDevelop.SharpAssembly.PE {
 
23
        
 
24
        public class StreamHeader
 
25
        {
 
26
                uint offset;
 
27
                uint size;
 
28
                string name;
 
29
                
 
30
                public uint Offset {
 
31
                        get {
 
32
                                return offset;
 
33
                        }
 
34
                        set {
 
35
                                offset = value;
 
36
                        }
 
37
                }
 
38
                
 
39
                public uint Size {
 
40
                        get {
 
41
                                return size;
 
42
                        }
 
43
                        set {
 
44
                                size = value;
 
45
                        }
 
46
                }
 
47
                
 
48
                public string Name {
 
49
                        get {
 
50
                                return name;
 
51
                        }
 
52
                        set {
 
53
                                name = value;
 
54
                        }
 
55
                }
 
56
                
 
57
                public void LoadFrom(BinaryReader binaryReader)
 
58
                {
 
59
                        offset = binaryReader.ReadUInt32();
 
60
                        size   = binaryReader.ReadUInt32();
 
61
                        int bytesRead = 1;
 
62
                        byte b = binaryReader.ReadByte();
 
63
                        while (b != 0) {
 
64
                                name += (char)b;
 
65
                                b = binaryReader.ReadByte();
 
66
                                ++bytesRead;
 
67
                        }
 
68
                        // name is filled to 4 byte blocks
 
69
                        int filler = bytesRead % 4 == 0 ? 0 :  4 - (bytesRead % 4);
 
70
                        for (int i = 0; i < filler; ++i) {
 
71
                                binaryReader.ReadByte();
 
72
                        }
 
73
                        
 
74
                }
 
75
        }
 
76
}