lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Apr 13, 2012, at 12:53 AM, Matthew Wild wrote:

> I also wrote such a module for Squish (to emulate file I/O on packed
> resources): http://code.matthewwild.co.uk/squish/file/14f827efadf2/vio/vio.lua

Thanks for sharing :)

> It doesn't support the 5.2 API either, but shouldn't be hard to extend to do so.

Right. 

At first glance, it doesn't seem to mimic the file:read (···) API though, even the 5.1, as it seems to ignore all the varargs, excepts the first one.

For example:

print( vio.open( 'foobar' ):read( 3, 3 ) )

> foo

I would expect 'foo' and 'bar', considering that there are two formats specified.

Ah, and, yes, it also drops the last empty line:

local aString =
[[

foo

bar

baz

]]

local aCount = 0

for aLine in vio.open( aString ):lines() do
  aCount = aCount + 1
  print( aCount, aLine )
end

> 1	
> 2	foo
> 3	
> 4	bar
> 5	
> 6	baz