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 64cb999..4178453 100644 Binary files a/test.dat and b/test.dat differ