A go library for reading and creating ISO9660 images

Overview

iso9660

GoDoc

A package for reading and creating ISO9660

Joliet and Rock Ridge extensions are not supported.

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)
  }
}
Comments
  • Use uint32 to decode directory entry length

    Use uint32 to decode directory entry length

    Use unsigned integers for the ExtentLength field of directory entries.

    I have a ISO file with a very large file in it (2.8GB), I had trouble reading that file with other tools so it could be that the ISO itself is not confromant or that other tools have this same bug. The ECMA standard is not clear on the signedness of the size field IMO. However I do not see the value of signed numbers for file length.

    opened by aarzilli 3
  • Proposal: Please start using Semantic Versioning

    Proposal: Please start using Semantic Versioning

    I found that this project already supports Go modules. But sadly, the tags doesn't follow Semantic Versioning, which means that all tags of this project will be ignored by Go modules and replaced by pseudo-versions, go get acts weirdly when tags are not in that form. It would be great to have the tagged release be named in the format vX.X.X format so that go mod can read it.

    $go get github.com/kdomanski/[email protected]
    go get github.com/kdomanski/[email protected]: no matching versions for query "v0.2"
    $go get github.com/kdomanski/iso9660
    go: downloading github.com/kdomanski/iso9660 v0.0.0-20200713230927-fa56c38dc741
    go: github.com/kdomanski/iso9660 upgrade => v0.0.0-20200713230927-fa56c38dc741
    

    Else the mod file shows something like github.com/kdomanski/iso9660 v0.0.0-20200713230927-fa56c38dc741 which is not very readable and difficult to upgrade. It’s hard to verify which version is in use. This is not conducive to version control.

    So, I propose this project to follow Semantic Versioning in future versions. For example, v1.0.1, v2.0.0, v3.1.0-alpha, v3.1.0-beta.2etc, so that other project can use tag in go.mod.

    opened by KateGo520 3
  • allow setting dCharacters / cloud-init support

    allow setting dCharacters / cloud-init support

    Hi kdomanski,

    thanks for writing this useful library. I tried to use it in combination with cloud-init, but there files are named user-data, and meta-data. '-' is not in the valid set for dCharacters, which is perfectly fine, because it simply is not a valid char according to the iso9660 spec. On the other hand it is also known that many platforms are pretty relaxed when it comes to actual implementations. Adding '-' to the dCharacters worked fine on Linux.

    Would you accept a patch that adds a SetdCharacters() to ImageWriter?

    opened by rck 2
  • Adding multiple folders recursively

    Adding multiple folders recursively

    I am trying to add multiple files in the sourceFolders by using the walk function for each folder. However, it only adds one single file for some reason.

    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()
    
    	sourcePath := "F:\\"
    
    	folders := []string{"F:\\test1", "F:\\test2"}
    
    	for _, folderName := range folders {
    		folderPath := strings.Join([]string{sourcePath, 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, sourcePath) // 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)
    	}
    }
    
    opened by aminya 1
  • Add AddLocalFile function in image_writer

    Add AddLocalFile function in image_writer

    AddLocalFile is for adding existing files in the filesystem to an ISO. It first tries to hardlink the file to the staging area which can provide speed-up. If hardlinking is not possible, it opens the specified file and calls AddFile().

    Even if hardlinking is never possible, it saves a few lines of codes in many places because you don't need to handle the opening/closing of files yourself.

    opened by chtisgit 1
  • panic name without a dot

    panic name without a dot

    https://github.com/kdomanski/iso9660/blob/880de9cb649c5731170a2f808b11ef1392954864/image_reader.go#L104

    runtime error: index out of range [1] with length 1

    maybe

    	if len(splitFileIdentifier) == 0 {
    		return splitFileIdentifier[0]
    	}
    
    opened by sdir 0
  • Write to the ISO file descriptor

    Write to the ISO file descriptor

    Before:

    $ go run readme.go
    2019/12/07 16:56:52 failed to write ISO image: write myFile.txt: bad file descriptor
    exit status 1
    

    After:

    $ go run readme.go
    $ ls -al output.iso
    -rw-r--r--@ 1 oozie  staff  0 Dec  7 16:56 output.iso
    
    opened by oozie 0
  • Location is not available when trying to access a folder with Windows

    Location is not available when trying to access a folder with Windows

    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("myFile.txt")
    	if err != nil {
    	  log.Fatalf("failed to open file: %s", err)
    	}
    	defer f.Close()
      
    	err = writer.AddFile(f, "MYFILE.TXT") // work
    	if err != nil {
    	  log.Fatalf("failed to add file: %s", err)
    	}
    
    	err = writer.AddFile(f, "random_folder_name/MYFILE.TXT") // doesn't work
    	if err != nil {
    	  log.Fatalf("failed to add file: %s", err)
    	}
      
    	err = writer.AddLocalDirectory("fixtures/test.iso_source", "fixtures/test.iso_source") // doesn't work
    	if err != nil {
    	  log.Fatalf("failed to add file: %s", err)
    	}
    
    	outputFile, err := os.OpenFile("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)
    	}
    }
    

    image

    As anyone has been able to create a folder within the .iso file, mount the .iso, and access that folder using Windows?

    opened by shellwhale 0
  • In memory image creation

    In memory image creation

    Currently, the package creates a temporary folder and copies the files into it to create the image. This can be avoided by using an in-memory creation.

    opened by aminya 1
  • Is there a way to create a bootable iso

    Is there a way to create a bootable iso

    This doesn't seem possible given https://github.com/kdomanski/iso9660/blob/880de9cb649c5731170a2f808b11ef1392954864/image_writer.go#L520-L524

    I might be missing something though ... If not, is this something you would consider as an enhancement?

    opened by carbonin 0
  • Feature Request: Joliet and Rock Ridge extensions supporting.

    Feature Request: Joliet and Rock Ridge extensions supporting.

    Good day Hope you are doing well.

    For now: Joliet and Rock Ridge extensions are not supported. Do you plan to write additional methods for supporting them?

    opened by vdmvoro 0
  • Feature Request: El Torito Support

    Feature Request: El Torito Support

    I would love to see El Torito being supported. El Torito images are valid ISO9660 images with the addition of being able to be written to USB drives (dd) for example.

    links:

    https://wiki.osdev.org/El-Torito

    https://en.wikipedia.org/wiki/El_Torito_(CD-ROM_standard)

    https://github.com/diskfs/go-diskfs/blob/1f72a0e0bb68b80c9659e81940962171e9dc9aed/filesystem/iso9660/eltorito.go

    Thanks for creating this library!

    opened by srlehn 0
