| 16 | ) |
| 17 | |
| 18 | func Init() (err error) { |
| 19 | log.Debug("initializing models.Paths from %s ...", Path) |
| 20 | |
| 21 | Paths = map[string]string{ |
| 22 | "idents": filepath.Join(Path, "idents"), |
| 23 | "shells": filepath.Join(Path, "shells"), |
| 24 | "plugins": filepath.Join(Path, "plugins"), |
| 25 | } |
| 26 | |
| 27 | for name, path := range Paths { |
| 28 | if Paths[name], err = fs.Expand(path); err != nil { |
| 29 | return fmt.Errorf("error while expanding path '%s': %s", path, err) |
| 30 | } else { |
| 31 | path = Paths[name] |
| 32 | } |
| 33 | |
| 34 | log.Debug("models.Paths[%s] = %s", name, path) |
| 35 | if !fs.Exists(path) { |
| 36 | log.Info("creating folder %s ...", path) |
| 37 | if err = os.MkdirAll(path, os.ModePerm); err != nil { |
| 38 | return fmt.Errorf("error while creating path '%s': %s", path, err) |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | return |
| 44 | } |