Handle forwarding for fs.Create* methods
This commit is contained in:
parent
d218b76994
commit
004182adc8
1 changed files with 47 additions and 0 deletions
|
|
@ -511,7 +511,15 @@ FS.prototype.CreateInode = function() {
|
|||
};
|
||||
|
||||
|
||||
// Note: parentid = -1 for initial root directory.
|
||||
FS.prototype.CreateDirectory = function(name, parentid) {
|
||||
const parent_inode = this.inodes[parentid];
|
||||
if(parentid >= 0 && this.is_forwarder(parent_inode))
|
||||
{
|
||||
const foreign_parentid = parent_inode.foreign_id;
|
||||
const foreign_id = this.follow_fs(parent_inode).CreateDirectory(name, foreign_parentid);
|
||||
return this.create_forwarder(parent_inode.mount_id, foreign_id);
|
||||
}
|
||||
var x = this.CreateInode();
|
||||
x.name = name;
|
||||
x.parentid = parentid;
|
||||
|
|
@ -531,6 +539,13 @@ FS.prototype.CreateDirectory = function(name, parentid) {
|
|||
};
|
||||
|
||||
FS.prototype.CreateFile = function(filename, parentid) {
|
||||
const parent_inode = this.inodes[parentid];
|
||||
if(this.is_forwarder(parent_inode))
|
||||
{
|
||||
const foreign_parentid = parent_inode.foreign_id;
|
||||
const foreign_id = this.follow_fs(parent_inode).CreateFile(filename, foreign_parentid);
|
||||
return this.create_forwarder(parent_inode.mount_id, foreign_id);
|
||||
}
|
||||
var x = this.CreateInode();
|
||||
x.dirty = true;
|
||||
x.name = filename;
|
||||
|
|
@ -547,6 +562,14 @@ FS.prototype.CreateFile = function(filename, parentid) {
|
|||
|
||||
|
||||
FS.prototype.CreateNode = function(filename, parentid, major, minor) {
|
||||
const parent_inode = this.inodes[parentid];
|
||||
if(this.is_forwarder(parent_inode))
|
||||
{
|
||||
const foreign_parentid = parent_inode.foreign_id;
|
||||
const foreign_id =
|
||||
this.follow_fs(parent_inode).CreateNode(filename, foreign_parentid, major, minor);
|
||||
return this.create_forwarder(parent_inode.mount_id, foreign_id);
|
||||
}
|
||||
var x = this.CreateInode();
|
||||
x.name = filename;
|
||||
x.parentid = parentid;
|
||||
|
|
@ -562,6 +585,14 @@ FS.prototype.CreateNode = function(filename, parentid, major, minor) {
|
|||
};
|
||||
|
||||
FS.prototype.CreateSymlink = function(filename, parentid, symlink) {
|
||||
const parent_inode = this.inodes[parentid];
|
||||
if(this.is_forwarder(parent_inode))
|
||||
{
|
||||
const foreign_parentid = parent_inode.foreign_id;
|
||||
const foreign_id =
|
||||
this.follow_fs(parent_inode).CreateSymlink(filename, foreign_parentid, symlink);
|
||||
return this.create_forwarder(parent_inode.mount_id, foreign_id);
|
||||
}
|
||||
var x = this.CreateInode();
|
||||
x.name = filename;
|
||||
x.parentid = parentid;
|
||||
|
|
@ -576,6 +607,14 @@ FS.prototype.CreateSymlink = function(filename, parentid, symlink) {
|
|||
};
|
||||
|
||||
FS.prototype.CreateTextFile = function(filename, parentid, str) {
|
||||
const parent_inode = this.inodes[parentid];
|
||||
if(this.is_forwarder(parent_inode))
|
||||
{
|
||||
const foreign_parentid = parent_inode.foreign_id;
|
||||
const foreign_id =
|
||||
this.follow_fs(parent_inode).CreateTextFile(filename, foreign_parentid, str);
|
||||
return this.create_forwarder(parent_inode.mount_id, foreign_id);
|
||||
}
|
||||
var id = this.CreateFile(filename, parentid);
|
||||
var x = this.inodes[id];
|
||||
var data = this.inodedata[id] = new Uint8Array(str.length);
|
||||
|
|
@ -591,6 +630,14 @@ FS.prototype.CreateTextFile = function(filename, parentid, str) {
|
|||
* @param {Uint8Array} buffer
|
||||
*/
|
||||
FS.prototype.CreateBinaryFile = function(filename, parentid, buffer) {
|
||||
const parent_inode = this.inodes[parentid];
|
||||
if(this.is_forwarder(parent_inode))
|
||||
{
|
||||
const foreign_parentid = parent_inode.foreign_id;
|
||||
const foreign_id =
|
||||
this.follow_fs(parent_inode).CreateBinaryFile(filename, foreign_parentid, buffer);
|
||||
return this.create_forwarder(parent_inode.mount_id, foreign_id);
|
||||
}
|
||||
var id = this.CreateFile(filename, parentid);
|
||||
var x = this.inodes[id];
|
||||
var data = this.inodedata[id] = new Uint8Array(buffer.length);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue