Fix read_file returning extra zero bytes at the end

This commit is contained in:
copy 2015-04-16 01:44:59 +02:00
parent c819dec03f
commit e21ae4a37f
2 changed files with 13 additions and 4 deletions

View file

@ -980,7 +980,7 @@
var filename = this.value.replace(/\/$/, "").split("/");
filename = filename[filename.length - 1] || "root";
dump_file(uint8array.buffer, filename);
dump_file(uint8array, filename);
this.value = "";
}
else

View file

@ -797,10 +797,19 @@ V86Starter.prototype.read_file = function(file, callback)
{
fs.OpenInode(id, undefined);
fs.AddEvent(
id,
function()
id,
function()
{
callback(null, fs.inodedata[id]);
var data = fs.inodedata[id];
if(data)
{
callback(null, data.subarray(0, fs.inodes[id].size));
}
else
{
callback(new FileNotFoundError(), null);
}
}
);
}