Review fixes
This commit is contained in:
parent
6e16f86208
commit
3c5a5ef7fa
|
@ -7307,6 +7307,8 @@ define('src/constants',['require'],function(require) {
|
||||||
var O_APPEND = 'APPEND';
|
var O_APPEND = 'APPEND';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
FILE_SYSTEM_NAME: 'local',
|
||||||
|
|
||||||
FILE_STORE_NAME: 'files',
|
FILE_STORE_NAME: 'files',
|
||||||
|
|
||||||
IDB_RO: 'readonly',
|
IDB_RO: 'readonly',
|
||||||
|
@ -7352,7 +7354,8 @@ define('src/constants',['require'],function(require) {
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
define('src/providers/indexeddb',['require','src/constants','src/constants','src/constants'],function(require) {
|
define('src/providers/indexeddb',['require','src/constants','src/constants','src/constants','src/constants'],function(require) {
|
||||||
|
var FILE_SYSTEM_NAME = require('src/constants').FILE_SYSTEM_NAME;
|
||||||
var FILE_STORE_NAME = require('src/constants').FILE_STORE_NAME;
|
var FILE_STORE_NAME = require('src/constants').FILE_STORE_NAME;
|
||||||
|
|
||||||
var indexedDB = window.indexedDB ||
|
var indexedDB = window.indexedDB ||
|
||||||
|
@ -7426,7 +7429,7 @@ define('src/providers/indexeddb',['require','src/constants','src/constants','src
|
||||||
|
|
||||||
|
|
||||||
function IndexedDB(name) {
|
function IndexedDB(name) {
|
||||||
this.name = name || "local";
|
this.name = name || FILE_SYSTEM_NAME;
|
||||||
this.db = null;
|
this.db = null;
|
||||||
}
|
}
|
||||||
IndexedDB.isSupported = function() {
|
IndexedDB.isSupported = function() {
|
||||||
|
@ -7479,7 +7482,8 @@ define('src/providers/indexeddb',['require','src/constants','src/constants','src
|
||||||
return IndexedDB;
|
return IndexedDB;
|
||||||
});
|
});
|
||||||
|
|
||||||
define('src/providers/memory',['require'],function(require) {
|
define('src/providers/memory',['require','src/constants'],function(require) {
|
||||||
|
var FILE_SYSTEM_NAME = require('src/constants').FILE_SYSTEM_NAME;
|
||||||
|
|
||||||
function MemoryContext(db, readOnly) {
|
function MemoryContext(db, readOnly) {
|
||||||
this.readOnly = readOnly;
|
this.readOnly = readOnly;
|
||||||
|
@ -7515,7 +7519,7 @@ define('src/providers/memory',['require'],function(require) {
|
||||||
|
|
||||||
|
|
||||||
function Memory(name) {
|
function Memory(name) {
|
||||||
this.name = name || "local";
|
this.name = name || FILE_SYSTEM_NAME;
|
||||||
this.db = {};
|
this.db = {};
|
||||||
}
|
}
|
||||||
Memory.isSupported = function() {
|
Memory.isSupported = function() {
|
||||||
|
@ -7523,7 +7527,6 @@ define('src/providers/memory',['require'],function(require) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Memory.prototype.open = function(callback) {
|
Memory.prototype.open = function(callback) {
|
||||||
var that = this;
|
|
||||||
callback(null, true);
|
callback(null, true);
|
||||||
};
|
};
|
||||||
Memory.prototype.getReadOnlyContext = function() {
|
Memory.prototype.getReadOnlyContext = function() {
|
||||||
|
@ -7544,68 +7547,7 @@ define('src/providers/providers',['require','src/providers/indexeddb','src/provi
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
define('src/filesystems-manager',['require','src/shared','src/constants','src/constants','src/error'],function(require) {
|
define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','src/path','src/path','src/shared','src/shared','src/shared','src/error','src/error','src/error','src/error','src/error','src/error','src/error','src/error','src/error','src/error','src/error','src/error','src/error','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/providers/providers'],function(require) {
|
||||||
|
|
||||||
var guid = require('src/shared').guid;
|
|
||||||
var FS_READY = require('src/constants').FS_READY;
|
|
||||||
var FS_ERROR = require('src/constants').FS_ERROR;
|
|
||||||
var EFileSystemError = require('src/error').EFileSystemError;
|
|
||||||
|
|
||||||
var filesystems = {};
|
|
||||||
|
|
||||||
function FileSystemWrapper(fs) {
|
|
||||||
this.fs = fs;
|
|
||||||
this.openFiles = {};
|
|
||||||
this.nextDescriptor = 1;
|
|
||||||
this.queue = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
FileSystemWrapper.prototype.allocDescriptor = function(openFileDescription) {
|
|
||||||
var fd = this.nextDescriptor ++;
|
|
||||||
this.openFiles[fd] = openFileDescription;
|
|
||||||
return fd;
|
|
||||||
};
|
|
||||||
|
|
||||||
FileSystemWrapper.prototype.releaseDescriptor = function(fd) {
|
|
||||||
delete this.openFiles[fd];
|
|
||||||
};
|
|
||||||
|
|
||||||
FileSystemWrapper.prototype.queueOrRun = function(operation) {
|
|
||||||
var error;
|
|
||||||
var fs = this.fs;
|
|
||||||
|
|
||||||
if(FS_READY == fs.readyState) {
|
|
||||||
operation.call(fs);
|
|
||||||
} else if(FS_ERROR == fs.readyState) {
|
|
||||||
error = new EFileSystemError('unknown error');
|
|
||||||
} else {
|
|
||||||
this.queue.push(operation);
|
|
||||||
}
|
|
||||||
|
|
||||||
return error;
|
|
||||||
};
|
|
||||||
|
|
||||||
FileSystemWrapper.prototype.runQueued = function() {
|
|
||||||
this.queue.forEach(function(operation) {
|
|
||||||
operation.call(this);
|
|
||||||
}.bind(this.fs));
|
|
||||||
this.queue = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
return {
|
|
||||||
register: function(fs) {
|
|
||||||
fs.id = guid();
|
|
||||||
filesystems[fs.id] = new FileSystemWrapper(fs);
|
|
||||||
},
|
|
||||||
|
|
||||||
get: function(fs) {
|
|
||||||
return filesystems[fs.id];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','src/path','src/path','src/shared','src/shared','src/shared','src/error','src/error','src/error','src/error','src/error','src/error','src/error','src/error','src/error','src/error','src/error','src/error','src/error','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/providers/providers','src/filesystems-manager'],function(require) {
|
|
||||||
|
|
||||||
var _ = require('lodash');
|
var _ = require('lodash');
|
||||||
|
|
||||||
|
@ -7636,6 +7578,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
var ELoop = require('src/error').ELoop;
|
var ELoop = require('src/error').ELoop;
|
||||||
var EFileSystemError = require('src/error').EFileSystemError;
|
var EFileSystemError = require('src/error').EFileSystemError;
|
||||||
|
|
||||||
|
var FILE_SYSTEM_NAME = require('src/constants').FILE_SYSTEM_NAME;
|
||||||
var FS_FORMAT = require('src/constants').FS_FORMAT;
|
var FS_FORMAT = require('src/constants').FS_FORMAT;
|
||||||
var MODE_FILE = require('src/constants').MODE_FILE;
|
var MODE_FILE = require('src/constants').MODE_FILE;
|
||||||
var MODE_DIRECTORY = require('src/constants').MODE_DIRECTORY;
|
var MODE_DIRECTORY = require('src/constants').MODE_DIRECTORY;
|
||||||
|
@ -7654,8 +7597,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
var O_APPEND = require('src/constants').O_APPEND;
|
var O_APPEND = require('src/constants').O_APPEND;
|
||||||
var O_FLAGS = require('src/constants').O_FLAGS;
|
var O_FLAGS = require('src/constants').O_FLAGS;
|
||||||
|
|
||||||
var Providers = require('src/providers/providers');
|
var providers = require('src/providers/providers');
|
||||||
var FileSystemsManager = require('src/filesystems-manager');
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DirectoryEntry
|
* DirectoryEntry
|
||||||
|
@ -7734,7 +7676,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
} else if(!rootDirectoryNode) {
|
} else if(!rootDirectoryNode) {
|
||||||
callback(new ENoEntry('path does not exist'));
|
callback(new ENoEntry('path does not exist'));
|
||||||
} else {
|
} else {
|
||||||
callback(undefined, rootDirectoryNode);
|
callback(null, rootDirectoryNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7777,7 +7719,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
follow_symbolic_link(node.data);
|
follow_symbolic_link(node.data);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
callback(undefined, node);
|
callback(null, node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8078,7 +8020,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
fileNode = result;
|
fileNode = result;
|
||||||
callback(undefined, fileNode);
|
callback(null, fileNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8110,7 +8052,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined, fileNode);
|
callback(null, fileNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8123,7 +8065,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined, length);
|
callback(null, length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8187,7 +8129,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
if(undefined === position) {
|
if(undefined === position) {
|
||||||
ofd.position += length;
|
ofd.position += length;
|
||||||
}
|
}
|
||||||
callback(undefined, length);
|
callback(null, length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8211,7 +8153,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined, result);
|
callback(null, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8223,7 +8165,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined, result);
|
callback(null, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8270,7 +8212,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined, result);
|
callback(null, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8434,7 +8376,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
} else {
|
} else {
|
||||||
directoryData = result;
|
directoryData = result;
|
||||||
var files = Object.keys(directoryData);
|
var files = Object.keys(directoryData);
|
||||||
callback(undefined, files);
|
callback(null, files);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8544,7 +8486,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
if(result.mode != MODE_SYMBOLIC_LINK) {
|
if(result.mode != MODE_SYMBOLIC_LINK) {
|
||||||
callback(new EInvalid("path not a symbolic link"));
|
callback(new EInvalid("path not a symbolic link"));
|
||||||
} else {
|
} else {
|
||||||
callback(undefined, result.data);
|
callback(null, result.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8569,34 +8511,72 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
* For example: "FORMAT" will cause the file system to be formatted.
|
* For example: "FORMAT" will cause the file system to be formatted.
|
||||||
* No explicit flags are set by default.
|
* No explicit flags are set by default.
|
||||||
*
|
*
|
||||||
* contextProvider: a explicit constructor function to use for the file
|
* provider: an explicit storage provider to use for the file
|
||||||
* system's database context provider. A number of context
|
* system's database context provider. A number of context
|
||||||
* providers are provided, and users can write one of their
|
* providers are included (see /src/providers), and users
|
||||||
* own and pass it in to be used. By default an IndexedDB
|
* can write one of their own and pass it in to be used.
|
||||||
* provider is used.
|
* By default an IndexedDB provider is used.
|
||||||
*
|
*
|
||||||
* onReady: a callback function to be executed when the file system becomes
|
* callback: a callback function to be executed when the file system becomes
|
||||||
* ready for use. Depending on the context provider used, this might
|
* ready for use. Depending on the context provider used, this might
|
||||||
* be right away, or could take some time. The onReady callback should
|
* be right away, or could take some time. The callback should expect
|
||||||
* check the file system's `readyState` and `error` properties to
|
* an `error` argument, which will be null if everything worked. Also
|
||||||
* make sure it is usable.
|
* users should check the file system's `readyState` and `error`
|
||||||
|
* properties to make sure it is usable.
|
||||||
*/
|
*/
|
||||||
function FileSystem(options) {
|
function FileSystem(options, callback) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
callback = callback || nop;
|
||||||
|
|
||||||
var fs = this;
|
var name = options.name || FILE_SYSTEM_NAME;
|
||||||
FileSystemsManager.register(fs);
|
|
||||||
|
|
||||||
var name = options.name || "local";
|
|
||||||
var flags = options.flags;
|
var flags = options.flags;
|
||||||
var provider = options.provider || new Providers.Default(name);
|
var provider = options.provider || new providers.Default(name);
|
||||||
var onReady = options.onReady || nop;
|
|
||||||
var forceFormatting = _(flags).contains(FS_FORMAT);
|
var forceFormatting = _(flags).contains(FS_FORMAT);
|
||||||
|
|
||||||
|
var fs = this;
|
||||||
fs.readyState = FS_PENDING;
|
fs.readyState = FS_PENDING;
|
||||||
fs.name = name;
|
fs.name = name;
|
||||||
fs.error = null;
|
fs.error = null;
|
||||||
|
|
||||||
|
// Safely expose the list of open files and file
|
||||||
|
// descriptor management functions
|
||||||
|
var openFiles = {};
|
||||||
|
var nextDescriptor = 1;
|
||||||
|
Object.defineProperty(this, "openFiles", {
|
||||||
|
get: function() { return openFiles; }
|
||||||
|
});
|
||||||
|
this.allocDescriptor = function(openFileDescription) {
|
||||||
|
var fd = nextDescriptor ++;
|
||||||
|
openFiles[fd] = openFileDescription;
|
||||||
|
return fd;
|
||||||
|
};
|
||||||
|
this.releaseDescriptor = function(fd) {
|
||||||
|
delete openFiles[fd];
|
||||||
|
};
|
||||||
|
|
||||||
|
// Safely expose the operation queue
|
||||||
|
var queue = [];
|
||||||
|
this.queueOrRun = function(operation) {
|
||||||
|
var error;
|
||||||
|
|
||||||
|
if(FS_READY == fs.readyState) {
|
||||||
|
operation.call(fs);
|
||||||
|
} else if(FS_ERROR == fs.readyState) {
|
||||||
|
error = new EFileSystemError('unknown error');
|
||||||
|
} else {
|
||||||
|
queue.push(operation);
|
||||||
|
}
|
||||||
|
|
||||||
|
return error;
|
||||||
|
};
|
||||||
|
function runQueued() {
|
||||||
|
queue.forEach(function(operation) {
|
||||||
|
operation.call(this);
|
||||||
|
}.bind(fs));
|
||||||
|
queue = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open file system storage provider
|
||||||
provider.open(function(err, needsFormatting) {
|
provider.open(function(err, needsFormatting) {
|
||||||
function complete(error) {
|
function complete(error) {
|
||||||
fs.provider = provider;
|
fs.provider = provider;
|
||||||
|
@ -8604,9 +8584,9 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
fs.readyState = FS_ERROR;
|
fs.readyState = FS_ERROR;
|
||||||
} else {
|
} else {
|
||||||
fs.readyState = FS_READY;
|
fs.readyState = FS_READY;
|
||||||
FileSystemsManager.get(fs).runQueued();
|
runQueued();
|
||||||
}
|
}
|
||||||
onReady();
|
callback(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(err) {
|
if(err) {
|
||||||
|
@ -8615,19 +8595,23 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
|
|
||||||
// If we don't need or want formatting, we're done
|
// If we don't need or want formatting, we're done
|
||||||
if(!(forceFormatting || needsFormatting)) {
|
if(!(forceFormatting || needsFormatting)) {
|
||||||
return complete();
|
return complete(null);
|
||||||
}
|
}
|
||||||
// otherwise format the fs first
|
// otherwise format the fs first
|
||||||
var context = provider.getReadWriteContext();
|
var context = provider.getReadWriteContext();
|
||||||
context.clear(function(err) {
|
context.clear(function(err) {
|
||||||
if(err) {
|
if(err) {
|
||||||
return complete(err);
|
complete(err);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
make_root_directory(context, complete);
|
make_root_directory(context, complete);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Expose storage providers on FileSystem constructor
|
||||||
|
FileSystem.providers = providers;
|
||||||
|
|
||||||
function _open(fs, context, path, flags, callback) {
|
function _open(fs, context, path, flags, callback) {
|
||||||
function check_result(error, fileNode) {
|
function check_result(error, fileNode) {
|
||||||
if(error) {
|
if(error) {
|
||||||
|
@ -8640,8 +8624,8 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
position = 0;
|
position = 0;
|
||||||
}
|
}
|
||||||
var openFileDescription = new OpenFileDescription(fileNode.id, flags, position);
|
var openFileDescription = new OpenFileDescription(fileNode.id, flags, position);
|
||||||
var fd = FileSystemsManager.get(fs).allocDescriptor(openFileDescription);
|
var fd = fs.allocDescriptor(openFileDescription);
|
||||||
callback(undefined, fd);
|
callback(null, fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8654,12 +8638,11 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
}
|
}
|
||||||
|
|
||||||
function _close(fs, fd, callback) {
|
function _close(fs, fd, callback) {
|
||||||
var wrapped = FileSystemsManager.get(fs);
|
if(!_(fs.openFiles).has(fd)) {
|
||||||
if(!_(wrapped.openFiles).has(fd)) {
|
|
||||||
callback(new EBadFileDescriptor('invalid file descriptor'));
|
callback(new EBadFileDescriptor('invalid file descriptor'));
|
||||||
} else {
|
} else {
|
||||||
wrapped.releaseDescriptor(fd);
|
fs.releaseDescriptor(fd);
|
||||||
callback(undefined);
|
callback(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8668,7 +8651,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined);
|
callback(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8680,7 +8663,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined);
|
callback(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8693,7 +8676,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
var stats = new Stats(result, name);
|
var stats = new Stats(result, name);
|
||||||
callback(undefined, stats);
|
callback(null, stats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8706,11 +8689,11 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
var stats = new Stats(result, fs.name);
|
var stats = new Stats(result, fs.name);
|
||||||
callback(undefined, stats);
|
callback(null, stats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var ofd = FileSystemsManager.get(fs).openFiles[fd];
|
var ofd = fs.openFiles[fd];
|
||||||
|
|
||||||
if(!ofd) {
|
if(!ofd) {
|
||||||
callback(new EBadFileDescriptor('invalid file descriptor'));
|
callback(new EBadFileDescriptor('invalid file descriptor'));
|
||||||
|
@ -8724,7 +8707,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined);
|
callback(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8736,7 +8719,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined);
|
callback(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8751,11 +8734,11 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined, nbytes);
|
callback(null, nbytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var ofd = FileSystemsManager.get(fs).openFiles[fd];
|
var ofd = fs.openFiles[fd];
|
||||||
|
|
||||||
if(!ofd) {
|
if(!ofd) {
|
||||||
callback(new EBadFileDescriptor('invalid file descriptor'));
|
callback(new EBadFileDescriptor('invalid file descriptor'));
|
||||||
|
@ -8786,7 +8769,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
var ofd = new OpenFileDescription(fileNode.id, flags, 0);
|
var ofd = new OpenFileDescription(fileNode.id, flags, 0);
|
||||||
var fd = FileSystemsManager.get(fs).allocDescriptor(ofd);
|
var fd = fs.allocDescriptor(ofd);
|
||||||
|
|
||||||
fstat_file(context, ofd, function(err2, fstatResult) {
|
fstat_file(context, ofd, function(err2, fstatResult) {
|
||||||
if(err2) {
|
if(err2) {
|
||||||
|
@ -8801,7 +8784,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
if(err3) {
|
if(err3) {
|
||||||
return callback(err3);
|
return callback(err3);
|
||||||
}
|
}
|
||||||
FileSystemsManager.get(fs).releaseDescriptor(fd);
|
fs.releaseDescriptor(fd);
|
||||||
|
|
||||||
var data;
|
var data;
|
||||||
if(options.encoding === 'utf8') {
|
if(options.encoding === 'utf8') {
|
||||||
|
@ -8809,7 +8792,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
} else {
|
} else {
|
||||||
data = buffer;
|
data = buffer;
|
||||||
}
|
}
|
||||||
callback(undefined, data);
|
callback(null, data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -8824,11 +8807,11 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined, nbytes);
|
callback(null, nbytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var ofd = FileSystemsManager.get(fs).openFiles[fd];
|
var ofd = fs.openFiles[fd];
|
||||||
|
|
||||||
if(!ofd) {
|
if(!ofd) {
|
||||||
callback(new EBadFileDescriptor('invalid file descriptor'));
|
callback(new EBadFileDescriptor('invalid file descriptor'));
|
||||||
|
@ -8865,14 +8848,14 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
var ofd = new OpenFileDescription(fileNode.id, flags, 0);
|
var ofd = new OpenFileDescription(fileNode.id, flags, 0);
|
||||||
var fd = FileSystemsManager.get(fs).allocDescriptor(ofd);
|
var fd = fs.allocDescriptor(ofd);
|
||||||
|
|
||||||
write_data(context, ofd, data, 0, data.length, 0, function(err2, nbytes) {
|
write_data(context, ofd, data, 0, data.length, 0, function(err2, nbytes) {
|
||||||
if(err2) {
|
if(err2) {
|
||||||
return callback(err2);
|
return callback(err2);
|
||||||
}
|
}
|
||||||
FileSystemsManager.get(fs).releaseDescriptor(fd);
|
fs.releaseDescriptor(fd);
|
||||||
callback(undefined);
|
callback(null);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -8902,12 +8885,12 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
callback(new EInvalid('resulting file offset would be negative'));
|
callback(new EInvalid('resulting file offset would be negative'));
|
||||||
} else {
|
} else {
|
||||||
ofd.position = stats.size + offset;
|
ofd.position = stats.size + offset;
|
||||||
callback(undefined, ofd.position);
|
callback(null, ofd.position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var ofd = FileSystemsManager.get(fs).openFiles[fd];
|
var ofd = fs.openFiles[fd];
|
||||||
|
|
||||||
if(!ofd) {
|
if(!ofd) {
|
||||||
callback(new EBadFileDescriptor('invalid file descriptor'));
|
callback(new EBadFileDescriptor('invalid file descriptor'));
|
||||||
|
@ -8918,14 +8901,14 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
callback(new EInvalid('resulting file offset would be negative'));
|
callback(new EInvalid('resulting file offset would be negative'));
|
||||||
} else {
|
} else {
|
||||||
ofd.position = offset;
|
ofd.position = offset;
|
||||||
callback(undefined, ofd.position);
|
callback(null, ofd.position);
|
||||||
}
|
}
|
||||||
} else if('CUR' === whence) {
|
} else if('CUR' === whence) {
|
||||||
if(ofd.position + offset < 0) {
|
if(ofd.position + offset < 0) {
|
||||||
callback(new EInvalid('resulting file offset would be negative'));
|
callback(new EInvalid('resulting file offset would be negative'));
|
||||||
} else {
|
} else {
|
||||||
ofd.position += offset;
|
ofd.position += offset;
|
||||||
callback(undefined, ofd.position);
|
callback(null, ofd.position);
|
||||||
}
|
}
|
||||||
} else if('END' === whence) {
|
} else if('END' === whence) {
|
||||||
fstat_file(context, ofd, update_descriptor_position);
|
fstat_file(context, ofd, update_descriptor_position);
|
||||||
|
@ -8939,7 +8922,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined, files);
|
callback(null, files);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8955,7 +8938,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined);
|
callback(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8975,7 +8958,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined);
|
callback(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8987,7 +8970,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined, result);
|
callback(null, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9004,7 +8987,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
var stats = new Stats(result, fs.name);
|
var stats = new Stats(result, fs.name);
|
||||||
callback(undefined, stats);
|
callback(null, stats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9026,7 +9009,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
|
|
||||||
FileSystem.prototype.open = function(path, flags, callback) {
|
FileSystem.prototype.open = function(path, flags, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_open(fs, context, path, flags, callback);
|
_open(fs, context, path, flags, callback);
|
||||||
|
@ -9039,7 +9022,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
};
|
};
|
||||||
FileSystem.prototype.mkdir = function(path, callback) {
|
FileSystem.prototype.mkdir = function(path, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_mkdir(context, path, callback);
|
_mkdir(context, path, callback);
|
||||||
|
@ -9049,7 +9032,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
};
|
};
|
||||||
FileSystem.prototype.rmdir = function(path, callback) {
|
FileSystem.prototype.rmdir = function(path, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_rmdir(context, path, callback);
|
_rmdir(context, path, callback);
|
||||||
|
@ -9059,7 +9042,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
};
|
};
|
||||||
FileSystem.prototype.stat = function(path, callback) {
|
FileSystem.prototype.stat = function(path, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_stat(context, fs.name, path, callback);
|
_stat(context, fs.name, path, callback);
|
||||||
|
@ -9069,7 +9052,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
};
|
};
|
||||||
FileSystem.prototype.fstat = function(fd, callback) {
|
FileSystem.prototype.fstat = function(fd, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_fstat(fs, context, fd, callback);
|
_fstat(fs, context, fd, callback);
|
||||||
|
@ -9079,7 +9062,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
};
|
};
|
||||||
FileSystem.prototype.link = function(oldpath, newpath, callback) {
|
FileSystem.prototype.link = function(oldpath, newpath, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_link(context, oldpath, newpath, callback);
|
_link(context, oldpath, newpath, callback);
|
||||||
|
@ -9089,7 +9072,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
};
|
};
|
||||||
FileSystem.prototype.unlink = function(path, callback) {
|
FileSystem.prototype.unlink = function(path, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_unlink(context, path, callback);
|
_unlink(context, path, callback);
|
||||||
|
@ -9099,7 +9082,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
};
|
};
|
||||||
FileSystem.prototype.read = function(fd, buffer, offset, length, position, callback) {
|
FileSystem.prototype.read = function(fd, buffer, offset, length, position, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_read(fs, context, fd, buffer, offset, length, position, callback);
|
_read(fs, context, fd, buffer, offset, length, position, callback);
|
||||||
|
@ -9109,7 +9092,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
};
|
};
|
||||||
FileSystem.prototype.readFile = function(path, options, callback) {
|
FileSystem.prototype.readFile = function(path, options, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_readFile(fs, context, path, options, callback);
|
_readFile(fs, context, path, options, callback);
|
||||||
|
@ -9119,7 +9102,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
};
|
};
|
||||||
FileSystem.prototype.write = function(fd, buffer, offset, length, position, callback) {
|
FileSystem.prototype.write = function(fd, buffer, offset, length, position, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_write(fs, context, fd, buffer, offset, length, position, callback);
|
_write(fs, context, fd, buffer, offset, length, position, callback);
|
||||||
|
@ -9130,7 +9113,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
};
|
};
|
||||||
FileSystem.prototype.writeFile = function(path, data, options, callback) {
|
FileSystem.prototype.writeFile = function(path, data, options, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_writeFile(fs, context, path, data, options, callback);
|
_writeFile(fs, context, path, data, options, callback);
|
||||||
|
@ -9140,7 +9123,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
};
|
};
|
||||||
FileSystem.prototype.lseek = function(fd, offset, whence, callback) {
|
FileSystem.prototype.lseek = function(fd, offset, whence, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_lseek(fs, context, fd, offset, whence, callback);
|
_lseek(fs, context, fd, offset, whence, callback);
|
||||||
|
@ -9150,7 +9133,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
};
|
};
|
||||||
FileSystem.prototype.readdir = function(path, callback) {
|
FileSystem.prototype.readdir = function(path, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_readdir(context, path, callback);
|
_readdir(context, path, callback);
|
||||||
|
@ -9160,7 +9143,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
};
|
};
|
||||||
FileSystem.prototype.rename = function(oldpath, newpath, callback) {
|
FileSystem.prototype.rename = function(oldpath, newpath, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_rename(context, oldpath, newpath, callback);
|
_rename(context, oldpath, newpath, callback);
|
||||||
|
@ -9170,7 +9153,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
};
|
};
|
||||||
FileSystem.prototype.readlink = function(path, callback) {
|
FileSystem.prototype.readlink = function(path, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_readlink(context, path, callback);
|
_readlink(context, path, callback);
|
||||||
|
@ -9180,7 +9163,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
};
|
};
|
||||||
FileSystem.prototype.symlink = function(srcpath, dstpath, callback) {
|
FileSystem.prototype.symlink = function(srcpath, dstpath, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_symlink(context, srcpath, dstpath, callback);
|
_symlink(context, srcpath, dstpath, callback);
|
||||||
|
@ -9190,7 +9173,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
};
|
};
|
||||||
FileSystem.prototype.lstat = function(path, callback) {
|
FileSystem.prototype.lstat = function(path, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_lstat(fs, context, path, callback);
|
_lstat(fs, context, path, callback);
|
||||||
|
@ -9200,8 +9183,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
FileSystem: FileSystem,
|
FileSystem: FileSystem
|
||||||
Providers: Providers
|
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,6 +8,8 @@ define(function(require) {
|
||||||
var O_APPEND = 'APPEND';
|
var O_APPEND = 'APPEND';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
FILE_SYSTEM_NAME: 'local',
|
||||||
|
|
||||||
FILE_STORE_NAME: 'files',
|
FILE_STORE_NAME: 'files',
|
||||||
|
|
||||||
IDB_RO: 'readonly',
|
IDB_RO: 'readonly',
|
||||||
|
|
|
@ -1,60 +0,0 @@
|
||||||
define(function(require) {
|
|
||||||
|
|
||||||
var guid = require('src/shared').guid;
|
|
||||||
var FS_READY = require('src/constants').FS_READY;
|
|
||||||
var FS_ERROR = require('src/constants').FS_ERROR;
|
|
||||||
var EFileSystemError = require('src/error').EFileSystemError;
|
|
||||||
|
|
||||||
var filesystems = {};
|
|
||||||
|
|
||||||
function FileSystemWrapper(fs) {
|
|
||||||
this.fs = fs;
|
|
||||||
this.openFiles = {};
|
|
||||||
this.nextDescriptor = 1;
|
|
||||||
this.queue = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
FileSystemWrapper.prototype.allocDescriptor = function(openFileDescription) {
|
|
||||||
var fd = this.nextDescriptor ++;
|
|
||||||
this.openFiles[fd] = openFileDescription;
|
|
||||||
return fd;
|
|
||||||
};
|
|
||||||
|
|
||||||
FileSystemWrapper.prototype.releaseDescriptor = function(fd) {
|
|
||||||
delete this.openFiles[fd];
|
|
||||||
};
|
|
||||||
|
|
||||||
FileSystemWrapper.prototype.queueOrRun = function(operation) {
|
|
||||||
var error;
|
|
||||||
var fs = this.fs;
|
|
||||||
|
|
||||||
if(FS_READY == fs.readyState) {
|
|
||||||
operation.call(fs);
|
|
||||||
} else if(FS_ERROR == fs.readyState) {
|
|
||||||
error = new EFileSystemError('unknown error');
|
|
||||||
} else {
|
|
||||||
this.queue.push(operation);
|
|
||||||
}
|
|
||||||
|
|
||||||
return error;
|
|
||||||
};
|
|
||||||
|
|
||||||
FileSystemWrapper.prototype.runQueued = function() {
|
|
||||||
this.queue.forEach(function(operation) {
|
|
||||||
operation.call(this);
|
|
||||||
}.bind(this.fs));
|
|
||||||
this.queue = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
return {
|
|
||||||
register: function(fs) {
|
|
||||||
fs.id = guid();
|
|
||||||
filesystems[fs.id] = new FileSystemWrapper(fs);
|
|
||||||
},
|
|
||||||
|
|
||||||
get: function(fs) {
|
|
||||||
return filesystems[fs.id];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
210
src/fs.js
210
src/fs.js
|
@ -29,6 +29,7 @@ define(function(require) {
|
||||||
var ELoop = require('src/error').ELoop;
|
var ELoop = require('src/error').ELoop;
|
||||||
var EFileSystemError = require('src/error').EFileSystemError;
|
var EFileSystemError = require('src/error').EFileSystemError;
|
||||||
|
|
||||||
|
var FILE_SYSTEM_NAME = require('src/constants').FILE_SYSTEM_NAME;
|
||||||
var FS_FORMAT = require('src/constants').FS_FORMAT;
|
var FS_FORMAT = require('src/constants').FS_FORMAT;
|
||||||
var MODE_FILE = require('src/constants').MODE_FILE;
|
var MODE_FILE = require('src/constants').MODE_FILE;
|
||||||
var MODE_DIRECTORY = require('src/constants').MODE_DIRECTORY;
|
var MODE_DIRECTORY = require('src/constants').MODE_DIRECTORY;
|
||||||
|
@ -47,8 +48,7 @@ define(function(require) {
|
||||||
var O_APPEND = require('src/constants').O_APPEND;
|
var O_APPEND = require('src/constants').O_APPEND;
|
||||||
var O_FLAGS = require('src/constants').O_FLAGS;
|
var O_FLAGS = require('src/constants').O_FLAGS;
|
||||||
|
|
||||||
var Providers = require('src/providers/providers');
|
var providers = require('src/providers/providers');
|
||||||
var FileSystemsManager = require('src/filesystems-manager');
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DirectoryEntry
|
* DirectoryEntry
|
||||||
|
@ -127,7 +127,7 @@ define(function(require) {
|
||||||
} else if(!rootDirectoryNode) {
|
} else if(!rootDirectoryNode) {
|
||||||
callback(new ENoEntry('path does not exist'));
|
callback(new ENoEntry('path does not exist'));
|
||||||
} else {
|
} else {
|
||||||
callback(undefined, rootDirectoryNode);
|
callback(null, rootDirectoryNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ define(function(require) {
|
||||||
follow_symbolic_link(node.data);
|
follow_symbolic_link(node.data);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
callback(undefined, node);
|
callback(null, node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -471,7 +471,7 @@ define(function(require) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
fileNode = result;
|
fileNode = result;
|
||||||
callback(undefined, fileNode);
|
callback(null, fileNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,7 +503,7 @@ define(function(require) {
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined, fileNode);
|
callback(null, fileNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -516,7 +516,7 @@ define(function(require) {
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined, length);
|
callback(null, length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -580,7 +580,7 @@ define(function(require) {
|
||||||
if(undefined === position) {
|
if(undefined === position) {
|
||||||
ofd.position += length;
|
ofd.position += length;
|
||||||
}
|
}
|
||||||
callback(undefined, length);
|
callback(null, length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -604,7 +604,7 @@ define(function(require) {
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined, result);
|
callback(null, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -616,7 +616,7 @@ define(function(require) {
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined, result);
|
callback(null, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -663,7 +663,7 @@ define(function(require) {
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined, result);
|
callback(null, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -827,7 +827,7 @@ define(function(require) {
|
||||||
} else {
|
} else {
|
||||||
directoryData = result;
|
directoryData = result;
|
||||||
var files = Object.keys(directoryData);
|
var files = Object.keys(directoryData);
|
||||||
callback(undefined, files);
|
callback(null, files);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -937,7 +937,7 @@ define(function(require) {
|
||||||
if(result.mode != MODE_SYMBOLIC_LINK) {
|
if(result.mode != MODE_SYMBOLIC_LINK) {
|
||||||
callback(new EInvalid("path not a symbolic link"));
|
callback(new EInvalid("path not a symbolic link"));
|
||||||
} else {
|
} else {
|
||||||
callback(undefined, result.data);
|
callback(null, result.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -962,34 +962,72 @@ define(function(require) {
|
||||||
* For example: "FORMAT" will cause the file system to be formatted.
|
* For example: "FORMAT" will cause the file system to be formatted.
|
||||||
* No explicit flags are set by default.
|
* No explicit flags are set by default.
|
||||||
*
|
*
|
||||||
* contextProvider: a explicit constructor function to use for the file
|
* provider: an explicit storage provider to use for the file
|
||||||
* system's database context provider. A number of context
|
* system's database context provider. A number of context
|
||||||
* providers are provided, and users can write one of their
|
* providers are included (see /src/providers), and users
|
||||||
* own and pass it in to be used. By default an IndexedDB
|
* can write one of their own and pass it in to be used.
|
||||||
* provider is used.
|
* By default an IndexedDB provider is used.
|
||||||
*
|
*
|
||||||
* onReady: a callback function to be executed when the file system becomes
|
* callback: a callback function to be executed when the file system becomes
|
||||||
* ready for use. Depending on the context provider used, this might
|
* ready for use. Depending on the context provider used, this might
|
||||||
* be right away, or could take some time. The onReady callback should
|
* be right away, or could take some time. The callback should expect
|
||||||
* check the file system's `readyState` and `error` properties to
|
* an `error` argument, which will be null if everything worked. Also
|
||||||
* make sure it is usable.
|
* users should check the file system's `readyState` and `error`
|
||||||
|
* properties to make sure it is usable.
|
||||||
*/
|
*/
|
||||||
function FileSystem(options) {
|
function FileSystem(options, callback) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
callback = callback || nop;
|
||||||
|
|
||||||
var fs = this;
|
var name = options.name || FILE_SYSTEM_NAME;
|
||||||
FileSystemsManager.register(fs);
|
|
||||||
|
|
||||||
var name = options.name || "local";
|
|
||||||
var flags = options.flags;
|
var flags = options.flags;
|
||||||
var provider = options.provider || new Providers.Default(name);
|
var provider = options.provider || new providers.Default(name);
|
||||||
var onReady = options.onReady || nop;
|
|
||||||
var forceFormatting = _(flags).contains(FS_FORMAT);
|
var forceFormatting = _(flags).contains(FS_FORMAT);
|
||||||
|
|
||||||
|
var fs = this;
|
||||||
fs.readyState = FS_PENDING;
|
fs.readyState = FS_PENDING;
|
||||||
fs.name = name;
|
fs.name = name;
|
||||||
fs.error = null;
|
fs.error = null;
|
||||||
|
|
||||||
|
// Safely expose the list of open files and file
|
||||||
|
// descriptor management functions
|
||||||
|
var openFiles = {};
|
||||||
|
var nextDescriptor = 1;
|
||||||
|
Object.defineProperty(this, "openFiles", {
|
||||||
|
get: function() { return openFiles; }
|
||||||
|
});
|
||||||
|
this.allocDescriptor = function(openFileDescription) {
|
||||||
|
var fd = nextDescriptor ++;
|
||||||
|
openFiles[fd] = openFileDescription;
|
||||||
|
return fd;
|
||||||
|
};
|
||||||
|
this.releaseDescriptor = function(fd) {
|
||||||
|
delete openFiles[fd];
|
||||||
|
};
|
||||||
|
|
||||||
|
// Safely expose the operation queue
|
||||||
|
var queue = [];
|
||||||
|
this.queueOrRun = function(operation) {
|
||||||
|
var error;
|
||||||
|
|
||||||
|
if(FS_READY == fs.readyState) {
|
||||||
|
operation.call(fs);
|
||||||
|
} else if(FS_ERROR == fs.readyState) {
|
||||||
|
error = new EFileSystemError('unknown error');
|
||||||
|
} else {
|
||||||
|
queue.push(operation);
|
||||||
|
}
|
||||||
|
|
||||||
|
return error;
|
||||||
|
};
|
||||||
|
function runQueued() {
|
||||||
|
queue.forEach(function(operation) {
|
||||||
|
operation.call(this);
|
||||||
|
}.bind(fs));
|
||||||
|
queue = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open file system storage provider
|
||||||
provider.open(function(err, needsFormatting) {
|
provider.open(function(err, needsFormatting) {
|
||||||
function complete(error) {
|
function complete(error) {
|
||||||
fs.provider = provider;
|
fs.provider = provider;
|
||||||
|
@ -997,9 +1035,9 @@ define(function(require) {
|
||||||
fs.readyState = FS_ERROR;
|
fs.readyState = FS_ERROR;
|
||||||
} else {
|
} else {
|
||||||
fs.readyState = FS_READY;
|
fs.readyState = FS_READY;
|
||||||
FileSystemsManager.get(fs).runQueued();
|
runQueued();
|
||||||
}
|
}
|
||||||
onReady();
|
callback(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(err) {
|
if(err) {
|
||||||
|
@ -1008,19 +1046,23 @@ define(function(require) {
|
||||||
|
|
||||||
// If we don't need or want formatting, we're done
|
// If we don't need or want formatting, we're done
|
||||||
if(!(forceFormatting || needsFormatting)) {
|
if(!(forceFormatting || needsFormatting)) {
|
||||||
return complete();
|
return complete(null);
|
||||||
}
|
}
|
||||||
// otherwise format the fs first
|
// otherwise format the fs first
|
||||||
var context = provider.getReadWriteContext();
|
var context = provider.getReadWriteContext();
|
||||||
context.clear(function(err) {
|
context.clear(function(err) {
|
||||||
if(err) {
|
if(err) {
|
||||||
return complete(err);
|
complete(err);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
make_root_directory(context, complete);
|
make_root_directory(context, complete);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Expose storage providers on FileSystem constructor
|
||||||
|
FileSystem.providers = providers;
|
||||||
|
|
||||||
function _open(fs, context, path, flags, callback) {
|
function _open(fs, context, path, flags, callback) {
|
||||||
function check_result(error, fileNode) {
|
function check_result(error, fileNode) {
|
||||||
if(error) {
|
if(error) {
|
||||||
|
@ -1033,8 +1075,8 @@ define(function(require) {
|
||||||
position = 0;
|
position = 0;
|
||||||
}
|
}
|
||||||
var openFileDescription = new OpenFileDescription(fileNode.id, flags, position);
|
var openFileDescription = new OpenFileDescription(fileNode.id, flags, position);
|
||||||
var fd = FileSystemsManager.get(fs).allocDescriptor(openFileDescription);
|
var fd = fs.allocDescriptor(openFileDescription);
|
||||||
callback(undefined, fd);
|
callback(null, fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1047,12 +1089,11 @@ define(function(require) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function _close(fs, fd, callback) {
|
function _close(fs, fd, callback) {
|
||||||
var wrapped = FileSystemsManager.get(fs);
|
if(!_(fs.openFiles).has(fd)) {
|
||||||
if(!_(wrapped.openFiles).has(fd)) {
|
|
||||||
callback(new EBadFileDescriptor('invalid file descriptor'));
|
callback(new EBadFileDescriptor('invalid file descriptor'));
|
||||||
} else {
|
} else {
|
||||||
wrapped.releaseDescriptor(fd);
|
fs.releaseDescriptor(fd);
|
||||||
callback(undefined);
|
callback(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1061,7 +1102,7 @@ define(function(require) {
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined);
|
callback(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1073,7 +1114,7 @@ define(function(require) {
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined);
|
callback(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1086,7 +1127,7 @@ define(function(require) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
var stats = new Stats(result, name);
|
var stats = new Stats(result, name);
|
||||||
callback(undefined, stats);
|
callback(null, stats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1099,11 +1140,11 @@ define(function(require) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
var stats = new Stats(result, fs.name);
|
var stats = new Stats(result, fs.name);
|
||||||
callback(undefined, stats);
|
callback(null, stats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var ofd = FileSystemsManager.get(fs).openFiles[fd];
|
var ofd = fs.openFiles[fd];
|
||||||
|
|
||||||
if(!ofd) {
|
if(!ofd) {
|
||||||
callback(new EBadFileDescriptor('invalid file descriptor'));
|
callback(new EBadFileDescriptor('invalid file descriptor'));
|
||||||
|
@ -1117,7 +1158,7 @@ define(function(require) {
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined);
|
callback(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1129,7 +1170,7 @@ define(function(require) {
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined);
|
callback(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1144,11 +1185,11 @@ define(function(require) {
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined, nbytes);
|
callback(null, nbytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var ofd = FileSystemsManager.get(fs).openFiles[fd];
|
var ofd = fs.openFiles[fd];
|
||||||
|
|
||||||
if(!ofd) {
|
if(!ofd) {
|
||||||
callback(new EBadFileDescriptor('invalid file descriptor'));
|
callback(new EBadFileDescriptor('invalid file descriptor'));
|
||||||
|
@ -1179,7 +1220,7 @@ define(function(require) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
var ofd = new OpenFileDescription(fileNode.id, flags, 0);
|
var ofd = new OpenFileDescription(fileNode.id, flags, 0);
|
||||||
var fd = FileSystemsManager.get(fs).allocDescriptor(ofd);
|
var fd = fs.allocDescriptor(ofd);
|
||||||
|
|
||||||
fstat_file(context, ofd, function(err2, fstatResult) {
|
fstat_file(context, ofd, function(err2, fstatResult) {
|
||||||
if(err2) {
|
if(err2) {
|
||||||
|
@ -1194,7 +1235,7 @@ define(function(require) {
|
||||||
if(err3) {
|
if(err3) {
|
||||||
return callback(err3);
|
return callback(err3);
|
||||||
}
|
}
|
||||||
FileSystemsManager.get(fs).releaseDescriptor(fd);
|
fs.releaseDescriptor(fd);
|
||||||
|
|
||||||
var data;
|
var data;
|
||||||
if(options.encoding === 'utf8') {
|
if(options.encoding === 'utf8') {
|
||||||
|
@ -1202,7 +1243,7 @@ define(function(require) {
|
||||||
} else {
|
} else {
|
||||||
data = buffer;
|
data = buffer;
|
||||||
}
|
}
|
||||||
callback(undefined, data);
|
callback(null, data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1217,11 +1258,11 @@ define(function(require) {
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined, nbytes);
|
callback(null, nbytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var ofd = FileSystemsManager.get(fs).openFiles[fd];
|
var ofd = fs.openFiles[fd];
|
||||||
|
|
||||||
if(!ofd) {
|
if(!ofd) {
|
||||||
callback(new EBadFileDescriptor('invalid file descriptor'));
|
callback(new EBadFileDescriptor('invalid file descriptor'));
|
||||||
|
@ -1258,14 +1299,14 @@ define(function(require) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
var ofd = new OpenFileDescription(fileNode.id, flags, 0);
|
var ofd = new OpenFileDescription(fileNode.id, flags, 0);
|
||||||
var fd = FileSystemsManager.get(fs).allocDescriptor(ofd);
|
var fd = fs.allocDescriptor(ofd);
|
||||||
|
|
||||||
write_data(context, ofd, data, 0, data.length, 0, function(err2, nbytes) {
|
write_data(context, ofd, data, 0, data.length, 0, function(err2, nbytes) {
|
||||||
if(err2) {
|
if(err2) {
|
||||||
return callback(err2);
|
return callback(err2);
|
||||||
}
|
}
|
||||||
FileSystemsManager.get(fs).releaseDescriptor(fd);
|
fs.releaseDescriptor(fd);
|
||||||
callback(undefined);
|
callback(null);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1295,12 +1336,12 @@ define(function(require) {
|
||||||
callback(new EInvalid('resulting file offset would be negative'));
|
callback(new EInvalid('resulting file offset would be negative'));
|
||||||
} else {
|
} else {
|
||||||
ofd.position = stats.size + offset;
|
ofd.position = stats.size + offset;
|
||||||
callback(undefined, ofd.position);
|
callback(null, ofd.position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var ofd = FileSystemsManager.get(fs).openFiles[fd];
|
var ofd = fs.openFiles[fd];
|
||||||
|
|
||||||
if(!ofd) {
|
if(!ofd) {
|
||||||
callback(new EBadFileDescriptor('invalid file descriptor'));
|
callback(new EBadFileDescriptor('invalid file descriptor'));
|
||||||
|
@ -1311,14 +1352,14 @@ define(function(require) {
|
||||||
callback(new EInvalid('resulting file offset would be negative'));
|
callback(new EInvalid('resulting file offset would be negative'));
|
||||||
} else {
|
} else {
|
||||||
ofd.position = offset;
|
ofd.position = offset;
|
||||||
callback(undefined, ofd.position);
|
callback(null, ofd.position);
|
||||||
}
|
}
|
||||||
} else if('CUR' === whence) {
|
} else if('CUR' === whence) {
|
||||||
if(ofd.position + offset < 0) {
|
if(ofd.position + offset < 0) {
|
||||||
callback(new EInvalid('resulting file offset would be negative'));
|
callback(new EInvalid('resulting file offset would be negative'));
|
||||||
} else {
|
} else {
|
||||||
ofd.position += offset;
|
ofd.position += offset;
|
||||||
callback(undefined, ofd.position);
|
callback(null, ofd.position);
|
||||||
}
|
}
|
||||||
} else if('END' === whence) {
|
} else if('END' === whence) {
|
||||||
fstat_file(context, ofd, update_descriptor_position);
|
fstat_file(context, ofd, update_descriptor_position);
|
||||||
|
@ -1332,7 +1373,7 @@ define(function(require) {
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined, files);
|
callback(null, files);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1348,7 +1389,7 @@ define(function(require) {
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined);
|
callback(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1368,7 +1409,7 @@ define(function(require) {
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined);
|
callback(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1380,7 +1421,7 @@ define(function(require) {
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
callback(undefined, result);
|
callback(null, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1397,7 +1438,7 @@ define(function(require) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else {
|
} else {
|
||||||
var stats = new Stats(result, fs.name);
|
var stats = new Stats(result, fs.name);
|
||||||
callback(undefined, stats);
|
callback(null, stats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1419,7 +1460,7 @@ define(function(require) {
|
||||||
|
|
||||||
FileSystem.prototype.open = function(path, flags, callback) {
|
FileSystem.prototype.open = function(path, flags, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_open(fs, context, path, flags, callback);
|
_open(fs, context, path, flags, callback);
|
||||||
|
@ -1432,7 +1473,7 @@ define(function(require) {
|
||||||
};
|
};
|
||||||
FileSystem.prototype.mkdir = function(path, callback) {
|
FileSystem.prototype.mkdir = function(path, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_mkdir(context, path, callback);
|
_mkdir(context, path, callback);
|
||||||
|
@ -1442,7 +1483,7 @@ define(function(require) {
|
||||||
};
|
};
|
||||||
FileSystem.prototype.rmdir = function(path, callback) {
|
FileSystem.prototype.rmdir = function(path, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_rmdir(context, path, callback);
|
_rmdir(context, path, callback);
|
||||||
|
@ -1452,7 +1493,7 @@ define(function(require) {
|
||||||
};
|
};
|
||||||
FileSystem.prototype.stat = function(path, callback) {
|
FileSystem.prototype.stat = function(path, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_stat(context, fs.name, path, callback);
|
_stat(context, fs.name, path, callback);
|
||||||
|
@ -1462,7 +1503,7 @@ define(function(require) {
|
||||||
};
|
};
|
||||||
FileSystem.prototype.fstat = function(fd, callback) {
|
FileSystem.prototype.fstat = function(fd, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_fstat(fs, context, fd, callback);
|
_fstat(fs, context, fd, callback);
|
||||||
|
@ -1472,7 +1513,7 @@ define(function(require) {
|
||||||
};
|
};
|
||||||
FileSystem.prototype.link = function(oldpath, newpath, callback) {
|
FileSystem.prototype.link = function(oldpath, newpath, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_link(context, oldpath, newpath, callback);
|
_link(context, oldpath, newpath, callback);
|
||||||
|
@ -1482,7 +1523,7 @@ define(function(require) {
|
||||||
};
|
};
|
||||||
FileSystem.prototype.unlink = function(path, callback) {
|
FileSystem.prototype.unlink = function(path, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_unlink(context, path, callback);
|
_unlink(context, path, callback);
|
||||||
|
@ -1492,7 +1533,7 @@ define(function(require) {
|
||||||
};
|
};
|
||||||
FileSystem.prototype.read = function(fd, buffer, offset, length, position, callback) {
|
FileSystem.prototype.read = function(fd, buffer, offset, length, position, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_read(fs, context, fd, buffer, offset, length, position, callback);
|
_read(fs, context, fd, buffer, offset, length, position, callback);
|
||||||
|
@ -1502,7 +1543,7 @@ define(function(require) {
|
||||||
};
|
};
|
||||||
FileSystem.prototype.readFile = function(path, options, callback) {
|
FileSystem.prototype.readFile = function(path, options, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_readFile(fs, context, path, options, callback);
|
_readFile(fs, context, path, options, callback);
|
||||||
|
@ -1512,7 +1553,7 @@ define(function(require) {
|
||||||
};
|
};
|
||||||
FileSystem.prototype.write = function(fd, buffer, offset, length, position, callback) {
|
FileSystem.prototype.write = function(fd, buffer, offset, length, position, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_write(fs, context, fd, buffer, offset, length, position, callback);
|
_write(fs, context, fd, buffer, offset, length, position, callback);
|
||||||
|
@ -1523,7 +1564,7 @@ define(function(require) {
|
||||||
};
|
};
|
||||||
FileSystem.prototype.writeFile = function(path, data, options, callback) {
|
FileSystem.prototype.writeFile = function(path, data, options, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_writeFile(fs, context, path, data, options, callback);
|
_writeFile(fs, context, path, data, options, callback);
|
||||||
|
@ -1533,7 +1574,7 @@ define(function(require) {
|
||||||
};
|
};
|
||||||
FileSystem.prototype.lseek = function(fd, offset, whence, callback) {
|
FileSystem.prototype.lseek = function(fd, offset, whence, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_lseek(fs, context, fd, offset, whence, callback);
|
_lseek(fs, context, fd, offset, whence, callback);
|
||||||
|
@ -1543,7 +1584,7 @@ define(function(require) {
|
||||||
};
|
};
|
||||||
FileSystem.prototype.readdir = function(path, callback) {
|
FileSystem.prototype.readdir = function(path, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_readdir(context, path, callback);
|
_readdir(context, path, callback);
|
||||||
|
@ -1553,7 +1594,7 @@ define(function(require) {
|
||||||
};
|
};
|
||||||
FileSystem.prototype.rename = function(oldpath, newpath, callback) {
|
FileSystem.prototype.rename = function(oldpath, newpath, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_rename(context, oldpath, newpath, callback);
|
_rename(context, oldpath, newpath, callback);
|
||||||
|
@ -1563,7 +1604,7 @@ define(function(require) {
|
||||||
};
|
};
|
||||||
FileSystem.prototype.readlink = function(path, callback) {
|
FileSystem.prototype.readlink = function(path, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_readlink(context, path, callback);
|
_readlink(context, path, callback);
|
||||||
|
@ -1573,7 +1614,7 @@ define(function(require) {
|
||||||
};
|
};
|
||||||
FileSystem.prototype.symlink = function(srcpath, dstpath, callback) {
|
FileSystem.prototype.symlink = function(srcpath, dstpath, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_symlink(context, srcpath, dstpath, callback);
|
_symlink(context, srcpath, dstpath, callback);
|
||||||
|
@ -1583,7 +1624,7 @@ define(function(require) {
|
||||||
};
|
};
|
||||||
FileSystem.prototype.lstat = function(path, callback) {
|
FileSystem.prototype.lstat = function(path, callback) {
|
||||||
var fs = this;
|
var fs = this;
|
||||||
var error = FileSystemsManager.get(fs).queueOrRun(
|
var error = fs.queueOrRun(
|
||||||
function() {
|
function() {
|
||||||
var context = fs.provider.getReadWriteContext();
|
var context = fs.provider.getReadWriteContext();
|
||||||
_lstat(fs, context, path, callback);
|
_lstat(fs, context, path, callback);
|
||||||
|
@ -1593,8 +1634,7 @@ define(function(require) {
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
FileSystem: FileSystem,
|
FileSystem: FileSystem
|
||||||
Providers: Providers
|
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
define(function(require) {
|
define(function(require) {
|
||||||
|
var FILE_SYSTEM_NAME = require('src/constants').FILE_SYSTEM_NAME;
|
||||||
var FILE_STORE_NAME = require('src/constants').FILE_STORE_NAME;
|
var FILE_STORE_NAME = require('src/constants').FILE_STORE_NAME;
|
||||||
|
|
||||||
var indexedDB = window.indexedDB ||
|
var indexedDB = window.indexedDB ||
|
||||||
|
@ -72,7 +73,7 @@ define(function(require) {
|
||||||
|
|
||||||
|
|
||||||
function IndexedDB(name) {
|
function IndexedDB(name) {
|
||||||
this.name = name || "local";
|
this.name = name || FILE_SYSTEM_NAME;
|
||||||
this.db = null;
|
this.db = null;
|
||||||
}
|
}
|
||||||
IndexedDB.isSupported = function() {
|
IndexedDB.isSupported = function() {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
define(function(require) {
|
define(function(require) {
|
||||||
|
var FILE_SYSTEM_NAME = require('src/constants').FILE_SYSTEM_NAME;
|
||||||
|
|
||||||
function MemoryContext(db, readOnly) {
|
function MemoryContext(db, readOnly) {
|
||||||
this.readOnly = readOnly;
|
this.readOnly = readOnly;
|
||||||
|
@ -34,7 +35,7 @@ define(function(require) {
|
||||||
|
|
||||||
|
|
||||||
function Memory(name) {
|
function Memory(name) {
|
||||||
this.name = name || "local";
|
this.name = name || FILE_SYSTEM_NAME;
|
||||||
this.db = {};
|
this.db = {};
|
||||||
}
|
}
|
||||||
Memory.isSupported = function() {
|
Memory.isSupported = function() {
|
||||||
|
@ -42,7 +43,6 @@ define(function(require) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Memory.prototype.open = function(callback) {
|
Memory.prototype.open = function(callback) {
|
||||||
var that = this;
|
|
||||||
callback(null, true);
|
callback(null, true);
|
||||||
};
|
};
|
||||||
Memory.prototype.getReadOnlyContext = function() {
|
Memory.prototype.getReadOnlyContext = function() {
|
||||||
|
|
|
@ -103,7 +103,7 @@ describe('fs.stat', function() {
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_result).toBeDefined();
|
expect(_result).toBeDefined();
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_result['node']).toBeDefined();
|
expect(_result['node']).toBeDefined();
|
||||||
expect(_result['dev']).toEqual(that.db_name);
|
expect(_result['dev']).toEqual(that.db_name);
|
||||||
expect(_result['size']).toBeDefined();
|
expect(_result['size']).toBeDefined();
|
||||||
|
@ -149,7 +149,7 @@ describe('fs.stat', function() {
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_result).toBeDefined();
|
expect(_result).toBeDefined();
|
||||||
expect(_node).toBeDefined();
|
expect(_node).toBeDefined();
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_result['node']).toEqual(_node);
|
expect(_result['node']).toEqual(_node);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -196,7 +196,7 @@ describe('fs.fstat', function() {
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_result).toBeDefined();
|
expect(_result).toBeDefined();
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_result['node']).toBeDefined();
|
expect(_result['node']).toBeDefined();
|
||||||
expect(_result['dev']).toEqual(that.db_name);
|
expect(_result['dev']).toEqual(that.db_name);
|
||||||
expect(_result['size']).toBeDefined();
|
expect(_result['size']).toBeDefined();
|
||||||
|
@ -265,7 +265,7 @@ describe('fs.lstat', function() {
|
||||||
}, 'test to complete', DEFAULT_TIMEOUT);
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_result).toBeDefined();
|
expect(_result).toBeDefined();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -292,7 +292,7 @@ describe('fs.lstat', function() {
|
||||||
}, 'test to complete', DEFAULT_TIMEOUT);
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_result).toBeDefined();
|
expect(_result).toBeDefined();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -377,7 +377,7 @@ describe('fs.mkdir', function() {
|
||||||
}, 'test to complete', DEFAULT_TIMEOUT);
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_result).not.toBeDefined();
|
expect(_result).not.toBeDefined();
|
||||||
expect(_stat).toBeDefined();
|
expect(_stat).toBeDefined();
|
||||||
});
|
});
|
||||||
|
@ -441,7 +441,7 @@ describe('fs.readdir', function() {
|
||||||
}, 'test to complete', DEFAULT_TIMEOUT);
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_files.length).toEqual(1);
|
expect(_files.length).toEqual(1);
|
||||||
expect(_files[0]).toEqual('tmp');
|
expect(_files[0]).toEqual('tmp');
|
||||||
});
|
});
|
||||||
|
@ -470,7 +470,7 @@ describe('fs.readdir', function() {
|
||||||
}, 'test to complete', DEFAULT_TIMEOUT);
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_files.length).toEqual(1);
|
expect(_files.length).toEqual(1);
|
||||||
expect(_files[0]).toEqual('tmp');
|
expect(_files[0]).toEqual('tmp');
|
||||||
});
|
});
|
||||||
|
@ -630,7 +630,7 @@ describe('fs.rmdir', function() {
|
||||||
}, 'test to complete', DEFAULT_TIMEOUT);
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_stat).not.toBeDefined();
|
expect(_stat).not.toBeDefined();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -775,7 +775,7 @@ describe('fs.open', function() {
|
||||||
}, 'test to complete', DEFAULT_TIMEOUT);
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_result1).toBeDefined();
|
expect(_result1).toBeDefined();
|
||||||
expect(_result2).toBeDefined();
|
expect(_result2).toBeDefined();
|
||||||
expect(_result1).not.toEqual(_result2);
|
expect(_result1).not.toEqual(_result2);
|
||||||
|
@ -802,7 +802,7 @@ describe('fs.open', function() {
|
||||||
}, 'test to complete', DEFAULT_TIMEOUT);
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_result).toBeDefined();
|
expect(_result).toBeDefined();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -856,7 +856,7 @@ describe('fs.write', function() {
|
||||||
}, 'test to complete', DEFAULT_TIMEOUT);
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_result).toEqual(buffer.length);
|
expect(_result).toEqual(buffer.length);
|
||||||
expect(_stats.size).toEqual(buffer.length);
|
expect(_stats.size).toEqual(buffer.length);
|
||||||
});
|
});
|
||||||
|
@ -898,7 +898,7 @@ describe('fs.write', function() {
|
||||||
}, 'test to complete', DEFAULT_TIMEOUT);
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_result).toEqual(2 * buffer.length);
|
expect(_result).toEqual(2 * buffer.length);
|
||||||
expect(_stats.size).toEqual(_result);
|
expect(_stats.size).toEqual(_result);
|
||||||
});
|
});
|
||||||
|
@ -968,7 +968,7 @@ describe('fs.writeFile, fs.readFile', function() {
|
||||||
}, 'test to complete', DEFAULT_TIMEOUT);
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_result).toEqual(contents);
|
expect(_result).toEqual(contents);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -994,7 +994,7 @@ describe('fs.writeFile, fs.readFile', function() {
|
||||||
}, 'test to complete', DEFAULT_TIMEOUT);
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_result).toEqual(contents);
|
expect(_result).toEqual(contents);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1020,7 +1020,7 @@ describe('fs.writeFile, fs.readFile', function() {
|
||||||
}, 'test to complete', DEFAULT_TIMEOUT);
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_result).toEqual(contents);
|
expect(_result).toEqual(contents);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1048,7 +1048,7 @@ describe('fs.writeFile, fs.readFile', function() {
|
||||||
}, 'test to complete', DEFAULT_TIMEOUT);
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_result).toEqual(binary);
|
expect(_result).toEqual(binary);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1132,7 +1132,7 @@ describe('fs.read', function() {
|
||||||
}, 'test to complete', DEFAULT_TIMEOUT);
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_result).toEqual(rbuffer.length);
|
expect(_result).toEqual(rbuffer.length);
|
||||||
expect(typed_array_equal(wbuffer, rbuffer)).toEqual(true);
|
expect(typed_array_equal(wbuffer, rbuffer)).toEqual(true);
|
||||||
});
|
});
|
||||||
|
@ -1173,7 +1173,7 @@ describe('fs.read', function() {
|
||||||
}, 'test to complete', DEFAULT_TIMEOUT);
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_result).toEqual(rbuffer.length);
|
expect(_result).toEqual(rbuffer.length);
|
||||||
expect(typed_array_equal(wbuffer.buffer, rbuffer.buffer)).toEqual(true);
|
expect(typed_array_equal(wbuffer.buffer, rbuffer.buffer)).toEqual(true);
|
||||||
});
|
});
|
||||||
|
@ -1281,7 +1281,7 @@ describe('fs.link', function() {
|
||||||
}, 'test to complete', DEFAULT_TIMEOUT);
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_newstats.node).toEqual(_oldstats.node);
|
expect(_newstats.node).toEqual(_oldstats.node);
|
||||||
expect(_newstats.nlinks).toEqual(2);
|
expect(_newstats.nlinks).toEqual(2);
|
||||||
expect(_newstats).toEqual(_oldstats);
|
expect(_newstats).toEqual(_oldstats);
|
||||||
|
@ -1318,7 +1318,7 @@ describe('fs.link', function() {
|
||||||
}, 'test to complete', DEFAULT_TIMEOUT);
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
||||||
|
|
||||||
runs(function () {
|
runs(function () {
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_newstats.node).toEqual(_linkstats.node);
|
expect(_newstats.node).toEqual(_linkstats.node);
|
||||||
expect(_newstats.node).toNotEqual(_oldstats.node);
|
expect(_newstats.node).toNotEqual(_oldstats.node);
|
||||||
expect(_newstats.nlinks).toEqual(2);
|
expect(_newstats.nlinks).toEqual(2);
|
||||||
|
@ -1554,7 +1554,7 @@ describe('fs.lseek', function() {
|
||||||
}, 'test to complete', DEFAULT_TIMEOUT);
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
||||||
|
|
||||||
runs(function () {
|
runs(function () {
|
||||||
expect(_error1).not.toBeDefined();
|
expect(_error1).toEqual(null);
|
||||||
expect(_error2).toBeDefined();
|
expect(_error2).toBeDefined();
|
||||||
expect(_stats.nlinks).toEqual(1);
|
expect(_stats.nlinks).toEqual(1);
|
||||||
});
|
});
|
||||||
|
@ -1623,7 +1623,7 @@ describe('fs.lseek', function() {
|
||||||
}, 'test to complete', DEFAULT_TIMEOUT);
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_result).toEqual(offset);
|
expect(_result).toEqual(offset);
|
||||||
expect(_stats.size).toEqual(offset + buffer.length);
|
expect(_stats.size).toEqual(offset + buffer.length);
|
||||||
var expected = new Uint8Array([1, 2, 3, 1, 2, 3, 4, 5, 6, 7, 8]);
|
var expected = new Uint8Array([1, 2, 3, 1, 2, 3, 4, 5, 6, 7, 8]);
|
||||||
|
@ -1675,7 +1675,7 @@ describe('fs.lseek', function() {
|
||||||
}, 'test to complete', DEFAULT_TIMEOUT);
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_result).toEqual(offset + buffer.length);
|
expect(_result).toEqual(offset + buffer.length);
|
||||||
expect(_stats.size).toEqual(offset + 2 * buffer.length);
|
expect(_stats.size).toEqual(offset + 2 * buffer.length);
|
||||||
var expected = new Uint8Array([1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 8]);
|
var expected = new Uint8Array([1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 8]);
|
||||||
|
@ -1732,7 +1732,7 @@ describe('fs.lseek', function() {
|
||||||
}, 'test to complete', DEFAULT_TIMEOUT);
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_result).toEqual(offset + buffer.length);
|
expect(_result).toEqual(offset + buffer.length);
|
||||||
expect(_stats.size).toEqual(offset + 2 * buffer.length);
|
expect(_stats.size).toEqual(offset + 2 * buffer.length);
|
||||||
var expected = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8]);
|
var expected = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8]);
|
||||||
|
@ -1815,7 +1815,7 @@ describe('fs.symlink', function() {
|
||||||
}, 'test to complete', DEFAULT_TIMEOUT);
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_result).not.toBeDefined();
|
expect(_result).not.toBeDefined();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1899,7 +1899,7 @@ describe('fs.readlink', function() {
|
||||||
}, 'test to complete', DEFAULT_TIMEOUT);
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_result).toEqual('/');
|
expect(_result).toEqual('/');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1946,7 +1946,7 @@ describe('path resolution', function() {
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_result).toBeDefined();
|
expect(_result).toBeDefined();
|
||||||
expect(_node).toBeDefined();
|
expect(_node).toBeDefined();
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_result['node']).toEqual(_node);
|
expect(_result['node']).toEqual(_node);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1980,7 +1980,7 @@ describe('path resolution', function() {
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_result).toBeDefined();
|
expect(_result).toBeDefined();
|
||||||
expect(_node).toBeDefined();
|
expect(_node).toBeDefined();
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_result['node']).toEqual(_node);
|
expect(_result['node']).toEqual(_node);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -2019,7 +2019,7 @@ describe('path resolution', function() {
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_result).toBeDefined();
|
expect(_result).toBeDefined();
|
||||||
expect(_node).toBeDefined();
|
expect(_node).toBeDefined();
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_result['node']).toEqual(_node);
|
expect(_result['node']).toEqual(_node);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -2061,7 +2061,7 @@ describe('path resolution', function() {
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_result).toBeDefined();
|
expect(_result).toBeDefined();
|
||||||
expect(_node).toBeDefined();
|
expect(_node).toBeDefined();
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_result['node']).toEqual(_node);
|
expect(_result['node']).toEqual(_node);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -2204,7 +2204,7 @@ describe('path resolution', function() {
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(_result).toBeDefined();
|
expect(_result).toBeDefined();
|
||||||
expect(_node).toBeDefined();
|
expect(_node).toBeDefined();
|
||||||
expect(_error).not.toBeDefined();
|
expect(_error).toEqual(null);
|
||||||
expect(_result['node']).toEqual(_node);
|
expect(_result['node']).toEqual(_node);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
describe("IDBFS.Providers.IndexedDB", function() {
|
describe("IDBFS.FileSystem.providers.IndexedDB", function() {
|
||||||
it("is supported -- if it isn't, none of these tests can run.", function() {
|
it("is supported -- if it isn't, none of these tests can run.", function() {
|
||||||
expect(IDBFS.Providers.IndexedDB.isSupported()).toEqual(true);
|
expect(IDBFS.FileSystem.providers.IndexedDB.isSupported()).toEqual(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has open, getReadOnlyContext, and getReadWriteContext instance methods", function() {
|
it("has open, getReadOnlyContext, and getReadWriteContext instance methods", function() {
|
||||||
var indexedDBProvider = new IDBFS.Providers.IndexedDB();
|
var indexedDBProvider = new IDBFS.FileSystem.providers.IndexedDB();
|
||||||
expect(typeof indexedDBProvider.open).toEqual('function');
|
expect(typeof indexedDBProvider.open).toEqual('function');
|
||||||
expect(typeof indexedDBProvider.getReadOnlyContext).toEqual('function');
|
expect(typeof indexedDBProvider.getReadOnlyContext).toEqual('function');
|
||||||
expect(typeof indexedDBProvider.getReadWriteContext).toEqual('function');
|
expect(typeof indexedDBProvider.getReadWriteContext).toEqual('function');
|
||||||
|
@ -23,7 +23,7 @@ describe("IDBFS.Providers.IndexedDB", function() {
|
||||||
var complete = false;
|
var complete = false;
|
||||||
var _error, _result;
|
var _error, _result;
|
||||||
|
|
||||||
var provider = new IDBFS.Providers.IndexedDB(this.db_name);
|
var provider = new IDBFS.FileSystem.providers.IndexedDB(this.db_name);
|
||||||
provider.open(function(err, firstAccess) {
|
provider.open(function(err, firstAccess) {
|
||||||
_error = err;
|
_error = err;
|
||||||
_result = firstAccess;
|
_result = firstAccess;
|
||||||
|
@ -54,7 +54,7 @@ describe("IDBFS.Providers.IndexedDB", function() {
|
||||||
var complete = false;
|
var complete = false;
|
||||||
var _error, _result;
|
var _error, _result;
|
||||||
|
|
||||||
var provider = new IDBFS.Providers.IndexedDB(this.db_name);
|
var provider = new IDBFS.FileSystem.providers.IndexedDB(this.db_name);
|
||||||
provider.open(function(err, firstAccess) {
|
provider.open(function(err, firstAccess) {
|
||||||
_error = err;
|
_error = err;
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ describe("IDBFS.Providers.IndexedDB", function() {
|
||||||
var complete = false;
|
var complete = false;
|
||||||
var _error, _result;
|
var _error, _result;
|
||||||
|
|
||||||
var provider = new IDBFS.Providers.IndexedDB(this.db_name);
|
var provider = new IDBFS.FileSystem.providers.IndexedDB(this.db_name);
|
||||||
provider.open(function(err, firstAccess) {
|
provider.open(function(err, firstAccess) {
|
||||||
_error = err;
|
_error = err;
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ describe("IDBFS.Providers.IndexedDB", function() {
|
||||||
var complete = false;
|
var complete = false;
|
||||||
var _error, _result1, _result2;
|
var _error, _result1, _result2;
|
||||||
|
|
||||||
var provider = new IDBFS.Providers.IndexedDB(this.db_name);
|
var provider = new IDBFS.FileSystem.providers.IndexedDB(this.db_name);
|
||||||
provider.open(function(err, firstAccess) {
|
provider.open(function(err, firstAccess) {
|
||||||
_error = err;
|
_error = err;
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ describe("IDBFS.Providers.IndexedDB", function() {
|
||||||
var complete = false;
|
var complete = false;
|
||||||
var _error, _result;
|
var _error, _result;
|
||||||
|
|
||||||
var provider = new IDBFS.Providers.IndexedDB(this.db_name);
|
var provider = new IDBFS.FileSystem.providers.IndexedDB(this.db_name);
|
||||||
provider.open(function(err, firstAccess) {
|
provider.open(function(err, firstAccess) {
|
||||||
_error = err;
|
_error = err;
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
describe("IDBFS.Providers.Memory", function() {
|
describe("IDBFS.FileSystem.providers.Memory", function() {
|
||||||
it("is supported -- if it isn't, none of these tests can run.", function() {
|
it("is supported -- if it isn't, none of these tests can run.", function() {
|
||||||
expect(IDBFS.Providers.Memory.isSupported()).toEqual(true);
|
expect(IDBFS.FileSystem.providers.Memory.isSupported()).toEqual(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has open, getReadOnlyContext, and getReadWriteContext instance methods", function() {
|
it("has open, getReadOnlyContext, and getReadWriteContext instance methods", function() {
|
||||||
var indexedDBProvider = new IDBFS.Providers.Memory();
|
var indexedDBProvider = new IDBFS.FileSystem.providers.Memory();
|
||||||
expect(typeof indexedDBProvider.open).toEqual('function');
|
expect(typeof indexedDBProvider.open).toEqual('function');
|
||||||
expect(typeof indexedDBProvider.getReadOnlyContext).toEqual('function');
|
expect(typeof indexedDBProvider.getReadOnlyContext).toEqual('function');
|
||||||
expect(typeof indexedDBProvider.getReadWriteContext).toEqual('function');
|
expect(typeof indexedDBProvider.getReadWriteContext).toEqual('function');
|
||||||
|
@ -15,7 +15,7 @@ describe("IDBFS.Providers.Memory", function() {
|
||||||
var complete = false;
|
var complete = false;
|
||||||
var _error, _result;
|
var _error, _result;
|
||||||
|
|
||||||
var provider = new IDBFS.Providers.Memory(this.db_name);
|
var provider = new IDBFS.FileSystem.providers.Memory(this.db_name);
|
||||||
provider.open(function(err, firstAccess) {
|
provider.open(function(err, firstAccess) {
|
||||||
_error = err;
|
_error = err;
|
||||||
_result = firstAccess;
|
_result = firstAccess;
|
||||||
|
@ -38,7 +38,7 @@ describe("IDBFS.Providers.Memory", function() {
|
||||||
var complete = false;
|
var complete = false;
|
||||||
var _error, _result;
|
var _error, _result;
|
||||||
|
|
||||||
var provider = new IDBFS.Providers.Memory(this.db_name);
|
var provider = new IDBFS.FileSystem.providers.Memory(this.db_name);
|
||||||
provider.open(function(err, firstAccess) {
|
provider.open(function(err, firstAccess) {
|
||||||
_error = err;
|
_error = err;
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ describe("IDBFS.Providers.Memory", function() {
|
||||||
var complete = false;
|
var complete = false;
|
||||||
var _error, _result;
|
var _error, _result;
|
||||||
|
|
||||||
var provider = new IDBFS.Providers.Memory(this.db_name);
|
var provider = new IDBFS.FileSystem.providers.Memory(this.db_name);
|
||||||
provider.open(function(err, firstAccess) {
|
provider.open(function(err, firstAccess) {
|
||||||
_error = err;
|
_error = err;
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ describe("IDBFS.Providers.Memory", function() {
|
||||||
var complete = false;
|
var complete = false;
|
||||||
var _error, _result1, _result2;
|
var _error, _result1, _result2;
|
||||||
|
|
||||||
var provider = new IDBFS.Providers.Memory(this.db_name);
|
var provider = new IDBFS.FileSystem.providers.Memory(this.db_name);
|
||||||
provider.open(function(err, firstAccess) {
|
provider.open(function(err, firstAccess) {
|
||||||
_error = err;
|
_error = err;
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ describe("IDBFS.Providers.Memory", function() {
|
||||||
var complete = false;
|
var complete = false;
|
||||||
var _error, _result;
|
var _error, _result;
|
||||||
|
|
||||||
var provider = new IDBFS.Providers.Memory(this.db_name);
|
var provider = new IDBFS.FileSystem.providers.Memory(this.db_name);
|
||||||
provider.open(function(err, firstAccess) {
|
provider.open(function(err, firstAccess) {
|
||||||
_error = err;
|
_error = err;
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,17 @@
|
||||||
describe("IDBFS.Providers", function() {
|
describe("IDBFS.Providers", function() {
|
||||||
it("is defined", function() {
|
it("is defined", function() {
|
||||||
expect(typeof IDBFS.Providers).not.toEqual(undefined);
|
expect(typeof IDBFS.FileSystem.providers).not.toEqual(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has IndexedDB constructor", function() {
|
it("has IndexedDB constructor", function() {
|
||||||
expect(typeof IDBFS.Providers.IndexedDB).toEqual('function');
|
expect(typeof IDBFS.FileSystem.providers.IndexedDB).toEqual('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has Memory constructor", function() {
|
it("has Memory constructor", function() {
|
||||||
expect(typeof IDBFS.Providers.Memory).toEqual('function');
|
expect(typeof IDBFS.FileSystem.providers.Memory).toEqual('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has a Default constructor", function() {
|
it("has a Default constructor", function() {
|
||||||
expect(typeof IDBFS.Providers.Default).toEqual('function');
|
expect(typeof IDBFS.FileSystem.providers.Default).toEqual('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue