Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
Forum Connectivity Upgrade Read more... ×
  • 0
J_E_Mc

filesystem.read is returning 2048 character strings

Question

I need to read files without the filesystem library but it is only returning 2048 characters of the file i am trying to read.

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 1
local fs = component.proxy(component.list("filesystem")())
local handle = fs.open("init.lua")
local buffer = {}
repeat
  local data = fs.read(handle, math.huge)
  table.insert(buffer, data)
until not data
fs.close(handle)
local entire_contents_of_file = table.concat(buffer)

stream handles naturally don't returns ALL of what you ask for, it can take multiple reads. read returns nil when the stream has ended (e.g. eof)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.