Makes sure folders are created when files are added

Added some comments
This commit is contained in:
Caleb Gardner
2021-02-27 00:49:40 -06:00
parent 65bc4a5d78
commit b6fbd63ba4
3 changed files with 32 additions and 25 deletions
-20
View File
@@ -3,34 +3,14 @@ package squashfs
import (
"errors"
"io"
"io/fs"
"math"
"time"
)
func (w *Writer) fixFolders() error {
for folder := range w.structure {
if folder == "/" || w.Contains(folder) {
continue
}
err := w.AddFolderTo(folder, fs.ModePerm)
if err != nil {
return err
}
}
return nil
}
//WriteTo attempts to write the archive to the given io.Writer.
//Folder that aren't present (such as if you add a file at /folder/file, but not the folder /folder)
//are added with full permission (777).
//
//Not working. Yet.
func (w *Writer) WriteTo(write io.Writer) (int64, error) {
err := w.fixFolders()
if err != nil {
return 0, err
}
if w.BlockSize > 1048576 {
w.BlockSize = 1048576
} else if w.BlockSize < 4096 {