Debugging lua 5.1, lua 5.2 error.
This commit is contained in:
parent
fb77f90959
commit
e8584f47b4
|
@ -60,6 +60,8 @@ end
|
||||||
-- Adding 'mkdir -p' functionality can be considered in the future.
|
-- Adding 'mkdir -p' functionality can be considered in the future.
|
||||||
local function check_directory(directory)
|
local function check_directory(directory)
|
||||||
|
|
||||||
|
print("Enter check_directory()")
|
||||||
|
print(directory)
|
||||||
if directory and type(directory) == "string" then
|
if directory and type(directory) == "string" then
|
||||||
|
|
||||||
-- Fully qualify a "~/" path or a relative path to $HOME. One might argue
|
-- Fully qualify a "~/" path or a relative path to $HOME. One might argue
|
||||||
|
@ -73,15 +75,20 @@ local function check_directory(directory)
|
||||||
directory = string.gsub(os.getenv("HOME"), "/*$", "/") .. directory
|
directory = string.gsub(os.getenv("HOME"), "/*$", "/") .. directory
|
||||||
end
|
end
|
||||||
|
|
||||||
|
print("After first sanitation -- " .. directory)
|
||||||
|
|
||||||
-- Assure that we return exactly one trailing slash
|
-- Assure that we return exactly one trailing slash
|
||||||
directory = string.gsub(directory, '/*$', '/')
|
directory = string.gsub(directory, '/*$', '/')
|
||||||
|
print("After second sanitation -- " .. directory)
|
||||||
|
|
||||||
if gears.filesystem.dir_writable(directory) then
|
if gears.filesystem.dir_writable(directory) then
|
||||||
|
print("Returning directory")
|
||||||
return directory
|
return directory
|
||||||
else
|
else
|
||||||
-- Currently returns nil if the requested directory string cannot be used.
|
-- Currently returns nil if the requested directory string cannot be used.
|
||||||
-- This can be swapped to a silent fallback to the default directory if
|
-- This can be swapped to a silent fallback to the default directory if
|
||||||
-- desired. It is debatable which way is better.
|
-- desired. It is debatable which way is better.
|
||||||
|
print("Returning nil")
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -89,6 +96,7 @@ local function check_directory(directory)
|
||||||
-- No directory argument means use the default. Technically an outrageously
|
-- No directory argument means use the default. Technically an outrageously
|
||||||
-- invalid argument (i.e. not even a string) currently falls back to the
|
-- invalid argument (i.e. not even a string) currently falls back to the
|
||||||
-- default as well.
|
-- default as well.
|
||||||
|
print("Returning default directory")
|
||||||
return get_default_dir()
|
return get_default_dir()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue