Exemple #1
0
func main() {
	if len(os.Args) != 2 {
		fmt.Println("Please provide one file names...")
		return
	}
	buffer := make([]byte, 32)
	fileIn, fileErr := os.Open(os.Args[1])
	if fileErr != nil {
		fmt.Println(fileErr.Error())
		return
	}
	xRef, fileErr := decode.GetXRef(fileIn)
	if fileErr != nil {
		fmt.Println(fileErr.Error())
		return
	}
	offset := int64(xRef.Trips[43].Offset)
	_, fileErr = fileIn.Seek(offset, 0)
	if fileErr != nil {
		fmt.Println(fileErr.Error())
		return
	}
	_, fileErr = fileIn.Read(buffer)
	if fileErr != nil {
		fmt.Println(fileErr.Error())
		return
	}
	fmt.Println(string(buffer))
}
Exemple #2
0
func main() {
	if len(os.Args) != 3 {
		fmt.Println("Please provide two file names...")
		return
	}
	fileIn, fileErr := os.Open(os.Args[1])
	if fileErr != nil {
		fmt.Println(fileErr.Error())
		return
	}
	fileOut, fileErr := os.Create(os.Args[2])
	if fileErr != nil {
		fmt.Println(fileErr.Error())
		return
	}
	xRef, fileErr := decode.GetXRef(fileIn)
	if fileErr != nil {
		fmt.Println(fileErr.Error())
		return
	}
	data, fileErr := xml.MarshalIndent(xRef, "\t", "\t")
	if fileErr != nil {
		fmt.Println(fileErr.Error())
		return
	}
	_, fileErr = fileOut.Write(data)
	if fileErr != nil {
		fmt.Println(fileErr.Error())
		return
	}
}