Fix fs.GetFullPath and fs.FindPreviousID forwarding

Use this.GetInode(idx) to get metadata such as filename and size.
Use this.inodes to navigate about the filesystem graph
This commit is contained in:
Ernest Wong 2018-08-11 11:49:07 +12:00 committed by Fabian
commit 3fcdf62eef

View file

@ -715,15 +715,16 @@ FS.prototype.GetFullPath = function(idx) {
var path = "";
while(idx != 0) {
path = "/" + this.inodes[idx].name + path;
idx = this.inodes[idx].parentid;
path = "/" + this.GetInode(idx).name + path;
idx = this.GetParent(idx);
}
return path.substring(1);
};
// no double linked list. So, we need this
FS.prototype.FindPreviousID = function(idx) {
var inode = this.GetInode(idx);
var inode = this.inodes[idx];
dbg_assert(this.should_be_linked(inode), "Filesystem FindPreviousID assumes linked inode");
var id = this.inodes[inode.parentid].firstid;
while(id != -1) {
if (this.inodes[id].nextid == idx) return id;