Support for love2d 11.1

This commit is contained in:
Ryan Ward 2018-06-09 15:02:20 -04:00
parent c069a981cd
commit 0f134f7465
5 changed files with 29 additions and 5 deletions

View File

@ -41,6 +41,10 @@ true
table: 0x001e3f40 table: 0x001e3f40
``` ```
#Updates/Changes #Updates/Changes
Version 5.0.7
Added:
+ bin.fileExists(name)
[returns true if a file exists]
Version 5.0.6 Version 5.0.6
------------- -------------
Fixed a bunch of bugs and added double support to the library Fixed a bunch of bugs and added double support to the library

View File

@ -1,5 +1,5 @@
bin={} bin={}
bin.Version={5,1,0} bin.Version={5,2,0}
bin.stage='stable' bin.stage='stable'
bin.data='' bin.data=''
bin.t='bin' bin.t='bin'
@ -684,10 +684,30 @@ if love then
temp.filepath=file temp.filepath=file
return temp return temp
end end
function bin.fileExists(name)
return love.filesystem.getInfo(name)
end
function bin:tofile(filename) function bin:tofile(filename)
if not(filename) or self.Stream then return nil end if not(filename) or self.Stream then return nil end
love.filesystem.write(filename,self.data) love.filesystem.write(filename,self.data)
end end
function bin.loadS(path,s,r)
local path = love.filesystem.getSaveDirectory( ).."\\"..path
if type(path) ~= "string" then error("Path must be a string!") end
local f = io.open(path, 'rb')
local content = f:read('*a')
f:close()
return bin.new(content)
end
function bin:tofileS(filename)
if self.stream then return end
local filename = love.filesystem.getSaveDirectory( ).."\\"..filename
print(#self.data,filename)
if not filename then error("Must include a filename to save as!") end
file = io.open(filename, "wb")
file:write(self.data)
file:close()
end
function bin.stream(file) function bin.stream(file)
return bin.newStreamFileObject(love.filesystem.newFile(file)) return bin.newStreamFileObject(love.filesystem.newFile(file))
end end

View File

@ -70,6 +70,10 @@ function io.dirExists(strFolderName)
end end
end end
end end
function bin.fileExists(name)
local f=io.open(name,"r")
if f~=nil then io.close(f) return true else return false end
end
function bin.randomName(n,ext) function bin.randomName(n,ext)
n=n or math.random(7,15) n=n or math.random(7,15)
if ext then if ext then

View File

@ -1,6 +1,2 @@
package.path="?/init.lua;"..package.path package.path="?/init.lua;"..package.path
require("bin") require("bin")
--~ test=bin.load("test.dat")
--~ print(test:getBlock("n",4))
--~ print(test:getBlock("n",4))
--~ tab=test:getBlock("t")

BIN
test.dat

Binary file not shown.