@@ -12,6 +12,7 @@ import (
1212)
1313
1414type config struct {
15+ Cleanup bool `yaml:"cleanup" mapstructure:"cleanup"`
1516 Verbose string `yaml:"verbose" mapstructure:"verbose"`
1617}
1718
@@ -25,6 +26,7 @@ func init() {
2526
2627 // Default config
2728 cfg = & config {
29+ Cleanup : false ,
2830 Verbose : "1" ,
2931 }
3032
@@ -45,7 +47,7 @@ func main() {
4547 }
4648
4749 // VLC paths
48- vlcRoamingPath := utl .PathJoin (utl . RoamingPath ( ), "vlc" )
50+ vlcRoamingPath := utl .PathJoin (os . Getenv ( "APPDATA" ), "vlc" )
4951 vlcTmpPath := utl .CreateFolder (app .AppPath , "tmp" )
5052
5153 // Set env vars
@@ -57,17 +59,21 @@ func main() {
5759 dataDvdcssPath := utl .PathJoin (app .DataPath , "dvdcss" )
5860 dataMlXspf := utl .PathJoin (app .DataPath , "ml.xspf" )
5961 dataVlcQtInterface := utl .PathJoin (app .DataPath , "vlc-qt-interface.ini" )
60- roamingDvdcssPath := utl .PathJoin (utl . RoamingPath ( ), "dvdcss" )
62+ roamingDvdcssPath := utl .PathJoin (os . Getenv ( "APPDATA" ), "dvdcss" )
6163 roamingMlXspf := utl .PathJoin (vlcRoamingPath , "ml.xspf" )
6264 roamingVlcQtInterface := utl .PathJoin (vlcRoamingPath , "vlc-qt-interface.ini" )
6365
6466 // Copy existing files from data to roaming folder for the current user
6567 utl .CreateFolder (vlcRoamingPath )
6668 if _ , err := os .Stat (dataMlXspf ); err == nil {
67- utl .CopyFile (dataMlXspf , roamingMlXspf )
69+ if err := utl .CopyFile (dataMlXspf , roamingMlXspf ); err != nil {
70+ log .Error ().Err (err ).Msgf ("Cannot copy %s" , dataMlXspf )
71+ }
6872 }
6973 if _ , err := os .Stat (dataVlcQtInterface ); err == nil {
70- utl .CopyFile (dataVlcQtInterface , roamingVlcQtInterface )
74+ if err := utl .CopyFile (dataVlcQtInterface , roamingVlcQtInterface ); err != nil {
75+ log .Error ().Err (err ).Msgf ("Cannot copy %s" , dataVlcQtInterface )
76+ }
7177 }
7278
7379 // Handle reg key
@@ -99,15 +105,21 @@ func main() {
99105 }
100106 }
101107
102- // Export registry key
103- os .Remove (regFile )
108+ // Export reg key
104109 if err := regKey .Export (regFile ); err != nil {
105- log .Warn ().Err (err ).Msg ("Cannot export registry key" )
110+ log .Error ().Err (err ).Msg ("Cannot export registry key" )
106111 }
107112
108- // Remove tmp and roaming path
109- os .RemoveAll (vlcTmpPath )
110- os .RemoveAll (vlcRoamingPath )
113+ // Cleanup
114+ if cfg .Cleanup {
115+ utl .Cleanup ([]string {
116+ vlcRoamingPath ,
117+ vlcTmpPath ,
118+ })
119+ if err := regKey .Delete (true ); err != nil {
120+ log .Error ().Err (err ).Msg ("Cannot remove registry key" )
121+ }
122+ }
111123 }()
112124
113125 // Launch
0 commit comments