From 0f134f746540822bf66e8c6ab8fe063391e7d70a Mon Sep 17 00:00:00 2001 From: Ryan Ward Date: Sat, 9 Jun 2018 15:02:20 -0400 Subject: [PATCH] Support for love2d 11.1 --- README.md | 4 ++++ bin/init.lua | 22 +++++++++++++++++++++- bin/support/utils.lua | 4 ++++ crypto.lua | 4 ---- test.dat | Bin 478 -> 478 bytes 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8703461..435c77c 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,10 @@ true table: 0x001e3f40 ``` #Updates/Changes +Version 5.0.7 +Added: ++ bin.fileExists(name) +[returns true if a file exists] Version 5.0.6 ------------- Fixed a bunch of bugs and added double support to the library diff --git a/bin/init.lua b/bin/init.lua index 3728c6f..6db7f05 100644 --- a/bin/init.lua +++ b/bin/init.lua @@ -1,5 +1,5 @@ bin={} -bin.Version={5,1,0} +bin.Version={5,2,0} bin.stage='stable' bin.data='' bin.t='bin' @@ -684,10 +684,30 @@ if love then temp.filepath=file return temp end + function bin.fileExists(name) + return love.filesystem.getInfo(name) + end function bin:tofile(filename) if not(filename) or self.Stream then return nil end love.filesystem.write(filename,self.data) 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) return bin.newStreamFileObject(love.filesystem.newFile(file)) end diff --git a/bin/support/utils.lua b/bin/support/utils.lua index 957b168..cc6efa6 100644 --- a/bin/support/utils.lua +++ b/bin/support/utils.lua @@ -70,6 +70,10 @@ function io.dirExists(strFolderName) 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) n=n or math.random(7,15) if ext then diff --git a/crypto.lua b/crypto.lua index cc07f93..fc8f815 100644 --- a/crypto.lua +++ b/crypto.lua @@ -1,6 +1,2 @@ package.path="?/init.lua;"..package.path require("bin") ---~ test=bin.load("test.dat") ---~ print(test:getBlock("n",4)) ---~ print(test:getBlock("n",4)) ---~ tab=test:getBlock("t") diff --git a/test.dat b/test.dat index 64cb99990a47051dce9bae4a7eac5cb17f87c52f..41784530b9aa63104d1b2a207f403fea6095fb9c 100644 GIT binary patch delta 36 mcmcb|e2