Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Using FilesFromDisk() for compressing files to root of archive #331

@nicola-spb

Description

@nicola-spb

What would you like to have changed?

I wanna use archiver.FilesFromDisk for archiving files from folder to root of archive like this:

files, err := archiver.FilesFromDisk(nil, map[string]string{
	"/path/on/disk/folder/*":    "", // contents added recursively to root of archive without "folder"
})

Why is this feature a useful, necessary, and/or important addition to this project?

I think it is useful feature.

What alternatives are there, or what are you doing in the meantime to work around the lack of this feature?

Without this feature I need to write:

fileNames := make(map[string]string)
err := filepath.Walk(sourceDir, func(path string, info os.FileInfo, err error) error {
	if err != nil {
		return err
	}

	// skip root directory
	if path == sourceDir {
		return nil
	}

	fileNames[path] = ""
	return nil
})

if err != nil {
	return err
}

// map files on disk to their paths in the archive
files, err := archiver.FilesFromDisk(nil, fileNames)

Please link to any relevant issues, pull requests, or other discussions.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions