# README
iso9660
A package for reading and creating ISO9660
Joliet extension is NOT supported.
Experimental support for reading Rock Ridge extension is currently in the works. If you are experiencing issues, please use the v0.3 release, which ignores Rock Ridge.
References for the format:
- ECMA-119 1st edition (December 1986) (Web Archive link)
- ECMA-119 2nd edition (December 1987) (Web Archive link)
- ECMA-119 3rd edition (December 2017) (Web Archive link)
- ECMA-119 4th edition (June 2019) (Web Archive link)
- Rock Ridge Interchange Protocol (Web Archive link)
- System Use Sharing Protocol v1.12
Examples
Extracting an ISO
package main
import (
"log"
"github.com/kdomanski/iso9660/util"
)
func main() {
f, err := os.Open("/home/user/myImage.iso")
if err != nil {
log.Fatalf("failed to open file: %s", err)
}
defer f.Close()
if err = util.ExtractImageToDirectory(f, "/home/user/target_dir"); err != nil {
log.Fatalf("failed to extract image: %s", err)
}
}
Creating an ISO
package main
import (
"log"
"os"
"github.com/kdomanski/iso9660"
)
func main() {
writer, err := iso9660.NewWriter()
if err != nil {
log.Fatalf("failed to create writer: %s", err)
}
defer writer.Cleanup()
f, err := os.Open("/home/user/myFile.txt")
if err != nil {
log.Fatalf("failed to open file: %s", err)
}
defer f.Close()
err = writer.AddFile(f, "folder/MYFILE.TXT")
if err != nil {
log.Fatalf("failed to add file: %s", err)
}
outputFile, err := os.OpenFile("/home/user/output.iso", os.O_WRONLY | os.O_TRUNC | os.O_CREATE, 0644)
if err != nil {
log.Fatalf("failed to create file: %s", err)
}
err = writer.WriteTo(outputFile, "testvol")
if err != nil {
log.Fatalf("failed to write ISO image: %s", err)
}
err = outputFile.Close()
if err != nil {
log.Fatalf("failed to close output file: %s", err)
}
}
Recursively create an ISO image from the given directories
package main
import (
"fmt"
"log"
"os"
"path/filepath"
"strings"
"github.com/kdomanski/iso9660"
)
func main() {
writer, err := iso9660.NewWriter()
if err != nil {
log.Fatalf("failed to create writer: %s", err)
}
defer writer.Cleanup()
isoFile, err := os.OpenFile("C:/output.iso", os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644)
if err != nil {
log.Fatalf("failed to create file: %s", err)
}
defer isoFile.Close()
prefix := "F:\\" // the prefix to remove in the output iso file
sourceFolders := []string{"F:\\test1", "F:\\test2"} // the given directories to create an ISO file from
for _, folderName := range sourceFolders {
folderPath := strings.Join([]string{prefix, folderName}, "/")
walk_err := filepath.Walk(folderPath, func(path string, info os.FileInfo, err error) error {
if err != nil {
log.Fatalf("walk: %s", err)
return err
}
if info.IsDir() {
return nil
}
outputPath := strings.TrimPrefix(path, prefix) // remove the source drive name
fmt.Printf("Adding file: %s\n", outputPath)
fileToAdd, err := os.Open(path)
if err != nil {
log.Fatalf("failed to open file: %s", err)
}
defer fileToAdd.Close()
err = writer.AddFile(fileToAdd, outputPath)
if err != nil {
log.Fatalf("failed to add file: %s", err)
}
return nil
})
if walk_err != nil {
log.Fatalf("%s", walk_err)
}
}
err = writer.WriteTo(isoFile, "Test")
if err != nil {
log.Fatalf("failed to write ISO image: %s", err)
}
}
# Functions
See SUSP-112 5.5.
MarshalString encodes the given string as a byte array padded to the given length.
NewWriter creates a new ImageWrite and initializes its temporary staging dir.
OpenImage returns an Image reader reating from a given file.
See SUSP-112 5.3.
UnmarshalInt16LSBMSB decodes a 16-bit integer in both byte orders, as defined in ECMA-119 7.3.3.
UnmarshalInt32LSBMSB decodes a 32-bit integer in both byte orders, as defined in ECMA-119 7.3.3.
UnmarshalUint32LSBMSB is the same as UnmarshalInt32LSBMSB but returns an unsigned integer.
VolumeDescriptorTimestampFromTime converts time.Time to VolumeDescriptorTimestamp.
WriteInt16LSBMSB writes a 16-bit integer in both byte orders, as defined in ECMA-119 7.2.3.
WriteInt32LSBMSB writes a 32-bit integer in both byte orders, as defined in ECMA-119 7.3.3.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
ErrFileTooLarge is returned when trying to process a file of size greater than 4GB, which due to the 32-bit address limitation is not possible except with ISO 9660-Level 3.
No description provided by the author
# Structs
BootVolumeDescriptorBody represents the data in bytes 7-2047 of a Boot Record as defined in ECMA-119 8.2.
SUSP-112 5.1.
DirectoryEntry contains data from a Directory Descriptor as described by ECMA-119 9.1.
No description provided by the author
File is a os.FileInfo-compatible wrapper around an ISO9660 directory entry.
Image is a wrapper around an image file that allows reading its ISO9660 data.
ImageWriter is responsible for staging an image's contents and writing them to an image.
PrimaryVolumeDescriptorBody represents the data in bytes 7-2047 of a Primary Volume Descriptor as defined in ECMA-119 8.4.
No description provided by the author
No description provided by the author
No description provided by the author
VolumeDescriptorTimestamp represents a time and date format that can be encoded according to ECMA-119 8.4.26.1.
# Type aliases
RecordingTimestamp represents a time and date format that can be encoded according to ECMA-119 9.1.5.
SUSP-112 4.1.
No description provided by the author