Commits

Fazlul Shahriar committed 8572994

rearrange functions/methods (no code changed)

Comments (0)

Files changed (1)

 	"os"
 )
 
-type File struct {
-	fd      *os.File
-	r       *bufio.Reader
-	Records []Record
-	Version *Version
-}
-
-type Record struct {
-	Tag, Ref    uint16
-	offset, len uint32
-	file        *File
-	parsing     bool
-	Info        interface{}
-}
-
 func get8(b []byte) (uint8, []byte) {
 	return uint8(b[0]), b[1:]
 }
 	return b[:n], b[n:]
 }
 
+func parseNumType(b []byte) *NumType {
+	nt := new(NumType)
+	nt.version, b = get8(b)
+	nt.Type, b = get8(b)
+	nt.width, b = get8(b)
+	nt.Class, b = get8(b)
+	return nt
+}
+
+func parseVersion(b []byte) *Version {
+	v := new(Version)
+	v.Major, b = get32(b)
+	v.Minor, b = get32(b)
+	v.Release, b = get32(b)
+	v.Description = string(b[:])
+	return v
+}
+
 func Open(filename string) (*File, error) {
 	fd, err := os.Open(filename)
 	if err != nil {
 	if err = file.readDescriptors(); err != nil {
 		return nil, err
 	}
-
 	rec, err := file.LookupRecord(DFTAG_VERSION, -1)
 	if err != nil {
 		return nil, err
 	return file, nil
 }
 
+type File struct {
+	fd      *os.File
+	r       *bufio.Reader
+	Records []Record
+	Version *Version
+}
+
 func (file *File) Close() {
 	file.fd.Close()
 }
 	return nt, nil
 }
 
-func (rec *Record) readPayload() ([]byte, error) {
-	if _, err := rec.file.fd.Seek(int64(rec.offset), os.SEEK_SET); err != nil {
-		return nil, err
-	}
-	r := bufio.NewReader(rec.file.fd)
-
-	b := make([]byte, rec.len)
-	if _, err := io.ReadFull(r, b); err != nil {
-		return nil, err
-	}
-	return b, nil
-}
-
-type Version struct {
-	Major, Minor, Release uint32
-	Description           string
-}
-
-func parseVersion(b []byte) *Version {
-	v := new(Version)
-	v.Major, b = get32(b)
-	v.Minor, b = get32(b)
-	v.Release, b = get32(b)
-	v.Description = string(b[:])
-	return v
-}
-
-type NumType struct {
-	version, Type, width, Class uint8
-}
-
-func parseNumType(b []byte) *NumType {
-	nt := new(NumType)
-	nt.version, b = get8(b)
-	nt.Type, b = get8(b)
-	nt.width, b = get8(b)
-	nt.Class, b = get8(b)
-	return nt
-}
-
-// Scientific Data Dimension
-type SDD struct {
-	Dim     []uint32
-	DataNT  *NumType
-	ScaleNT []*NumType
-}
-
 func (file *File) parseSDD(b []byte) (*SDD, error) {
 	sdd := new(SDD)
 	rank, b := get16(b)
 	return sdd, nil
 }
 
-// Numeric Data Group
-type NDG struct {
-	Records []*Record
-}
-
 func (file *File) parseNDG(b []byte) (*NDG, error) {
 	var tag, ref uint16
 
 	return ndg, nil
 }
 
-type VGroup struct {
-	Records      []*Record
-	Name         []byte
-	Class        []byte
-	extag, exref uint16
-	version      uint16
-}
-
 func (file *File) parseVGroup(b []byte) (*VGroup, error) {
 	vg := new(VGroup)
 	nelt, b := get16(b)
 	vg.version, b = get16(b)
 	return vg, nil
 }
+
+type Record struct {
+	Tag, Ref    uint16
+	offset, len uint32
+	file        *File
+	parsing     bool
+	Info        interface{}
+}
+
+func (rec *Record) readPayload() ([]byte, error) {
+	if _, err := rec.file.fd.Seek(int64(rec.offset), os.SEEK_SET); err != nil {
+		return nil, err
+	}
+	r := bufio.NewReader(rec.file.fd)
+
+	b := make([]byte, rec.len)
+	if _, err := io.ReadFull(r, b); err != nil {
+		return nil, err
+	}
+	return b, nil
+}
+
+type Version struct {
+	Major, Minor, Release uint32
+	Description           string
+}
+
+type NumType struct {
+	version, Type, width, Class uint8
+}
+
+// Scientific Data Dimension
+type SDD struct {
+	Dim     []uint32
+	DataNT  *NumType
+	ScaleNT []*NumType
+}
+
+// Numeric Data Group
+type NDG struct {
+	Records []*Record
+}
+
+type VGroup struct {
+	Records      []*Record
+	Name         []byte
+	Class        []byte
+	extag, exref uint16
+	version      uint16
+}