Skip to content

Commit

Permalink
v1.0.4; Fix compatibility issue by moving from basic Lua IO functions…
Browse files Browse the repository at this point in the history
… to 100% Love filesystem functions
  • Loading branch information
Walter Stanish committed Oct 2, 2016
1 parent 1373bcd commit d146bf8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ The latest code can always be found at [Github](https://github.com/globalcitizen

## News

* 2016-10-02: [v1.0.4](https://github.com/globalcitizen/svglover/releases/tag/v1.0.4) released!
- Fix compatibility issue by moving from basic Lua IO functions to 100% Love filesystem functions

* 2016-10-02: [v1.0.3](https://github.com/globalcitizen/svglover/releases/tag/v1.0.3) released!
- Allow automatic / transparent loading of gzip compressed SVG files
- Add zoom feature
Expand Down
26 changes: 12 additions & 14 deletions svglover.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,18 @@ svglover_onscreen_svgs = {}
-- load an svg and return it as a slightly marked up table
-- markup includes resolution detection
function svglover_load(svgfile)
-- validate input
-- file exists?
local fh = io.open(svgfile, "rb")
if not fh then
print("FATAL: file does not exist: '" .. svgfile .. "'")
os.exit()
end
-- file is a roughly sane size?
local size = fh:seek("end")
fh:seek("set", current)
if size == nil or size < 10 or size > 500000 then
print("FATAL: file is not an expected size (0-500000 bytes): '" .. svgfile .. "'")
os.exit()
end
-- validate input
-- file exists?
if not love.filesystem.exists(svgfile) then
print("FATAL: file does not exist: '" .. svgfile .. "'")
os.exit()
end
-- file is a roughly sane size?
local size = love.filesystem.getSize(svgfile)
if size == nil or size < 10 or size > 500000 then
print("FATAL: file is not an expected size (0-500000 bytes): '" .. svgfile .. "'")
os.exit()
end

-- initialize return structure
local svg = {height=0,height=0,drawcommands=''}
Expand Down

0 comments on commit d146bf8

Please sign in to comment.