Merge pull request #941 from harshavardhana/pr_out_cast_url_should_in_typec_should_verify_target_is_dir_or_exit_if_doesn_t_exist_let_it_create_one

In casttypeC should verify target is Dir() or exit, if doesn't exist let it create one
This commit is contained in:
Harshavardhana
2015-07-26 21:26:07 +00:00
+5 -2
View File
@@ -168,8 +168,11 @@ func checkCastSyntaxTypeC(srcURL string, tgtURLs []string) {
console.Fatalf("Source ‘%s’ is not a folder. %s\n", stripRecursiveURL(srcURL), NewIodine(iodine.New(err, nil)))
}
for _, tgtURL := range tgtURLs {
if !isTargetURLDir(tgtURL) {
console.Fatalf("One of the target ‘%s’ is not a folder. cannot have mixtures of directories and files while copying directories recursively. %s\n", tgtURL, NewIodine(iodine.New(errInvalidArgument{}, nil)))
_, content, err := url2Stat(tgtURL)
if err == nil {
if !content.Type.IsDir() {
console.Fatalf("One of the target ‘%s’ is not a folder. cannot have mixtures of directories and files while copying directories recursively. %s\n", tgtURL, NewIodine(iodine.New(errInvalidArgument{}, nil)))
}
}
}
}