2022-10-02 12:19:00 +03:00
|
|
|
package controllers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"os/user"
|
|
|
|
"strings"
|
|
|
|
|
2023-06-05 18:54:14 +03:00
|
|
|
"github.com/Redume/Starlio/utils"
|
2022-10-23 15:26:51 +03:00
|
|
|
"github.com/gofiber/fiber/v2"
|
2022-10-02 12:19:00 +03:00
|
|
|
)
|
|
|
|
|
2022-10-23 15:26:51 +03:00
|
|
|
var CreateLabel = func(c *fiber.Ctx) error {
|
2022-10-02 12:19:00 +03:00
|
|
|
u, err := user.Current()
|
|
|
|
if err != nil {
|
2023-03-18 16:50:33 +03:00
|
|
|
utils.Logger(err.Error())
|
2022-10-02 12:19:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
dir, err := os.Getwd()
|
|
|
|
if err != nil {
|
2023-03-18 16:50:33 +03:00
|
|
|
utils.Logger(err.Error())
|
2022-10-02 12:19:00 +03:00
|
|
|
}
|
|
|
|
|
2023-06-05 18:54:14 +03:00
|
|
|
dir = strings.Replace(dir, "\\", "\\\\", -1) + "\\Starlio.exe"
|
2022-10-02 12:19:00 +03:00
|
|
|
|
2023-06-05 18:54:14 +03:00
|
|
|
err = utils.CreateLnk(dir, strings.Replace(u.HomeDir, "\\", "\\\\", -1)+"\\Desktop\\Starlio.lnk")
|
2022-10-02 12:19:00 +03:00
|
|
|
if err != nil {
|
2023-03-18 16:50:33 +03:00
|
|
|
utils.Logger(err.Error())
|
2022-10-02 12:19:00 +03:00
|
|
|
}
|
|
|
|
|
2022-10-23 15:26:51 +03:00
|
|
|
utils.Respond(c, utils.Message(true, "The shortcut was successfully created"))
|
|
|
|
return nil
|
2022-10-02 12:19:00 +03:00
|
|
|
}
|