File tree 1 file changed +25
-0
lines changed
1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,31 @@ func CopyFile(src, dst string) (err error) {
37
37
return nil
38
38
}
39
39
40
+ func ClassicCopyFile (src , dst string ) error {
41
+ r , err := os .Open (src )
42
+ if err != nil {
43
+ return fmt .Errorf ("copy %s %s: %v" , src , dst , err )
44
+ }
45
+ defer r .Close ()
46
+
47
+ w , err := os .Create (dst )
48
+ if err != nil {
49
+ return fmt .Errorf ("copy %s %s: %v" , src , dst , err )
50
+ }
51
+
52
+ if _ , err := io .Copy (w , r ); err != nil {
53
+ w .Close ()
54
+ os .Remove (dst )
55
+ return fmt .Errorf ("copy %s %s: %v" , src , dst , err )
56
+ }
57
+
58
+ if err := w .Close (); err != nil {
59
+ os .Remove (dst )
60
+ return fmt .Errorf ("copy %s %s: %v" , src , dst , err )
61
+ }
62
+ return nil
63
+ }
64
+
40
65
// OrgCopyFile copies the source file to the given destination. If any error occurs it
41
66
// returns an error value describing the reason.
42
67
func OrgCopyFile (src , dst string ) (err error ) {
You can’t perform that action at this time.
0 commit comments