mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-12-02 03:37:46 +08:00
[ADD] add debug print
This commit is contained in:
parent
46bdeda627
commit
b278ea634d
@ -570,28 +570,37 @@ func Unzip(archive, target string) error {
|
|||||||
func CopyFile(source, target string) error {
|
func CopyFile(source, target string) error {
|
||||||
sfi, err := os.Stat(source)
|
sfi, err := os.Stat(source)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("===err1", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
elem := reflect.ValueOf(sfi.Sys()).Elem()
|
elem := reflect.ValueOf(sfi.Sys()).Elem()
|
||||||
uid := elem.FieldByName("Uid").Uint()
|
uid := elem.FieldByName("Uid").Uint()
|
||||||
gid := elem.FieldByName("Gid").Uint()
|
gid := elem.FieldByName("Gid").Uint()
|
||||||
|
fmt.Println("file %s uid %d gid %s", source, uid, gid)
|
||||||
|
|
||||||
sf, err := directio.OpenFile(source, os.O_RDONLY, 0)
|
sf, err := directio.OpenFile(source, os.O_RDONLY, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("===err2", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer sf.Close()
|
defer sf.Close()
|
||||||
tf, err := directio.OpenFile(target, os.O_RDONLY|os.O_CREATE|os.O_WRONLY, sfi.Mode())
|
tf, err := directio.OpenFile(target, os.O_RDONLY|os.O_CREATE|os.O_WRONLY, sfi.Mode())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("===err3", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer tf.Close()
|
defer tf.Close()
|
||||||
_, err = io.Copy(tf, sf)
|
_, err = io.Copy(tf, sf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("===err4", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.Chown(target, int(uid), int(gid)); err != nil {
|
if err := os.Chown(target, int(uid), int(gid)); err != nil {
|
||||||
|
fmt.Println("===err5", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user