kdomanski / iso9660 Goto Github PK
View Code? Open in Web Editor NEWA go library for reading and creating ISO9660 images
License: BSD 2-Clause "Simplified" License
A go library for reading and creating ISO9660 images
License: BSD 2-Clause "Simplified" License
The RRIP defines the following System Use Entries:
PX
POSIX file attributesPN
POSIX device numberSL
Symbolic linkNM
Alternate nameCL
Child linkPL
Parent linkRE
Relocated directoryTF
Time stamp(s) for a fileSF
File data in sparse file formatLine 104 in 880de9c
runtime error: index out of range [1] with length 1
maybe
if len(splitFileIdentifier) == 0 {
return splitFileIdentifier[0]
}
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.
This doesn't seem possible given
Lines 520 to 524 in 880de9c
I might be missing something though ...
If not, is this something you would consider as an enhancement?
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?
Thanks for making this great tool. Seems like currently no such an API to file last modified time when they are added into ISO. Could you please tell me if it is limitation on ISO file format, or one missing feature? If later one, do you have any plan to add it?
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)
Thanks for creating this library!
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)
}
}
As anyone has been able to create a folder within the .iso file, mount the .iso, and access that folder using Windows?
Would it be possible to have a flag on the file writer so that if set, any files we write are not renamed to follow the correct standard?
I am working with legacy applications that use the incorrect naming convention and will reference files on the ISO which don't exist because of the file rename. Having to change the installer and all associated files to follow the new convention would be a painful process.
I am trying to extract a ubuntu iso image (from https://releases.ubuntu.com/22.04/) to a temporary folder. Below is the code I am using
func ExtractISO() error {
temp, err := os.MkdirTemp("temp", "ubuntu-")
if err != nil {
return fmt.Errorf("creating temp dir: %s", err)
}
iso_file, err := os.Open("ubuntu-22.04.3-live-server-amd64.iso")
if err != nil {
return fmt.Errorf("opening iso file: %s", err)
}
defer iso_file.Close()
if err = util.ExtractImageToDirectory(iso_file, temp); err != nil {
return fmt.Errorf("extracting image: %s", err)
}
return nil
}
I am getting hit with an error extracting image: open temp/ubuntu-4020240902/boot/grub/i386-pc/zstd.mod: invalid argument
I am not sure what the reason is, maybe the - in i386-pc?
EDIT: I just realized this might also be a permissions issue
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)
}
}
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
?
Not sure if this is in scope of the project, however inorder to listen to podcasts in the car I have created:
https://github.com/arran4/podcast-cdr-manager
It successfully creates an ISO. My linux machine can read it:
However when I put it in the car:
( TOYOTA YARIS, RADIO/CD/DVD/SAT/TV, CD/MP3 PLAYER, NCP9#, SINGLE, 10/05-06/16 )
However when I burn the mp3s with K3b it works fine. (Default settings. It works, so it's not a CDRW issue.)
Testing it with just ISO9660 with K3b:
That seemed to work. So I suspect this might be an ISO issue OR an issue with how I'm using the library?
I want to add 2 files and one directory, is that not possible?
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.2
etc, so that other project can use tag in go.mod.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.