why did i call the function[love.filesystem.createDirectory] failed, the following show code.
Code: Select all
logDir = "./log"
logPath = "./log/sad.log"
function love.load()
loadStatus, errString = initLog()
end
function love.draw()
if (false == loadStatus) then
love.graphics.printf("progress load fail:\r\n \t" .. errString, 0, 0, 1024, "left")
end
end
function love.update(dt)
end
function initLog()
cwd = love.filesystem.getWorkingDirectory()
if ("/" ~= string.sub(cwd, -1, -1)) then
cwd = cwd .. "/"
end
if ("./" == string.sub(logDir, 1, 2)) then
logDir = cwd .. string.sub(logDir, 3)
end
if (nil == love.filesystem.getInfo(logDir, "directory")) then
if (false == love.filesystem.createDirectory(logDir)) then
return false, "can not create directory[" .. logDir .. " ]"
end
end
if ("./" == string.sub(logPath, 1, 2)) then
logPath = cwd .. string.sub(logPath, 3)
end
if (nil == love.filesystem.getInfo(logPath, "file")) then
logFile = love.filesystem.newFile(logPath)
if (false == logFile:open("r")) then
return false, "can not create file[" .. logPath .. " ]"
end
end
end