github.com/simpleiot/simpleiot@v0.18.3/assets/files/files.go (about) 1 package files 2 3 import ( 4 "os" 5 ) 6 7 // FileUpdate describes a file that gets updated 8 type FileUpdate struct { 9 Dest string 10 Perm os.FileMode 11 Callback func() 12 } 13 14 // UpdateFiles updates various files in the system 15 func UpdateFiles(_ string) error { 16 return nil 17 18 // FIXME, this needs ported to go-embed 19 20 /* 21 fileUpdates := []FileUpdate{ 22 // currently not using this, saving for future use 23 } 24 25 for _, fu := range fileUpdates { 26 f := path.Base(fu.Dest) 27 fBytes := Asset(path.Join("/", f)) 28 if fBytes == nil { 29 return fmt.Errorf("Error opening update for: %v", f) 30 } 31 32 fOldBytes, _ := ioutil.ReadFile(fu.Dest) 33 if bytes.Compare(fBytes, fOldBytes) != 0 { 34 fmt.Println("Updating: ", fu.Dest) 35 err := ioutil.WriteFile(fu.Dest, fBytes, fu.Perm) 36 if err != nil { 37 return fmt.Errorf("Error updating: %v", fu.Dest) 38 } 39 if fu.Callback != nil { 40 fu.Callback() 41 } 42 } 43 } 44 45 return nil 46 */ 47 }