Releases(v0.3.3)
  • v0.3.3(Sep 17, 2022)

    What's Changed

    • split unit and integration tests runs by @kdomanski in https://github.com/kdomanski/iso9660/pull/23
    • remove unnecessary buffer allocation in image writer by @kdomanski in https://github.com/kdomanski/iso9660/pull/22

    Full Changelog: https://github.com/kdomanski/iso9660/compare/v0.3.2...v0.3.3

    Source code(tar.gz)
    Source code(zip)
  • v0.3.2(Aug 26, 2022)

    What's Changed

    • Use uint32 to decode directory entry length by @aarzilli in https://github.com/kdomanski/iso9660/pull/20
    • add Go 1.19 to the test matrix by @kdomanski in https://github.com/kdomanski/iso9660/pull/21

    New Contributors

    • @aarzilli made their first contribution in https://github.com/kdomanski/iso9660/pull/20

    Full Changelog: https://github.com/kdomanski/iso9660/compare/v0.3.1...v0.3.2

    Source code(tar.gz)
    Source code(zip)
  • v0.2.1(Jul 10, 2021)

  • v0.2.0(Jul 10, 2021)

    • WriteTo now accepts a io.Writer instead of io.WriterAt, allowing e.g. direct streaming of images over network
    • fixed incorrect alignment of items to sectors due to broken padding
    • fixed parent directory entry being identical to current directory (probably only relevant when exporting mountpoint over NFS)
    Source code(tar.gz)
    Source code(zip)
  • v0.2(Jul 13, 2020)

    • WriteTo now accepts a io.Writer instead of io.WriterAt, allowing e.g. direct streaming of images over network
    • fixed incorrect alignment of items to sectors due to broken padding
    • fixed parent directory entry being identical to current directory (probably only relevant when exporting mountpoint over NFS)
    Source code(tar.gz)
    Source code(zip)
Owner
Kamil Domański
"Audaces fortuna iuvat." -- Roman proverb
Kamil Domański
Self-contained Machine Learning and Natural Language Processing library in Go

If you like the project, please ★ star this repository to show your support! ?? A Machine Learning library written in pure Go designed to support rele

