1. Marek Kubica
  2. zoetrope09

Commits

Geraldo Ramos  committed 7137ebf

Fix storafe.lu. Don't know why pcall always returns true.

  • Participants
  • Parent commits 71d4ed1
  • Branches default

Comments (0)

Files changed (1)

File zoetrope/utils/storage.lua

View file
  • Ignore whitespace
 -- retains your data across a single app session. If you want to be notified
 -- when errors occur, check the <save()> and <load()> methods' arguments.
 --
--- Make sure to set your app's identity in conf.lua, so that your 
+-- Make sure to set your app's identity in conf.lua, so that your
 -- files don't clobber some other app's. See https://love2d.org/wiki/Config_Files
 -- for details.
 --
 	-- Arguments:
 	--		values - table of values to set before saving, optional -- these
 	--		act in addition to anything previously set in the <data>
-	--		ignoreError - silently ignore any errors saving, defaults to true 
+	--		ignoreError - silently ignore any errors saving, defaults to true
 	--
 	-- Returns:
 	--		nothing
 	load = function (self, ignoreError)
 		if ignoreError ~= false then ignoreError = true end
 
-		local ok, data = pcall(love.filesystem.read, self.filename)
+		local ok = love.filesystem.isFile(self.filename)
 
 		if ok then
-			ok, self.data = pcall(loadstring('return ' .. data))
-			
+			ok, self.data = pcall(loadstring('return ' .. love.filesystem.read(self.filename)))
+
 			if not ok then
 				if ignoreError then
 					self.data = {}
 			end
 		else
 			if not ignoreError then
-				error("could not load storage from disk: " .. data)
+				error("could not load storage from disk: " .. love.filesystem.read(self.filename))
 			end
 		end