Skip to content

Commit

Permalink
Used correct path separation
Browse files Browse the repository at this point in the history
  • Loading branch information
curlpipe committed Oct 31, 2024
1 parent 038a9fd commit b39a325
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/plugin/bootstrap.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
-- Bootstrap code provides plug-ins and configuration with APIs and other utilities
home = os.getenv("HOME") or os.getenv("USERPROFILE")
path_sep = package.config:sub(1,1)

if package.config:sub(1,1) == "\\" then
if path_sep == "\\" then
plugin_path = home .. "\\ox"
else
plugin_path = home .. "/.config/ox"
Expand Down
16 changes: 8 additions & 8 deletions src/plugin/plugin_manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function plugin_manager:plugin_downloaded(plugin)
local base = plugin .. ".lua"
local path_cross = base
local path_unix = home .. "/.config/ox/" .. base
local path_win = home .. "/ox/" .. base
local path_win = home .. "\\ox\\" .. base
local installed = file_exists(path_cross) or file_exists(path_unix) or file_exists(path_win)
-- Return true if plug-ins are built in
local builtin = self:plugin_is_builtin(plugin)
Expand All @@ -135,7 +135,7 @@ function plugin_manager:download_plugin(plugin)
return "Plug-in not found in repository"
end
-- Find the path to download it to
local path = plugin_path .. "/" .. plugin .. ".lua"
local path = plugin_path .. path_sep .. plugin .. ".lua"
-- Create the plug-in directory if it doesn't already exist
if not dir_exists(plugin_path) then
if shell:run("mkdir " .. plugin_path) ~= 0 then
Expand All @@ -155,8 +155,8 @@ end
-- Remove a plug-in from the configuration directory
function plugin_manager:remove_plugin(plugin)
-- Obtain the path
local path = package.config:sub(1,1) == '\\' and home .. "/ox" or home .. "/.config/ox"
path = path .. "/" .. plugin .. ".lua"
local path = path_sep == '\\' and home .. "\\ox" or home .. "/.config/ox"
path = path .. path_sep .. plugin .. ".lua"
-- Remove the file
local success, err = os.remove(path)
if not success then
Expand All @@ -169,7 +169,7 @@ end
-- Verify whether the plug-in is being imported in the configuration file
function plugin_manager:plugin_in_config(plugin)
-- Find the configuration file path
local path = home .. "/.oxrc"
local path = home .. path_sep .. ".oxrc"
-- Open the document
local file = io.open(path, "r")
if not file then return false end
Expand All @@ -188,7 +188,7 @@ end

-- Append the plug-in import code to the configuration file so it is loaded
function plugin_manager:append_to_config(plugin)
local path = home .. "/.oxrc"
local path = home .. path_sep .. ".oxrc"
local file = io.open(path, "a")
if not file then
return "Failed to open configuration file"
Expand All @@ -201,7 +201,7 @@ end
-- Remove plug-in import code from the configuration file
function plugin_manager:remove_from_config(plugin)
-- Find the configuration file path
local path = home .. "/.oxrc"
local path = home .. path_sep .. ".oxrc"
-- Open the configuration file
local file = io.open(path, "r")
if not file then
Expand All @@ -228,7 +228,7 @@ end
-- Find the local version of a plug-in that is installed
function plugin_manager:local_version(plugin)
-- Open the file
local file = io.open(plugin_path .. "/" .. plugin .. ".lua", "r")
local file = io.open(plugin_path .. path_sep .. plugin .. ".lua", "r")
if not file then return nil end
-- Attempt to find a version indicator in the first 10 lines of the file
local version = nil
Expand Down

0 comments on commit b39a325

Please sign in to comment.