----------------------------------------
-- returns file as ByteArray
----------------------------------------
on file_get_bytes (tFile)
fp = xtra("fileIO").new()
if not objectP(fp) then return -1
fp.openFile(tFile, 1)
err = fp.status()
if (err) then return err
data = fp.readByteArray(fp.getLength())
fp.closeFile()
fp = 0
return data
end
----------------------------------------
-- saves ByteArray to file
----------------------------------------
on file_put_bytes (tFile, tByteArray, intOffset, intLen)
if voidP(intOffset) then intOffset=1
if voidP(intLen) then intLen=tByteArray.length
fp = xtra("fileIO").new()
if not objectP(fp) then return -1
fp.openFile(tFile, 1)
err = fp.status()
if not (err) then fp.delete()
else if (err and not (err = -37)) then return err
fp.createFile(tFile)
err = fp.status()
if (err) then return err
fp.openFile(tFile, 2)
err = fp.status()
if (err) then return err
ok = fp.writeByteArray(tByteArray, intOffset, intLen)
fp.closeFile()
fp=0
return ok
end