NLP Odyssey 1.3k Dec 30, 2022
Go bindings for the snowball libstemmer library including porter 2

Go (golang) bindings for libstemmer This simple library provides Go (golang) bindings for the snowball libstemmer library including the popular porter

Richard Johnson 20 Sep 27, 2022
Cgo binding for icu4c library

About Cgo binding for icu4c C library detection and conversion functions. Guaranteed compatibility with version 50.1. Installation Installation consis

Dmitry Bondarenko 21 Sep 27, 2022
A Go library for performing Unicode Text Segmentation as described in Unicode Standard Annex #29

segment A Go library for performing Unicode Text Segmentation as described in Unicode Standard Annex #29 Features Currently only segmentation at Word

bleve 74 Dec 19, 2022
Cgo binding for Snowball C library

Description Snowball stemmer port (cgo wrapper) for Go. Provides word stem extraction functionality. For more detailed info see http://snowball.tartar

Dmitry Bondarenko 35 Nov 28, 2022
Natural language detection library for Go

Whatlanggo Natural language detection for Go. Features Supports 84 languages 100% written in Go No external dependencies Fast Recognizes not only a la

Abado Jack Mtulla 572 Dec 28, 2022
Go efficient text segmentation and NLP; support english, chinese, japanese and other. Go 语言高性能分词

gse Go efficient text segmentation; support english, chinese, japanese and other. 简体中文 Dictionary with double array trie (Double-Array Trie) to achiev

ego 2.1k Jan 8, 2023
i18n (Internationalization and localization) engine written in Go, used for translating locale strings.

go-localize Simple and easy to use i18n (Internationalization and localization) engine written in Go, used for translating locale strings. Use with go

Miles Croxford 49 Nov 29, 2022
Utilities for working with discrete probability distributions and other tools useful for doing NLP work

GNLP A few structures for doing NLP analysis / experiments. Basics counter.Counter A map-like data structure for representing discrete probability dis

Matt Jones 93 Nov 28, 2022
Read and use word2vec vectors in Go

Introduction This is a package for reading word2vec vectors in Go and finding similar words and analogies. Installation This package can be installed

Daniël de Kok 50 Nov 28, 2022
[UNMANTEINED] Extract values from strings and fill your structs with nlp.

nlp nlp is a general purpose any-lang Natural Language Processor that parses the data inside a text and returns a filled model Supported types int in

Juan Alvarez 379 Nov 24, 2022
Selected Machine Learning algorithms for natural language processing and semantic analysis in Golang

Natural Language Processing Implementations of selected machine learning algorithms for natural language processing in golang. The primary focus for t

James Bowman 386 Dec 25, 2022
Stemmer packages for Go programming language. Includes English, German and Dutch stemmers.

Stemmer package for Go Stemmer package provides an interface for stemmers and includes English, German and Dutch stemmers as sub-packages: porter2 sub

Dmitry Chestnykh 53 Dec 14, 2022
A Go package for n-gram based text categorization, with support for utf-8 and raw text

A Go package for n-gram based text categorization, with support for utf-8 and raw text. To do: write documentation make it faster Keywords: text categ

Peter Kleiweg 69 Nov 28, 2022
Package i18n provides internationalization and localization for your Go applications.

i18n Package i18n provides internationalization and localization for your Go applications. Installation The minimum requirement of Go is 1.16. go get

null 52 Nov 9, 2022
Gopher-translator - A HTTP API that accepts english word or sentences and translates them to Gopher language

Gopher Translator Service An interview assignment project. To see the full assig

Teodor Draganov 0 Jan 25, 2022
A go library for reading and creating ISO9660 images

iso9660 A package for reading and creating ISO9660 Joliet and Rock Ridge extensions are not supported. Examples Extracting an ISO package main import

Kamil Domański 225 Jan 2, 2023
An image server which automatically optimize non webp and avif images to webp and avif images

go-imageserver go-imageserver is an image server which automatically optimize no

DeltaLaboratory 4 Apr 18, 2022
Resize upladed images to s3 bucket with given sizes, and uploades new images back to bucket

Features Resize upladed images to s3 bucket with given sizes, and uploades new images back to bucket Environment Variables IMAGE_SIZES - formax 200x20

null 1 Feb 2, 2022
Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.

Packer Website: https://www.packer.io IRC: #packer-tool on Freenode Mailing list: Google Groups Packer is a tool for building identical machine images

HashiCorp 14.1k Jan 8, 2023