提交 a6efedf8 编写于 作者: V v_zhibsong

change2

上级 9c8c690a
package utils
import (
"errors"
"os"
"path/filepath"
)
......@@ -21,9 +20,18 @@ func FileMove(src string, dst string) (err error) {
if err != nil {
return err
}
if !filepath.IsAbs(dst) && !filepath.IsAbs(src) {
return errors.New(dst + " or " + src + " path is not abs")
var revoke = false
Redirect:
_, err = os.Stat(filepath.Dir(dst))
if err != nil {
err = os.MkdirAll(filepath.Dir(dst), 0755)
if err != nil {
return err
}
if !revoke {
revoke = true
goto Redirect
}
}
// TODO 判断文件夹是否存在,不存在mkdir
return os.Rename(src, dst)
}
\ No newline at end of file
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册