Rename Load to ReadFile, make args.PATH default to cwd

This commit is contained in:
lordwelch 2017-09-22 18:47:50 -06:00
parent 3b0200fe51
commit 678d618ffa
2 changed files with 7 additions and 2 deletions

View File

@ -28,8 +28,13 @@ func main() {
PATH string `arg:"-P,help:Path to torrent files"`
}
)
arg.MustParse(&args)
if len(args.PATH < 1) {
args.PATH, _ = os.Getwd()
}
unselectedDir = filepath.Clean(args.PATH + "/unselected/")
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
url := strings.TrimSpace(scanner.Text())
@ -50,7 +55,7 @@ func process(torrentFile string) *MediaTorrent {
vt *MediaTorrent = new(MediaTorrent)
)
f, _ := os.OpenFile(torrentFile, os.O_RDONLY, 755)
mt.Load(f)
mt.ReadFile(f)
fmt.Printf("%+v\n", mt)
vt.Torrent = NewTorrent(*mt)
vt.Parse(vt.Name)

View File

@ -66,7 +66,7 @@ func NewTorrent(mt MetaTorrent) (T Torrent) {
return T
}
func (Mt *MetaTorrent) Load(r io.Reader) error {
func (Mt *MetaTorrent) ReadFile(r io.Reader) error {
return bencode.NewDecoder(r).Decode(Mt)
}