diff --git a/connect.go b/connect.go index 959f1bd..ed8163b 100644 --- a/connect.go +++ b/connect.go @@ -68,9 +68,14 @@ func NewConnection(config *AppConfig) (*Connection, error) { c.UseStdout = config.UseStdout c.Yes = config.Yes c.rate = config.Rate + + stat, _ := os.Stdin.Stat() + if (stat.Mode() & os.ModeCharDevice) == 0 { + config.File = "stdin" + } if len(config.File) > 0 { if config.File == "stdin" { - f, err := ioutil.TempFile(os.TempDir(), "croc-stdin-") + f, err := ioutil.TempFile(".", "croc-stdin-") if err != nil { return c, err } diff --git a/main.go b/main.go index 8e46dfd..bd91b01 100644 --- a/main.go +++ b/main.go @@ -22,7 +22,7 @@ type AppConfig struct { UseStdout bool `yaml:"stdout" flagName:"stdout" flagSName:"o" flagDescribe:"Use stdout" default:"false"` Yes bool `yaml:"yes" flagName:"yes" flagSName:"y" flagDescribe:"Automatically accept file" default:"false"` Server string `yaml:"server" flagName:"server" flagSName:"l" flagDescribe:"Address of relay server" default:"cowyo.com"` - File string `yaml:"send" flagName:"send" flagSName:"s" flagDescribe:"File to send (\"stdin\" to read from stdin)" default:""` + File string `yaml:"send" flagName:"send" flagSName:"s" flagDescribe:"File to send default:""` Path string `yaml:"save" flagName:"save" flagSName:"p" flagDescribe:"Path to save to" default:""` Code string `yaml:"code" flagName:"code" flagSName:"c" flagDescribe:"Use your own code phrase" default:""` Rate int `yaml:"rate" flagName:"rate" flagSName:"R" flagDescribe:"Throttle down to speed in kbps" default:"1000000"`