()
| 18 | const SearchPathRegistry = "Search Path" |
| 19 | |
| 20 | func updateGlobalLibraryPath() { |
| 21 | ideVersion := bossRegistry.GetCurrentDelphiVersion() |
| 22 | if ideVersion == "" { |
| 23 | msg.Err("Version not found for path %s", env.GlobalConfiguration.DelphiPath) |
| 24 | } |
| 25 | library, err := registry.OpenKey(registry.CURRENT_USER, consts.RegistryBasePath+ideVersion+`\Library`, registry.ALL_ACCESS) |
| 26 | |
| 27 | if err != nil { |
| 28 | msg.Err(`Registry path` + consts.RegistryBasePath + ideVersion + `\Library not exists`) |
| 29 | return |
| 30 | } |
| 31 | |
| 32 | libraryInfo, err := library.Stat() |
| 33 | if err != nil { |
| 34 | msg.Err(err.Error()) |
| 35 | return |
| 36 | } |
| 37 | platforms, err := library.ReadSubKeyNames(int(libraryInfo.SubKeyCount)) |
| 38 | if err != nil { |
| 39 | msg.Err("No platform found for delphi " + ideVersion) |
| 40 | return |
| 41 | } |
| 42 | |
| 43 | for _, platform := range platforms { |
| 44 | delphiPlatform, err := registry.OpenKey(registry.CURRENT_USER, consts.RegistryBasePath+ideVersion+`\Library\`+platform, registry.ALL_ACCESS) |
| 45 | utils.HandleError(err) |
| 46 | paths, _, err := delphiPlatform.GetStringValue(SearchPathRegistry) |
| 47 | if err != nil { |
| 48 | msg.Debug("Failed to update library path from platform %s with delphi %s", platform, ideVersion) |
| 49 | continue |
| 50 | } |
| 51 | |
| 52 | splitPaths := strings.Split(paths, ";") |
| 53 | newSplitPaths := GetNewPaths(splitPaths, true, env.GetCurrentDir()) |
| 54 | newPaths := strings.Join(newSplitPaths, ";") |
| 55 | err = delphiPlatform.SetStringValue(SearchPathRegistry, newPaths) |
| 56 | utils.HandleError(err) |
| 57 | } |
| 58 | |
| 59 | } |
no test coverage detected