mirror of
https://github.com/ipfs/kubo.git
synced 2025-08-06 19:44:01 +08:00
24 lines
452 B
Go
24 lines
452 B
Go
package cmdenv
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
files "github.com/ipfs/go-ipfs-files"
|
|
)
|
|
|
|
// GetFileArg returns the next file from the directory or an error
|
|
func GetFileArg(it files.DirIterator) (files.File, error) {
|
|
if !it.Next() {
|
|
err := it.Err()
|
|
if err == nil {
|
|
err = fmt.Errorf("expected a file argument")
|
|
}
|
|
return nil, err
|
|
}
|
|
file := files.FileFromEntry(it)
|
|
if file == nil {
|
|
return nil, fmt.Errorf("file argument was nil")
|
|
}
|
|
return file, nil
|
|
}
|