func WriteRefFiles(book *EPUB, w *zip.Writer) error {
	for rfPath, rf := range book.RootFiles {
		dir := path.Dir(rfPath)
		for _, file := range rf.Manifest.Items {
			targetPath := path.Join(dir, file.Href)
			bookFile, ok := book.Files[targetPath]
			if !ok {
				fmt.Printf("Can't find refereed file '%s' in structure cache. RootFile path: '%s'\n", targetPath, rfPath)
				continue
			}
			file, err := w.Create(targetPath)
			if err != nil {
				return err
			}
			bookFileReader, err := bookFile.Open()
			if err != nil {
				return err
			}
			buffer, err := ioutil.ReadAll(bookFileReader)
			if err != nil {
				return err
			}
			_, err = file.Write(buffer)
			if err != nil {
				return err
			}
		}
	}
	return nil
}
//WriteRefFiles save all referenced files from each root file to archive
WriteRefFiles save all referenced files from each root file to archive
// WriteRefFiles save all referenced files from each root file to archive
func WriteRefFiles(book *EPUB, w *zip.Writer) error {
	for rfPath, rf := range book.RootFiles {
		dir := path.Dir(rfPath)
		for _, file := range rf.Manifest.Items {
			targetPath := path.Join(dir, file.Href)
			bookFile, ok := book.Files[targetPath]
			if !ok {
				fmt.Printf("Can't find refereed file '%s' in structure cache. RootFile path: '%s'\n", targetPath, rfPath)
				continue
			}
			file, err := w.Create(targetPath)
			if err != nil {
				return err
			}
			bookFileReader, err := bookFile.Open()
			if err != nil {
				return err
			}
			buffer, err := ioutil.ReadAll(bookFileReader)
			if err != nil {
				return err
			}
			_, err = file.Write(buffer)
			if err != nil {
				return err
			}
		}
	}
	return nil
}
func WriteRefFiles ( book * EPUB , w * zip . Writer ) error { for rfPath , rf := range book . RootFiles { dir := path . Dir ( rfPath ) for _ , file := range rf . Manifest . Items { targetPath := path . Join ( dir , file . Href ) bookFile , ok := book . Files [ targetPath ] if ! ok { fmt . Printf ( " \n " , targetPath , rfPath ) continue } file , err := w . Create ( targetPath ) if err != nil { return err } bookFileReader , err := bookFile . Open ( ) if err != nil { return err } buffer , err := ioutil . ReadAll ( bookFileReader ) if err != nil { return err } _ , err = file . Write ( buffer ) if err != nil { return err } } } return nil }
WriteRefFiles save all referenced files from each root file to archive
WriteRefFiles save all referenced files from each root file to archive