Refactor errors code, fix to better match node
This commit is contained in:
parent
8945514285
commit
fe7ec79f83
22
README.md
22
README.md
|
@ -208,28 +208,36 @@ For more info see the docs in the [path module](http://nodejs.org/api/path.html)
|
|||
####Filer.Errors<a name="Errors"></a>
|
||||
|
||||
The error objects used internally by Filer are also exposed via the `Filer.Errors` object. As much as possible
|
||||
these match their node.js counterparts. See [src/errors.js](https://github.com/js-platform/filer/blob/develop/src/errors.js)
|
||||
for the complete list. Errors can be used, or compared, like so:
|
||||
these match their node.js counterparts, with a few Filer-specifc additions.
|
||||
See [src/errors.js](https://github.com/js-platform/filer/blob/develop/src/errors.js) for the complete
|
||||
list. Errors can be used, or compared, like so:
|
||||
|
||||
Examples:
|
||||
|
||||
```javascript
|
||||
// Example 1: create an EExists error
|
||||
var err = new Filer.Errors.EExists();
|
||||
// Example 1: create an EExist error
|
||||
var err1 = new Filer.Errors.EEXIST();
|
||||
var err2 = new Filer.Errors[47];
|
||||
|
||||
// Example 2: compare an error to see if it is EInvalid
|
||||
function callback(err) {
|
||||
if(err instanceof Filer.Errors.EInvalid){
|
||||
if(err instanceof Filer.Errors.EINVAL){
|
||||
...
|
||||
}
|
||||
|
||||
// Or compare the error's code
|
||||
if(err.code === 'EINVALID') {
|
||||
if(err.code === 'EINVAL') {
|
||||
...
|
||||
}
|
||||
}
|
||||
|
||||
// Example 3: display the error message
|
||||
// Example 4: compare an error using errno
|
||||
function callback(err) {
|
||||
if(err.errno === 47){
|
||||
...
|
||||
}
|
||||
|
||||
// Example 5: display the error message
|
||||
console.log(err.message);
|
||||
```
|
||||
|
||||
|
|
666
src/errors.js
666
src/errors.js
|
@ -1,580 +1,100 @@
|
|||
/*
|
||||
Copyright (c) 2012, Alan Kligman
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
Neither the name of the Mozilla Foundation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
Errors based off Node.js custom errors (https://github.com/rvagg/node-errno) made available under the MIT license
|
||||
*/
|
||||
|
||||
define(function(require) {
|
||||
// 'use strict';
|
||||
var errors = {};
|
||||
var errno = -1;
|
||||
|
||||
function Unknown(message){
|
||||
this.message = message || 'unknown error';
|
||||
/**
|
||||
* DON'T CHANGE THE ORDER OF THIS ARRAY!!
|
||||
* The errno property follows the order from -1 upward
|
||||
*/
|
||||
[
|
||||
/**
|
||||
* node.js errors
|
||||
*/
|
||||
'UNKNOWN:unknown error',
|
||||
'OK:success',
|
||||
'EOF:end of file',
|
||||
'EADDRINFO:getaddrinfo error',
|
||||
'EACCES:permission denied',
|
||||
'EAGAIN:resource temporarily unavailable',
|
||||
'EADDRINUSE:address already in use',
|
||||
'EADDRNOTAVAIL:address not available',
|
||||
'EAFNOSUPPORT:address family not supported',
|
||||
'EALREADY:connection already in progress',
|
||||
'EBADF:bad file descriptor',
|
||||
'EBUSY:resource busy or locked',
|
||||
'ECONNABORTED:software caused connection abort',
|
||||
'ECONNREFUSED:connection refused',
|
||||
'ECONNRESET:connection reset by peer',
|
||||
'EDESTADDRREQ:destination address required',
|
||||
'EFAULT:bad address in system call argument',
|
||||
'EHOSTUNREACH:host is unreachable',
|
||||
'EINTR:interrupted system call',
|
||||
'EINVAL:invalid argument',
|
||||
'EISCONN:socket is already connected',
|
||||
'EMFILE:too many open files',
|
||||
'EMSGSIZE:message too long',
|
||||
'ENETDOWN:network is down',
|
||||
'ENETUNREACH:network is unreachable',
|
||||
'ENFILE:file table overflow',
|
||||
'ENOBUFS:no buffer space available',
|
||||
'ENOMEM:not enough memory',
|
||||
'ENOTDIR:not a directory',
|
||||
'EISDIR:illegal operation on a directory',
|
||||
'ENONET:machine is not on the network',
|
||||
'ENOTCONN:socket is not connected',
|
||||
'ENOTSOCK:socket operation on non-socket',
|
||||
'ENOTSUP:operation not supported on socket',
|
||||
'ENOENT:no such file or directory',
|
||||
'ENOSYS:function not implemented',
|
||||
'EPIPE:broken pipe',
|
||||
'EPROTO:protocol error',
|
||||
'EPROTONOSUPPORT:protocol not supported',
|
||||
'EPROTOTYPE:protocol wrong type for socket',
|
||||
'ETIMEDOUT:connection timed out',
|
||||
'ECHARSET:invalid Unicode character',
|
||||
'EAIFAMNOSUPPORT:address family for hostname not supported',
|
||||
'EAISERVICE:servname not supported for ai_socktype',
|
||||
'EAISOCKTYPE:ai_socktype not supported',
|
||||
'ESHUTDOWN:cannot send after transport endpoint shutdown',
|
||||
'EEXIST:file already exists',
|
||||
'ESRCH:no such process',
|
||||
'ENAMETOOLONG:name too long',
|
||||
'EPERM:operation not permitted',
|
||||
'ELOOP:too many symbolic links encountered',
|
||||
'EXDEV:cross-device link not permitted',
|
||||
'ENOTEMPTY:directory not empty',
|
||||
'ENOSPC:no space left on device',
|
||||
'EIO:i/o error',
|
||||
'EROFS:read-only file system',
|
||||
'ENODEV:no such device',
|
||||
'ESPIPE:invalid seek',
|
||||
'ECANCELED:operation canceled',
|
||||
|
||||
/**
|
||||
* Filer specific errors
|
||||
*/
|
||||
'ENOTMOUNTED:not mounted',
|
||||
'EFILESYSTEMERROR:missing super node',
|
||||
'ENOATTR:attribute does not exist'
|
||||
|
||||
].forEach(function(e) {
|
||||
e = e.split(':');
|
||||
var err = e[0];
|
||||
var message = e[1];
|
||||
|
||||
function ctor(m) {
|
||||
this.message = m || message;
|
||||
}
|
||||
Unknown.prototype = new Error();
|
||||
Unknown.prototype.errno = -1;
|
||||
Unknown.prototype.code = "UNKNOWN";
|
||||
Unknown.prototype.constructor = Unknown;
|
||||
var proto = ctor.prototype = new Error();
|
||||
proto.errno = errno;
|
||||
proto.code = err;
|
||||
proto.constructor = ctor;
|
||||
|
||||
function OK(message){
|
||||
this.message = message || 'success';
|
||||
}
|
||||
OK.prototype = new Error();
|
||||
OK.prototype.errno = 0;
|
||||
OK.prototype.code = "OK";
|
||||
OK.prototype.constructor = OK;
|
||||
// We expose the error as both Errors.EINVAL and Errors[18]
|
||||
errors[err] = errors[errno] = ctor;
|
||||
|
||||
function EOF(message){
|
||||
this.message = message || 'end of file';
|
||||
}
|
||||
EOF.prototype = new Error();
|
||||
EOF.prototype.errno = 1;
|
||||
EOF.prototype.code = "EOF";
|
||||
EOF.prototype.constructor = EOF;
|
||||
|
||||
function EAddrInfo(message){
|
||||
this.message = message || 'getaddrinfo error';
|
||||
}
|
||||
EAddrInfo.prototype = new Error();
|
||||
EAddrInfo.prototype.errno = 2;
|
||||
EAddrInfo.prototype.code = "EADDRINFO";
|
||||
EAddrInfo.prototype.constructor = EAddrInfo;
|
||||
|
||||
function EAcces(message){
|
||||
this.message = message || 'permission denied';
|
||||
}
|
||||
EAcces.prototype = new Error();
|
||||
EAcces.prototype.errno = 3;
|
||||
EAcces.prototype.code = "EACCES";
|
||||
EAcces.prototype.constructor = EAcces;
|
||||
|
||||
function EAgain(message){
|
||||
this.message = message || 'resource temporarily unavailable';
|
||||
}
|
||||
EAgain.prototype = new Error();
|
||||
EAgain.prototype.errno = 4;
|
||||
EAgain.prototype.code = "EAGAIN";
|
||||
EAgain.prototype.constructor = EAgain;
|
||||
|
||||
function EAddrInUse(message){
|
||||
this.message = message || 'address already in use';
|
||||
}
|
||||
EAddrInUse.prototype = new Error();
|
||||
EAddrInUse.prototype.errno = 5;
|
||||
EAddrInUse.prototype.code = "EADDRINUSE";
|
||||
EAddrInUse.prototype.constructor = EAddrInUse;
|
||||
|
||||
function EAddrNotAvail(message){
|
||||
this.message = message || 'address not available';
|
||||
}
|
||||
EAddrNotAvail.prototype = new Error();
|
||||
EAddrNotAvail.prototype.errno = 6;
|
||||
EAddrNotAvail.prototype.code = "EADDRNOTAVAIL";
|
||||
EAddrNotAvail.prototype.constructor = EAddrNotAvail;
|
||||
|
||||
function EAFNoSupport(message){
|
||||
this.message = message || 'address family not supported';
|
||||
}
|
||||
EAFNoSupport.prototype = new Error();
|
||||
EAFNoSupport.prototype.errno = 7;
|
||||
EAFNoSupport.prototype.code = "EAFNOSUPPORT";
|
||||
EAFNoSupport.prototype.constructor = EAFNoSupport;
|
||||
|
||||
function EAlready(message){
|
||||
this.message = message || 'connection already in progress';
|
||||
}
|
||||
EAlready.prototype = new Error();
|
||||
EAlready.prototype.errno = 8;
|
||||
EAlready.prototype.code = "EALREADY";
|
||||
EAlready.prototype.constructor = EAlready;
|
||||
|
||||
function EBadFileDescriptor(message){
|
||||
this.message = message || 'bad file descriptor';
|
||||
}
|
||||
EBadFileDescriptor.prototype = new Error();
|
||||
EBadFileDescriptor.prototype.errno = 9;
|
||||
EBadFileDescriptor.prototype.code = "EBADF";
|
||||
EBadFileDescriptor.prototype.constructor = EBadFileDescriptor;
|
||||
|
||||
function EBusy(message){
|
||||
this.message = message || 'resource busy or locked';
|
||||
}
|
||||
EBusy.prototype = new Error();
|
||||
EBusy.prototype.errno = 10;
|
||||
EBusy.prototype.code = "EBUSY";
|
||||
EBusy.prototype.constructor = EBusy;
|
||||
|
||||
function EConnAborted(message){
|
||||
this.message = message || 'software caused connection abort';
|
||||
}
|
||||
EConnAborted.prototype = new Error();
|
||||
EConnAborted.prototype.errno = 11;
|
||||
EConnAborted.prototype.code = "ECONNABORTED";
|
||||
EConnAborted.prototype.constructor = EConnAborted;
|
||||
|
||||
function EConnRefused(message){
|
||||
this.message = message || 'connection refused';
|
||||
}
|
||||
EConnRefused.prototype = new Error();
|
||||
EConnRefused.prototype.errno = 12;
|
||||
EConnRefused.prototype.code = "ECONNREFUSED";
|
||||
EConnRefused.prototype.constructor = EConnRefused;
|
||||
|
||||
function EConnReset(message){
|
||||
this.message = message || 'connection reset by peer';
|
||||
}
|
||||
EConnReset.prototype = new Error();
|
||||
EConnReset.prototype.errno = 13;
|
||||
EConnReset.prototype.code = "ECONNRESET";
|
||||
EConnReset.prototype.constructor = EConnReset;
|
||||
|
||||
function EDestAddrReq(message){
|
||||
this.message = message || 'destination address required';
|
||||
}
|
||||
EDestAddrReq.prototype = new Error();
|
||||
EDestAddrReq.prototype.errno = 14;
|
||||
EDestAddrReq.prototype.code = "EDESTADDRREQ";
|
||||
EDestAddrReq.prototype.constructor = EDestAddrReq;
|
||||
|
||||
function EFault(message){
|
||||
this.message = message || 'bad address in system call argument';
|
||||
}
|
||||
EFault.prototype = new Error();
|
||||
EFault.prototype.errno = 15;
|
||||
EFault.prototype.code = "EFAULT";
|
||||
EFault.prototype.constructor = EFault;
|
||||
|
||||
function EHostUnreach(message){
|
||||
this.message = message || 'host is unreachable';
|
||||
}
|
||||
EHostUnreach.prototype = new Error();
|
||||
EHostUnreach.prototype.errno = 16;
|
||||
EHostUnreach.prototype.code = "EHOSTUNREACH";
|
||||
EHostUnreach.prototype.constructor = EHostUnreach;
|
||||
|
||||
function EIntr(message){
|
||||
this.message = message || 'interrupted system call';
|
||||
}
|
||||
EIntr.prototype = new Error();
|
||||
EIntr.prototype.errno = 17;
|
||||
EIntr.prototype.code = "EINTR";
|
||||
EIntr.prototype.constructor = EIntr;
|
||||
|
||||
function EInvalid(message){
|
||||
this.message = message || 'invalid argument';
|
||||
}
|
||||
EInvalid.prototype = new Error();
|
||||
EInvalid.prototype.errno = 18;
|
||||
EInvalid.prototype.code = "EINVAL";
|
||||
EInvalid.prototype.constructor = EInvalid;
|
||||
|
||||
function EIsConn(message){
|
||||
this.message = message || 'socket is already connected';
|
||||
}
|
||||
EIsConn.prototype = new Error();
|
||||
EIsConn.prototype.errno = 19;
|
||||
EIsConn.prototype.code = "EISCONN";
|
||||
EIsConn.prototype.constructor = EIsConn;
|
||||
|
||||
function EMFile(message){
|
||||
this.message = message || 'too many open files';
|
||||
}
|
||||
EMFile.prototype = new Error();
|
||||
EMFile.prototype.errno = 20;
|
||||
EMFile.prototype.code = "EMFILE";
|
||||
EMFile.prototype.constructor = EMFile;
|
||||
|
||||
function EMsgSize(message){
|
||||
this.message = message || 'message too long';
|
||||
}
|
||||
EMsgSize.prototype = new Error();
|
||||
EMsgSize.prototype.errno = 21;
|
||||
EMsgSize.prototype.code = "EMSGSIZE";
|
||||
EMsgSize.prototype.constructor = EMsgSize;
|
||||
|
||||
function ENetDown(message){
|
||||
this.message = message || 'network is down';
|
||||
}
|
||||
ENetDown.prototype = new Error();
|
||||
ENetDown.prototype.errno = 22;
|
||||
ENetDown.prototype.code = "ENETDOWN";
|
||||
ENetDown.prototype.constructor = ENetDown;
|
||||
|
||||
function ENetUnreach(message){
|
||||
this.message = message || 'network is unreachable';
|
||||
}
|
||||
ENetUnreach.prototype = new Error();
|
||||
ENetUnreach.prototype.errno = 23;
|
||||
ENetUnreach.prototype.code = "ENETUNREACH";
|
||||
ENetUnreach.prototype.constructor = ENetUnreach;
|
||||
|
||||
function ENFile(message){
|
||||
this.message = message || 'file table overflow';
|
||||
}
|
||||
ENFile.prototype = new Error();
|
||||
ENFile.prototype.errno = 24;
|
||||
ENFile.prototype.code = "ENFILE";
|
||||
ENFile.prototype.constructor = ENFile;
|
||||
|
||||
function ENoBufS(message){
|
||||
this.message = message || 'no buffer space available';
|
||||
}
|
||||
ENoBufS.prototype = new Error();
|
||||
ENoBufS.prototype.errno = 25;
|
||||
ENoBufS.prototype.code = "ENOBUFS";
|
||||
ENoBufS.prototype.constructor = ENoBufS;
|
||||
|
||||
function ENoMem(message){
|
||||
this.message = message || 'not enough memory';
|
||||
}
|
||||
ENoMem.prototype = new Error();
|
||||
ENoMem.prototype.errno = 26;
|
||||
ENoMem.prototype.code = "ENOMEM";
|
||||
ENoMem.prototype.constructor = ENoMem;
|
||||
|
||||
function ENotDirectory(message){
|
||||
this.message = message || 'not a directory';
|
||||
}
|
||||
ENotDirectory.prototype = new Error();
|
||||
ENotDirectory.prototype.errno = 27;
|
||||
ENotDirectory.prototype.code = "ENOTDIR";
|
||||
ENotDirectory.prototype.constructor = ENotDirectory;
|
||||
|
||||
function EIsDirectory(message){
|
||||
this.message = message || 'illegal operation on a directory';
|
||||
}
|
||||
EIsDirectory.prototype = new Error();
|
||||
EIsDirectory.prototype.errno = 28;
|
||||
EIsDirectory.prototype.code = "EISDIR";
|
||||
EIsDirectory.prototype.constructor = EIsDirectory;
|
||||
|
||||
function ENoNet(message){
|
||||
this.message = message || 'machine is not on the network';
|
||||
}
|
||||
ENoNet.prototype = new Error();
|
||||
ENoNet.prototype.errno = 29;
|
||||
ENoNet.prototype.code = "ENONET";
|
||||
ENoNet.prototype.constructor = ENoNet;
|
||||
|
||||
function ENotConn(message){
|
||||
this.message = message || 'socket is not connected';
|
||||
}
|
||||
ENotConn.prototype = new Error();
|
||||
ENotConn.prototype.errno = 31;
|
||||
ENotConn.prototype.code = "ENOTCONN";
|
||||
ENotConn.prototype.constructor = ENotConn;
|
||||
|
||||
function ENotSock(message){
|
||||
this.message = message || 'socket operation on non-socket';
|
||||
}
|
||||
ENotSock.prototype = new Error();
|
||||
ENotSock.prototype.errno = 32;
|
||||
ENotSock.prototype.code = "ENOTSOCK";
|
||||
ENotSock.prototype.constructor = ENotSock;
|
||||
|
||||
function ENotSup(message){
|
||||
this.message = message || 'operation not supported on socket';
|
||||
}
|
||||
ENotSup.prototype = new Error();
|
||||
ENotSup.prototype.errno = 33;
|
||||
ENotSup.prototype.code = "ENOTSUP";
|
||||
ENotSup.prototype.constructor = ENotSup;
|
||||
|
||||
function ENoEntry(message){
|
||||
this.message = message || 'no such file or directory';
|
||||
}
|
||||
ENoEntry.prototype = new Error();
|
||||
ENoEntry.prototype.errno = 34;
|
||||
ENoEntry.prototype.code = "ENOENT";
|
||||
ENoEntry.prototype.constructor = ENoEntry;
|
||||
|
||||
function ENotImplemented(message){
|
||||
this.message = message || 'function not implemented';
|
||||
}
|
||||
ENotImplemented.prototype = new Error();
|
||||
ENotImplemented.prototype.errno = 35;
|
||||
ENotImplemented.prototype.code = "ENOSYS";
|
||||
ENotImplemented.prototype.constructor = ENotImplemented;
|
||||
|
||||
function EPipe(message){
|
||||
this.message = message || 'broken pipe';
|
||||
}
|
||||
EPipe.prototype = new Error();
|
||||
EPipe.prototype.errno = 36;
|
||||
EPipe.prototype.code = "EPIPE";
|
||||
EPipe.prototype.constructor = EPipe;
|
||||
|
||||
function EProto(message){
|
||||
this.message = message || 'protocol error';
|
||||
}
|
||||
EProto.prototype = new Error();
|
||||
EProto.prototype.errno = 37;
|
||||
EProto.prototype.code = "EPROTO";
|
||||
EProto.prototype.constructor = EProto;
|
||||
|
||||
function EProtoNoSupport(message){
|
||||
this.message = message || 'protocol not supported';
|
||||
}
|
||||
EProtoNoSupport.prototype = new Error();
|
||||
EProtoNoSupport.prototype.errno = 38;
|
||||
EProtoNoSupport.prototype.code = "EPROTONOSUPPORT";
|
||||
EProtoNoSupport.prototype.constructor = EProtoNoSupport;
|
||||
|
||||
function EPrototype(message){
|
||||
this.message = message || 'protocol wrong type for socket';
|
||||
}
|
||||
EPrototype.prototype = new Error();
|
||||
EPrototype.prototype.errno = 39;
|
||||
EPrototype.prototype.code = "EPROTOTYPE";
|
||||
EPrototype.prototype.constructor = EPrototype;
|
||||
|
||||
function ETimedOut(message){
|
||||
this.message = message || 'connection timed out';
|
||||
}
|
||||
ETimedOut.prototype = new Error();
|
||||
ETimedOut.prototype.errno = 40;
|
||||
ETimedOut.prototype.code = "ETIMEDOUT";
|
||||
ETimedOut.prototype.constructor = ETimedOut;
|
||||
|
||||
function ECharset(message){
|
||||
this.message = message || 'invalid Unicode character';
|
||||
}
|
||||
ECharset.prototype = new Error();
|
||||
ECharset.prototype.errno = 41;
|
||||
ECharset.prototype.code = "ECHARSET";
|
||||
ECharset.prototype.constructor = ECharset;
|
||||
|
||||
function EAIFamNoSupport(message){
|
||||
this.message = message || 'address family for hostname not supported';
|
||||
}
|
||||
EAIFamNoSupport.prototype = new Error();
|
||||
EAIFamNoSupport.prototype.errno = 42;
|
||||
EAIFamNoSupport.prototype.code = "EAIFAMNOSUPPORT";
|
||||
EAIFamNoSupport.prototype.constructor = EAIFamNoSupport;
|
||||
|
||||
function EAIService(message){
|
||||
this.message = message || 'servname not supported for ai_socktype';
|
||||
}
|
||||
EAIService.prototype = new Error();
|
||||
EAIService.prototype.errno = 44;
|
||||
EAIService.prototype.code = "EAISERVICE";
|
||||
EAIService.prototype.constructor = EAIService;
|
||||
|
||||
function EAISockType(message){
|
||||
this.message = message || 'ai_socktype not supported';
|
||||
}
|
||||
EAISockType.prototype = new Error();
|
||||
EAISockType.prototype.errno = 45;
|
||||
EAISockType.prototype.code = "EAISOCKTYPE";
|
||||
EAISockType.prototype.constructor = EAISockType;
|
||||
|
||||
function EShutdown(message){
|
||||
this.message = message || 'cannot send after transport endpoint shutdown';
|
||||
}
|
||||
EShutdown.prototype = new Error();
|
||||
EShutdown.prototype.errno = 46;
|
||||
EShutdown.prototype.code = "ESHUTDOWN";
|
||||
EShutdown.prototype.constructor = EShutdown;
|
||||
|
||||
function EExists(message){
|
||||
this.message = message || 'file already exists';
|
||||
}
|
||||
EExists.prototype = new Error();
|
||||
EExists.prototype.errno = 47;
|
||||
EExists.prototype.code = "EEXIST";
|
||||
EExists.prototype.constructor = EExists;
|
||||
|
||||
function ESrch(message){
|
||||
this.message = message || 'no such process';
|
||||
}
|
||||
ESrch.prototype = new Error();
|
||||
ESrch.prototype.errno = 48;
|
||||
ESrch.prototype.code = "ESRCH";
|
||||
ESrch.prototype.constructor = ESrch;
|
||||
|
||||
function ENameTooLong(message){
|
||||
this.message = message || 'name too long';
|
||||
}
|
||||
ENameTooLong.prototype = new Error();
|
||||
ENameTooLong.prototype.errno = 49;
|
||||
ENameTooLong.prototype.code = "ENAMETOOLONG";
|
||||
ENameTooLong.prototype.constructor = ENameTooLong;
|
||||
|
||||
function EPerm(message){
|
||||
this.message = message || 'operation not permitted';
|
||||
}
|
||||
EPerm.prototype = new Error();
|
||||
EPerm.prototype.errno = 50;
|
||||
EPerm.prototype.code = "EPERM";
|
||||
EPerm.prototype.constructor = EPerm;
|
||||
|
||||
function ELoop(message){
|
||||
this.message = message || 'too many symbolic links encountered';
|
||||
}
|
||||
ELoop.prototype = new Error();
|
||||
ELoop.prototype.errno = 51;
|
||||
ELoop.prototype.code = "ELOOP";
|
||||
ELoop.prototype.constructor = ELoop;
|
||||
|
||||
function EXDev(message){
|
||||
this.message = message || 'cross-device link not permitted';
|
||||
}
|
||||
EXDev.prototype = new Error();
|
||||
EXDev.prototype.errno = 52;
|
||||
EXDev.prototype.code = "EXDEV";
|
||||
EXDev.prototype.constructor = EXDev;
|
||||
|
||||
function ENotEmpty(message){
|
||||
this.message = message || 'directory not empty';
|
||||
}
|
||||
ENotEmpty.prototype = new Error();
|
||||
ENotEmpty.prototype.errno = 53;
|
||||
ENotEmpty.prototype.code = "ENOTEMPTY";
|
||||
ENotEmpty.prototype.constructor = ENotEmpty;
|
||||
|
||||
function ENoSpc(message){
|
||||
this.message = message || 'no space left on device';
|
||||
}
|
||||
ENoSpc.prototype = new Error();
|
||||
ENoSpc.prototype.errno = 54;
|
||||
ENoSpc.prototype.code = "ENOSPC";
|
||||
ENoSpc.prototype.constructor = ENoSpc;
|
||||
|
||||
function EIO(message){
|
||||
this.message = message || 'i/o error';
|
||||
}
|
||||
EIO.prototype = new Error();
|
||||
EIO.prototype.errno = 55;
|
||||
EIO.prototype.code = "EIO";
|
||||
EIO.prototype.constructor = EIO;
|
||||
|
||||
function EROFS(message){
|
||||
this.message = message || 'read-only file system';
|
||||
}
|
||||
EROFS.prototype = new Error();
|
||||
EROFS.prototype.errno = 56;
|
||||
EROFS.prototype.code = "EROFS";
|
||||
EROFS.prototype.constructor = EROFS;
|
||||
|
||||
function ENoDev(message){
|
||||
this.message = message || 'no such device';
|
||||
}
|
||||
ENoDev.prototype = new Error();
|
||||
ENoDev.prototype.errno = 57;
|
||||
ENoDev.prototype.code = "ENODEV";
|
||||
ENoDev.prototype.constructor = ENoDev;
|
||||
|
||||
function ESPipe(message){
|
||||
this.message = message || 'invalid seek';
|
||||
}
|
||||
ESPipe.prototype = new Error();
|
||||
ESPipe.prototype.errno = 58;
|
||||
ESPipe.prototype.code = "ESPIPE";
|
||||
ESPipe.prototype.constructor = ESPipe;
|
||||
|
||||
function ECanceled(message){
|
||||
this.message = message || 'operation canceled';
|
||||
}
|
||||
ECanceled.prototype = new Error();
|
||||
ECanceled.prototype.errno = 59;
|
||||
ECanceled.prototype.code = "ECANCELED";
|
||||
ECanceled.prototype.constructor = ECanceled;
|
||||
|
||||
function ENotMounted(message){
|
||||
this.message = message || 'not mounted';
|
||||
}
|
||||
ENotMounted.prototype = new Error();
|
||||
ENotMounted.prototype.errno = 60;
|
||||
ENotMounted.prototype.code = "ENotMounted";
|
||||
ENotMounted.prototype.constructor = ENotMounted;
|
||||
|
||||
function EFileSystemError(message){
|
||||
this.message = message || 'missing super node';
|
||||
}
|
||||
EFileSystemError.prototype = new Error();
|
||||
EFileSystemError.prototype.errno = 61;
|
||||
EFileSystemError.prototype.code = "EFileSystemError";
|
||||
EFileSystemError.prototype.constructor = EFileSystemError;
|
||||
|
||||
function ENoAttr(message) {
|
||||
this.message = message || 'attribute does not exist';
|
||||
}
|
||||
ENoAttr.prototype = new Error();
|
||||
ENoAttr.prototype.errno = 62;
|
||||
ENoAttr.prototype.code = 'ENoAttr';
|
||||
ENoAttr.prototype.constructor = ENoAttr;
|
||||
|
||||
return {
|
||||
Unknown: Unknown,
|
||||
OK: OK,
|
||||
EOF: EOF,
|
||||
EAddrInfo: EAddrInfo,
|
||||
EAcces: EAcces,
|
||||
EAgain: EAgain,
|
||||
EAddrInUse: EAddrInUse,
|
||||
EAddrNotAvail: EAddrNotAvail,
|
||||
EAFNoSupport: EAFNoSupport,
|
||||
EAlready: EAlready,
|
||||
EBadFileDescriptor: EBadFileDescriptor,
|
||||
EBusy: EBusy,
|
||||
EConnAborted: EConnAborted,
|
||||
EConnRefused: EConnRefused,
|
||||
EConnReset: EConnReset,
|
||||
EDestAddrReq: EDestAddrReq,
|
||||
EFault: EFault,
|
||||
EHostUnreach: EHostUnreach,
|
||||
EIntr: EIntr,
|
||||
EInvalid: EInvalid,
|
||||
EIsConn: EIsConn,
|
||||
EMFile: EMFile,
|
||||
EMsgSize: EMsgSize,
|
||||
ENetDown: ENetDown,
|
||||
ENetUnreach: ENetUnreach,
|
||||
ENFile: ENFile,
|
||||
ENoBufS: ENoBufS,
|
||||
ENoMem: ENoMem,
|
||||
ENotDirectory: ENotDirectory,
|
||||
EIsDirectory: EIsDirectory,
|
||||
ENoNet: ENoNet,
|
||||
ENotConn: ENotConn,
|
||||
ENotSock: ENotSock,
|
||||
ENotSup: ENotSup,
|
||||
ENoEntry: ENoEntry,
|
||||
ENotImplemented: ENotImplemented,
|
||||
EPipe: EPipe,
|
||||
EProto: EProto,
|
||||
EProtoNoSupport: EProtoNoSupport,
|
||||
EPrototype: EPrototype,
|
||||
ETimedOut: ETimedOut,
|
||||
ECharset: ECharset,
|
||||
EAIFamNoSupport: EAIFamNoSupport,
|
||||
EAIService: EAIService,
|
||||
EAISockType: EAISockType,
|
||||
EShutdown: EShutdown,
|
||||
EExists: EExists,
|
||||
ESrch: ESrch,
|
||||
ENameTooLong: ENameTooLong,
|
||||
EPerm: EPerm,
|
||||
ELoop: ELoop,
|
||||
EXDev: EXDev,
|
||||
ENotEmpty: ENotEmpty,
|
||||
ENoSpc: ENoSpc,
|
||||
EIO: EIO,
|
||||
EROFS: EROFS,
|
||||
ENoDev: ENoDev,
|
||||
ESPipe: ESPipe,
|
||||
ECanceled: ECanceled,
|
||||
ENotMounted: ENotMounted,
|
||||
EFileSystemError: EFileSystemError,
|
||||
ENoAttr: ENoAttr
|
||||
};
|
||||
errno++;
|
||||
});
|
||||
|
||||
return errors;
|
||||
});
|
||||
|
|
160
src/fs.js
160
src/fs.js
|
@ -203,7 +203,7 @@ define(function(require) {
|
|||
function find_node(context, path, callback) {
|
||||
path = normalize(path);
|
||||
if(!path) {
|
||||
return callback(new Errors.ENoEntry('path is an empty string'));
|
||||
return callback(new Errors.ENOENT('path is an empty string'));
|
||||
}
|
||||
var name = basename(path);
|
||||
var parentPath = dirname(path);
|
||||
|
@ -213,7 +213,7 @@ define(function(require) {
|
|||
if(error) {
|
||||
callback(error);
|
||||
} else if(!superNode || superNode.mode !== MODE_META || !superNode.rnode) {
|
||||
callback(new Errors.EFileSystemError());
|
||||
callback(new Errors.EFILESYSTEMERROR());
|
||||
} else {
|
||||
context.get(superNode.rnode, check_root_directory_node);
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ define(function(require) {
|
|||
if(error) {
|
||||
callback(error);
|
||||
} else if(!rootDirectoryNode) {
|
||||
callback(new Errors.ENoEntry());
|
||||
callback(new Errors.ENOENT());
|
||||
} else {
|
||||
callback(null, rootDirectoryNode);
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ define(function(require) {
|
|||
if(error) {
|
||||
callback(error);
|
||||
} else if(parentDirectoryNode.mode !== MODE_DIRECTORY || !parentDirectoryNode.data) {
|
||||
callback(new Errors.ENotDirectory('a component of the path prefix is not a directory'));
|
||||
callback(new Errors.ENOTDIR('a component of the path prefix is not a directory'));
|
||||
} else {
|
||||
context.get(parentDirectoryNode.data, get_node_from_parent_directory_data);
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ define(function(require) {
|
|||
callback(error);
|
||||
} else {
|
||||
if(!_(parentDirectoryData).has(name)) {
|
||||
callback(new Errors.ENoEntry());
|
||||
callback(new Errors.ENOENT());
|
||||
} else {
|
||||
var nodeId = parentDirectoryData[name].id;
|
||||
context.get(nodeId, is_symbolic_link);
|
||||
|
@ -263,7 +263,7 @@ define(function(require) {
|
|||
if(node.mode == MODE_SYMBOLIC_LINK) {
|
||||
followedCount++;
|
||||
if(followedCount > SYMLOOP_MAX){
|
||||
callback(new Errors.ELoop());
|
||||
callback(new Errors.ELOOP());
|
||||
} else {
|
||||
follow_symbolic_link(node.data);
|
||||
}
|
||||
|
@ -314,10 +314,10 @@ define(function(require) {
|
|||
callback(error);
|
||||
}
|
||||
else if (flag === XATTR_CREATE && node.xattrs.hasOwnProperty(name)) {
|
||||
callback(new Errors.EExists('attribute already exists'));
|
||||
callback(new Errors.EEXIST('attribute already exists'));
|
||||
}
|
||||
else if (flag === XATTR_REPLACE && !node.xattrs.hasOwnProperty(name)) {
|
||||
callback(new Errors.ENoAttr());
|
||||
callback(new Errors.ENOATTR());
|
||||
}
|
||||
else {
|
||||
node.xattrs[name] = value;
|
||||
|
@ -334,7 +334,7 @@ define(function(require) {
|
|||
context.get(path_or_fd.id, set_xattr);
|
||||
}
|
||||
else {
|
||||
callback(new Errors.EInvalid('path or file descriptor of wrong type'));
|
||||
callback(new Errors.EINVAL('path or file descriptor of wrong type'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -350,8 +350,8 @@ define(function(require) {
|
|||
|
||||
function write_super_node(error, existingNode) {
|
||||
if(!error && existingNode) {
|
||||
callback(new Errors.EExists());
|
||||
} else if(error && !error instanceof Errors.ENoEntry) {
|
||||
callback(new Errors.EEXIST());
|
||||
} else if(error && !(error instanceof Errors.ENOENT)) {
|
||||
callback(error);
|
||||
} else {
|
||||
superNode = new SuperNode();
|
||||
|
@ -397,8 +397,8 @@ define(function(require) {
|
|||
|
||||
function check_if_directory_exists(error, result) {
|
||||
if(!error && result) {
|
||||
callback(new Errors.EExists());
|
||||
} else if(error && !error instanceof Errors.ENoEntry) {
|
||||
callback(new Errors.EEXIST());
|
||||
} else if(error && !(error instanceof Errors.ENOENT)) {
|
||||
callback(error);
|
||||
} else {
|
||||
find_node(context, parentPath, read_parent_directory_data);
|
||||
|
@ -482,9 +482,9 @@ define(function(require) {
|
|||
if(error) {
|
||||
callback(error);
|
||||
} else if(ROOT_DIRECTORY_NAME == name) {
|
||||
callback(new Errors.EBusy());
|
||||
callback(new Errors.EBUSY());
|
||||
} else if(!_(result).has(name)) {
|
||||
callback(new Errors.ENoEntry());
|
||||
callback(new Errors.ENOENT());
|
||||
} else {
|
||||
parentDirectoryData = result;
|
||||
directoryNode = parentDirectoryData[name].id;
|
||||
|
@ -496,7 +496,7 @@ define(function(require) {
|
|||
if(error) {
|
||||
callback(error);
|
||||
} else if(result.mode != MODE_DIRECTORY) {
|
||||
callback(new Errors.ENotDirectory());
|
||||
callback(new Errors.ENOTDIR());
|
||||
} else {
|
||||
directoryNode = result;
|
||||
context.get(directoryNode.data, check_if_directory_is_empty);
|
||||
|
@ -509,7 +509,7 @@ define(function(require) {
|
|||
} else {
|
||||
directoryData = result;
|
||||
if(_(directoryData).size() > 0) {
|
||||
callback(new Errors.ENotEmpty());
|
||||
callback(new Errors.ENOTEMPTY());
|
||||
} else {
|
||||
remove_directory_entry_from_parent_directory_node();
|
||||
}
|
||||
|
@ -564,7 +564,7 @@ define(function(require) {
|
|||
|
||||
if(ROOT_DIRECTORY_NAME == name) {
|
||||
if(_(flags).contains(O_WRITE)) {
|
||||
callback(new Errors.EIsDirectory('the named file is a directory and O_WRITE is set'));
|
||||
callback(new Errors.EISDIR('the named file is a directory and O_WRITE is set'));
|
||||
} else {
|
||||
find_node(context, path, set_file_node);
|
||||
}
|
||||
|
@ -588,18 +588,18 @@ define(function(require) {
|
|||
directoryData = result;
|
||||
if(_(directoryData).has(name)) {
|
||||
if(_(flags).contains(O_EXCLUSIVE)) {
|
||||
callback(new Errors.ENoEntry('O_CREATE and O_EXCLUSIVE are set, and the named file exists'));
|
||||
callback(new Errors.ENOENT('O_CREATE and O_EXCLUSIVE are set, and the named file exists'));
|
||||
} else {
|
||||
directoryEntry = directoryData[name];
|
||||
if(directoryEntry.type == MODE_DIRECTORY && _(flags).contains(O_WRITE)) {
|
||||
callback(new Errors.EIsDirectory('the named file is a directory and O_WRITE is set'));
|
||||
callback(new Errors.EISDIR('the named file is a directory and O_WRITE is set'));
|
||||
} else {
|
||||
context.get(directoryEntry.id, check_if_symbolic_link);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(!_(flags).contains(O_CREATE)) {
|
||||
callback(new Errors.ENoEntry('O_CREATE is not set and the named file does not exist'));
|
||||
callback(new Errors.ENOENT('O_CREATE is not set and the named file does not exist'));
|
||||
} else {
|
||||
write_file_node();
|
||||
}
|
||||
|
@ -615,7 +615,7 @@ define(function(require) {
|
|||
if(node.mode == MODE_SYMBOLIC_LINK) {
|
||||
followedCount++;
|
||||
if(followedCount > SYMLOOP_MAX){
|
||||
callback(new Errors.ELoop('too many symbolic links were encountered'));
|
||||
callback(new Errors.ELOOP());
|
||||
} else {
|
||||
follow_symbolic_link(node.data);
|
||||
}
|
||||
|
@ -631,7 +631,7 @@ define(function(require) {
|
|||
name = basename(data);
|
||||
if(ROOT_DIRECTORY_NAME == name) {
|
||||
if(_(flags).contains(O_WRITE)) {
|
||||
callback(new Errors.EIsDirectory('the named file is a directory and O_WRITE is set'));
|
||||
callback(new Errors.EISDIR('the named file is a directory and O_WRITE is set'));
|
||||
} else {
|
||||
find_node(context, path, set_file_node);
|
||||
}
|
||||
|
@ -899,7 +899,7 @@ define(function(require) {
|
|||
} else {
|
||||
directoryData = result;
|
||||
if(!_(directoryData).has(name)) {
|
||||
callback(new Errors.ENoEntry('a component of the path does not name an existing file'));
|
||||
callback(new Errors.ENOENT('a component of the path does not name an existing file'));
|
||||
} else {
|
||||
context.get(directoryData[name].id, check_file);
|
||||
}
|
||||
|
@ -962,7 +962,7 @@ define(function(require) {
|
|||
} else {
|
||||
newDirectoryData = result;
|
||||
if(_(newDirectoryData).has(newname)) {
|
||||
callback(new Errors.EExists('newpath resolves to an existing file'));
|
||||
callback(new Errors.EEXIST('newpath resolves to an existing file'));
|
||||
} else {
|
||||
newDirectoryData[newname] = oldDirectoryData[oldname];
|
||||
context.put(newDirectoryNode.data, newDirectoryData, read_directory_entry);
|
||||
|
@ -985,7 +985,7 @@ define(function(require) {
|
|||
} else {
|
||||
oldDirectoryData = result;
|
||||
if(!_(oldDirectoryData).has(oldname)) {
|
||||
callback(new Errors.ENoEntry('a component of either path prefix does not exist'));
|
||||
callback(new Errors.ENOENT('a component of either path prefix does not exist'));
|
||||
} else {
|
||||
find_node(context, newParentPath, read_new_directory_data);
|
||||
}
|
||||
|
@ -1055,7 +1055,7 @@ define(function(require) {
|
|||
} else {
|
||||
directoryData = result;
|
||||
if(!_(directoryData).has(name)) {
|
||||
callback(new Errors.ENoEntry('a component of the path does not name an existing file'));
|
||||
callback(new Errors.ENOENT('a component of the path does not name an existing file'));
|
||||
} else {
|
||||
context.get(directoryData[name].id, update_file_node);
|
||||
}
|
||||
|
@ -1113,7 +1113,7 @@ define(function(require) {
|
|||
var fileNode;
|
||||
|
||||
if(ROOT_DIRECTORY_NAME == name) {
|
||||
callback(new Errors.EExists('the destination path already exists'));
|
||||
callback(new Errors.EEXIST());
|
||||
} else {
|
||||
find_node(context, parentPath, read_directory_data);
|
||||
}
|
||||
|
@ -1133,7 +1133,7 @@ define(function(require) {
|
|||
} else {
|
||||
directoryData = result;
|
||||
if(_(directoryData).has(name)) {
|
||||
callback(new Errors.EExists('the destination path already exists'));
|
||||
callback(new Errors.EEXIST());
|
||||
} else {
|
||||
write_file_node();
|
||||
}
|
||||
|
@ -1192,7 +1192,7 @@ define(function(require) {
|
|||
} else {
|
||||
directoryData = result;
|
||||
if(!_(directoryData).has(name)) {
|
||||
callback(new Errors.ENoEntry('a component of the path does not name an existing file'));
|
||||
callback(new Errors.ENOENT('a component of the path does not name an existing file'));
|
||||
} else {
|
||||
context.get(directoryData[name].id, check_if_symbolic);
|
||||
}
|
||||
|
@ -1204,7 +1204,7 @@ define(function(require) {
|
|||
callback(error);
|
||||
} else {
|
||||
if(result.mode != MODE_SYMBOLIC_LINK) {
|
||||
callback(new Errors.EInvalid("path not a symbolic link"));
|
||||
callback(new Errors.EINVAL("path not a symbolic link"));
|
||||
} else {
|
||||
callback(null, result.data);
|
||||
}
|
||||
|
@ -1221,7 +1221,7 @@ define(function(require) {
|
|||
if (error) {
|
||||
callback(error);
|
||||
} else if(node.mode == MODE_DIRECTORY ) {
|
||||
callback(new Errors.EIsDirectory('the named file is a directory'));
|
||||
callback(new Errors.EISDIR());
|
||||
} else{
|
||||
fileNode = node;
|
||||
context.get(fileNode.data, truncate_file_data);
|
||||
|
@ -1260,7 +1260,7 @@ define(function(require) {
|
|||
}
|
||||
|
||||
if(length < 0) {
|
||||
callback(new Errors.EInvalid('length cannot be negative'));
|
||||
callback(new Errors.EINVAL('length cannot be negative'));
|
||||
} else {
|
||||
find_node(context, path, read_file_data);
|
||||
}
|
||||
|
@ -1273,7 +1273,7 @@ define(function(require) {
|
|||
if (error) {
|
||||
callback(error);
|
||||
} else if(node.mode == MODE_DIRECTORY ) {
|
||||
callback(new Errors.EIsDirectory('the named file is a directory'));
|
||||
callback(new Errors.EISDIR());
|
||||
} else{
|
||||
fileNode = node;
|
||||
context.get(fileNode.data, truncate_file_data);
|
||||
|
@ -1311,7 +1311,7 @@ define(function(require) {
|
|||
}
|
||||
|
||||
if(length < 0) {
|
||||
callback(new Errors.EInvalid('length cannot be negative'));
|
||||
callback(new Errors.EINVAL('length cannot be negative'));
|
||||
} else {
|
||||
context.get(ofd.id, read_file_data);
|
||||
}
|
||||
|
@ -1329,10 +1329,10 @@ define(function(require) {
|
|||
}
|
||||
|
||||
if (typeof atime != 'number' || typeof mtime != 'number') {
|
||||
callback(new Errors.EInvalid('atime and mtime must be number'));
|
||||
callback(new Errors.EINVAL('atime and mtime must be number'));
|
||||
}
|
||||
else if (atime < 0 || mtime < 0) {
|
||||
callback(new Errors.EInvalid('atime and mtime must be positive integers'));
|
||||
callback(new Errors.EINVAL('atime and mtime must be positive integers'));
|
||||
}
|
||||
else {
|
||||
find_node(context, path, update_times);
|
||||
|
@ -1350,10 +1350,10 @@ define(function(require) {
|
|||
}
|
||||
|
||||
if (typeof atime != 'number' || typeof mtime != 'number') {
|
||||
callback(new Errors.EInvalid('atime and mtime must be a number'));
|
||||
callback(new Errors.EINVAL('atime and mtime must be a number'));
|
||||
}
|
||||
else if (atime < 0 || mtime < 0) {
|
||||
callback(new Errors.EInvalid('atime and mtime must be positive integers'));
|
||||
callback(new Errors.EINVAL('atime and mtime must be positive integers'));
|
||||
}
|
||||
else {
|
||||
context.get(ofd.id, update_times);
|
||||
|
@ -1364,14 +1364,14 @@ define(function(require) {
|
|||
path = normalize(path);
|
||||
|
||||
if (typeof name != 'string') {
|
||||
callback(new Errors.EInvalid('attribute name must be a string'));
|
||||
callback(new Errors.EINVAL('attribute name must be a string'));
|
||||
}
|
||||
else if (!name) {
|
||||
callback(new Errors.EInvalid('attribute name cannot be an empty string'));
|
||||
callback(new Errors.EINVAL('attribute name cannot be an empty string'));
|
||||
}
|
||||
else if (flag !== null &&
|
||||
flag !== XATTR_CREATE && flag !== XATTR_REPLACE) {
|
||||
callback(new Errors.EInvalid('invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE'));
|
||||
callback(new Errors.EINVAL('invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE'));
|
||||
}
|
||||
else {
|
||||
set_extended_attribute(context, path, name, value, flag, callback);
|
||||
|
@ -1381,14 +1381,14 @@ define(function(require) {
|
|||
function fsetxattr_file (context, ofd, name, value, flag, callback) {
|
||||
|
||||
if (typeof name != 'string') {
|
||||
callback(new Errors.EInvalid('attribute name must be a string'));
|
||||
callback(new Errors.EINVAL('attribute name must be a string'));
|
||||
}
|
||||
else if (!name) {
|
||||
callback(new Errors.EInvalid('attribute name cannot be an empty string'));
|
||||
callback(new Errors.EINVAL('attribute name cannot be an empty string'));
|
||||
}
|
||||
else if (flag !== null &&
|
||||
flag !== XATTR_CREATE && flag !== XATTR_REPLACE) {
|
||||
callback(new Errors.EInvalid('invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE'));
|
||||
callback(new Errors.EINVAL('invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE'));
|
||||
}
|
||||
else {
|
||||
set_extended_attribute(context, ofd, name, value, flag, callback);
|
||||
|
@ -1405,7 +1405,7 @@ define(function(require) {
|
|||
callback (error);
|
||||
}
|
||||
else if (!node.xattrs.hasOwnProperty(name)) {
|
||||
callback(new Errors.ENoAttr('attribute does not exist'));
|
||||
callback(new Errors.ENOATTR());
|
||||
}
|
||||
else {
|
||||
callback(null, node.xattrs[name]);
|
||||
|
@ -1413,10 +1413,10 @@ define(function(require) {
|
|||
}
|
||||
|
||||
if (typeof name != 'string') {
|
||||
callback(new Errors.EInvalid('attribute name must be a string'));
|
||||
callback(new Errors.EINVAL('attribute name must be a string'));
|
||||
}
|
||||
else if (!name) {
|
||||
callback(new Errors.EInvalid('attribute name cannot be an empty string'));
|
||||
callback(new Errors.EINVAL('attribute name cannot be an empty string'));
|
||||
}
|
||||
else {
|
||||
find_node(context, path, get_xattr);
|
||||
|
@ -1432,7 +1432,7 @@ define(function(require) {
|
|||
callback(error);
|
||||
}
|
||||
else if (!node.xattrs.hasOwnProperty(name)) {
|
||||
callback(new Errors.ENoAttr('attribute does not exist'));
|
||||
callback(new Errors.ENOATTR());
|
||||
}
|
||||
else {
|
||||
callback(null, node.xattrs[name]);
|
||||
|
@ -1440,10 +1440,10 @@ define(function(require) {
|
|||
}
|
||||
|
||||
if (typeof name != 'string') {
|
||||
callback(new Errors.EInvalid('attribute name must be a string'));
|
||||
callback(new Errors.EINVAL());
|
||||
}
|
||||
else if (!name) {
|
||||
callback(new Errors.EInvalid('attribute name cannot be an empty string'));
|
||||
callback(new Errors.EINVAL('attribute name cannot be an empty string'));
|
||||
}
|
||||
else {
|
||||
context.get(ofd.id, get_xattr);
|
||||
|
@ -1468,7 +1468,7 @@ define(function(require) {
|
|||
callback(error);
|
||||
}
|
||||
else if (!xattr.hasOwnProperty(name)) {
|
||||
callback(new Errors.ENoAttr('attribute does not exist'));
|
||||
callback(new Errors.ENOATTR());
|
||||
}
|
||||
else {
|
||||
delete node.xattrs[name];
|
||||
|
@ -1477,10 +1477,10 @@ define(function(require) {
|
|||
}
|
||||
|
||||
if (typeof name != 'string') {
|
||||
callback(new Errors.EInvalid('attribute name must be a string'));
|
||||
callback(new Errors.EINVAL('attribute name must be a string'));
|
||||
}
|
||||
else if (!name) {
|
||||
callback(new Errors.EInvalid('attribute name cannot be an empty string'));
|
||||
callback(new Errors.EINVAL('attribute name cannot be an empty string'));
|
||||
}
|
||||
else {
|
||||
find_node(context, path, remove_xattr);
|
||||
|
@ -1502,7 +1502,7 @@ define(function(require) {
|
|||
callback(error);
|
||||
}
|
||||
else if (!node.xattrs.hasOwnProperty(name)) {
|
||||
callback(new Errors.ENoAttr('attribute does not exist'));
|
||||
callback(new Errors.ENOATTR());
|
||||
}
|
||||
else {
|
||||
delete node.xattrs[name];
|
||||
|
@ -1511,10 +1511,10 @@ define(function(require) {
|
|||
}
|
||||
|
||||
if (typeof name != 'string') {
|
||||
callback(new Errors.EInvalid('attribute name must be a string'));
|
||||
callback(new Errors.EINVAL('attribute name must be a string'));
|
||||
}
|
||||
else if (!name) {
|
||||
callback(new Errors.EInvalid('attribute name cannot be an empty string'));
|
||||
callback(new Errors.EINVAL('attribute name cannot be an empty string'));
|
||||
}
|
||||
else {
|
||||
context.get(ofd.id, remove_xattr);
|
||||
|
@ -1763,7 +1763,7 @@ define(function(require) {
|
|||
|
||||
flags = validate_flags(flags);
|
||||
if(!flags) {
|
||||
callback(new Errors.EInvalid('flags is not valid'));
|
||||
callback(new Errors.EINVAL('flags is not valid'));
|
||||
}
|
||||
|
||||
open_file(context, path, flags, check_result);
|
||||
|
@ -1771,7 +1771,7 @@ define(function(require) {
|
|||
|
||||
function _close(fs, fd, callback) {
|
||||
if(!_(fs.openFiles).has(fd)) {
|
||||
callback(new Errors.EBadFileDescriptor('invalid file descriptor'));
|
||||
callback(new Errors.EBADF());
|
||||
} else {
|
||||
fs.releaseDescriptor(fd);
|
||||
callback(null);
|
||||
|
@ -1884,9 +1884,9 @@ define(function(require) {
|
|||
var ofd = fs.openFiles[fd];
|
||||
|
||||
if(!ofd) {
|
||||
callback(new Errors.EBadFileDescriptor('invalid file descriptor'));
|
||||
callback(new Errors.EBADF());
|
||||
} else if(!_(ofd.flags).contains(O_READ)) {
|
||||
callback(new Errors.EBadFileDescriptor('descriptor does not permit reading'));
|
||||
callback(new Errors.EBADF('descriptor does not permit reading'));
|
||||
} else {
|
||||
read_data(context, ofd, buffer, offset, length, position, check_result);
|
||||
}
|
||||
|
@ -1899,7 +1899,7 @@ define(function(require) {
|
|||
|
||||
var flags = validate_flags(options.flag || 'r');
|
||||
if(!flags) {
|
||||
callback(new Errors.EInvalid('flags is not valid'));
|
||||
callback(new Errors.EINVAL('flags is not valid'));
|
||||
}
|
||||
|
||||
open_file(context, path, flags, function(err, fileNode) {
|
||||
|
@ -1951,9 +1951,9 @@ define(function(require) {
|
|||
var ofd = fs.openFiles[fd];
|
||||
|
||||
if(!ofd) {
|
||||
callback(new Errors.EBadFileDescriptor('invalid file descriptor'));
|
||||
callback(new Errors.EBADF());
|
||||
} else if(!_(ofd.flags).contains(O_WRITE)) {
|
||||
callback(new Errors.EBadFileDescriptor('descriptor does not permit writing'));
|
||||
callback(new Errors.EBADF('descriptor does not permit writing'));
|
||||
} else if(buffer.length - offset < length) {
|
||||
callback(new Errors.EIO('intput buffer is too small'));
|
||||
} else {
|
||||
|
@ -1968,7 +1968,7 @@ define(function(require) {
|
|||
|
||||
var flags = validate_flags(options.flag || 'w');
|
||||
if(!flags) {
|
||||
callback(new Errors.EInvalid('flags is not valid'));
|
||||
callback(new Errors.EINVAL('flags is not valid'));
|
||||
}
|
||||
|
||||
data = data || '';
|
||||
|
@ -2003,7 +2003,7 @@ define(function(require) {
|
|||
|
||||
var flags = validate_flags(options.flag || 'a');
|
||||
if(!flags) {
|
||||
callback(new Errors.EInvalid('flags is not valid'));
|
||||
callback(new Errors.EINVAL('flags is not valid'));
|
||||
}
|
||||
|
||||
data = data || '';
|
||||
|
@ -2067,7 +2067,7 @@ define(function(require) {
|
|||
var ofd = fs.openFiles[fd];
|
||||
|
||||
if (!ofd) {
|
||||
callback(new Errors.EBadFileDescriptor('invalid file descriptor'));
|
||||
callback(new Errors.EBADF());
|
||||
}
|
||||
else {
|
||||
fgetxattr_file(context, ofd, name, get_result);
|
||||
|
@ -2102,10 +2102,10 @@ define(function(require) {
|
|||
var ofd = fs.openFiles[fd];
|
||||
|
||||
if (!ofd) {
|
||||
callback(new Errors.EBadFileDescriptor('invalid file descriptor'));
|
||||
callback(new Errors.EBADF());
|
||||
}
|
||||
else if (!_(ofd.flags).contains(O_WRITE)) {
|
||||
callback(new Errors.EBadFileDescriptor('descriptor does not permit writing'));
|
||||
callback(new Errors.EBADF('descriptor does not permit writing'));
|
||||
}
|
||||
else {
|
||||
fsetxattr_file(context, ofd, name, value, flag, check_result);
|
||||
|
@ -2141,10 +2141,10 @@ define(function(require) {
|
|||
var ofd = fs.openFiles[fd];
|
||||
|
||||
if (!ofd) {
|
||||
callback(new Errors.EBadFileDescriptor('invalid file descriptor'));
|
||||
callback(new Errors.EBADF());
|
||||
}
|
||||
else if (!_(ofd.flags).contains(O_WRITE)) {
|
||||
callback(new Errors.EBadFileDescriptor('descriptor does not permit writing'));
|
||||
callback(new Errors.EBADF('descriptor does not permit writing'));
|
||||
}
|
||||
else {
|
||||
fremovexattr_file(context, ofd, name, remove_xattr);
|
||||
|
@ -2165,7 +2165,7 @@ define(function(require) {
|
|||
callback(error);
|
||||
} else {
|
||||
if(stats.size + offset < 0) {
|
||||
callback(new Errors.EInvalid('resulting file offset would be negative'));
|
||||
callback(new Errors.EINVAL('resulting file offset would be negative'));
|
||||
} else {
|
||||
ofd.position = stats.size + offset;
|
||||
callback(null, ofd.position);
|
||||
|
@ -2176,19 +2176,19 @@ define(function(require) {
|
|||
var ofd = fs.openFiles[fd];
|
||||
|
||||
if(!ofd) {
|
||||
callback(new Errors.EBadFileDescriptor('invalid file descriptor'));
|
||||
callback(new Errors.EBADF());
|
||||
}
|
||||
|
||||
if('SET' === whence) {
|
||||
if(offset < 0) {
|
||||
callback(new Errors.EInvalid('resulting file offset would be negative'));
|
||||
callback(new Errors.EINVAL('resulting file offset would be negative'));
|
||||
} else {
|
||||
ofd.position = offset;
|
||||
callback(null, ofd.position);
|
||||
}
|
||||
} else if('CUR' === whence) {
|
||||
if(ofd.position + offset < 0) {
|
||||
callback(new Errors.EInvalid('resulting file offset would be negative'));
|
||||
callback(new Errors.EINVAL('resulting file offset would be negative'));
|
||||
} else {
|
||||
ofd.position += offset;
|
||||
callback(null, ofd.position);
|
||||
|
@ -2196,7 +2196,7 @@ define(function(require) {
|
|||
} else if('END' === whence) {
|
||||
fstat_file(context, ofd, update_descriptor_position);
|
||||
} else {
|
||||
callback(new Errors.EInvalid('whence argument is not a proper value'));
|
||||
callback(new Errors.EINVAL('whence argument is not a proper value'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2249,9 +2249,9 @@ define(function(require) {
|
|||
var ofd = fs.openFiles[fd];
|
||||
|
||||
if(!ofd) {
|
||||
callback(new Errors.EBadFileDescriptor('invalid file descriptor'));
|
||||
callback(new Errors.EBADF());
|
||||
} else if(!_(ofd.flags).contains(O_WRITE)) {
|
||||
callback(new Errors.EBadFileDescriptor('descriptor does not permit writing'));
|
||||
callback(new Errors.EBADF('descriptor does not permit writing'));
|
||||
} else {
|
||||
futimes_file(context, ofd, atime, mtime, check_result);
|
||||
}
|
||||
|
@ -2354,9 +2354,9 @@ define(function(require) {
|
|||
var ofd = fs.openFiles[fd];
|
||||
|
||||
if(!ofd) {
|
||||
callback(new Errors.EBadFileDescriptor('invalid file descriptor'));
|
||||
callback(new Errors.EBADF());
|
||||
} else if(!_(ofd.flags).contains(O_WRITE)) {
|
||||
callback(new Errors.EBadFileDescriptor('descriptor does not permit writing'));
|
||||
callback(new Errors.EBADF('descriptor does not permit writing'));
|
||||
} else {
|
||||
ftruncate_file(context, ofd, length, check_result);
|
||||
}
|
||||
|
|
|
@ -40,14 +40,14 @@ define(function(require) {
|
|||
// Make sure the path actually exists, and is a dir
|
||||
fs.stat(path, function(err, stats) {
|
||||
if(err) {
|
||||
callback(new Errors.ENotDirectory());
|
||||
callback(new Errors.ENOTDIR());
|
||||
return;
|
||||
}
|
||||
if(stats.type === 'DIRECTORY') {
|
||||
cwd = path;
|
||||
callback();
|
||||
} else {
|
||||
callback(new Errors.ENotDirectory());
|
||||
callback(new Errors.ENOTDIR());
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -313,7 +313,7 @@ define(function(require) {
|
|||
|
||||
// If not, see if we're allowed to delete recursively
|
||||
if(!options.recursive) {
|
||||
callback(new Errors.ENotEmpty());
|
||||
callback(new Errors.ENOTEMPTY());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,136 @@
|
|||
define(["Filer"], function(Filer) {
|
||||
|
||||
describe("Filer.Errors", function() {
|
||||
it("has expected errors", function() {
|
||||
expect(Filer.Errors).to.exist;
|
||||
|
||||
// By ctor
|
||||
expect(Filer.Errors.UNKNOWN).to.be.a('function');
|
||||
expect(Filer.Errors.OK).to.be.a('function');
|
||||
expect(Filer.Errors.EOF).to.be.a('function');
|
||||
expect(Filer.Errors.EADDRINFO).to.be.a('function');
|
||||
expect(Filer.Errors.EACCES).to.be.a('function');
|
||||
expect(Filer.Errors.EAGAIN).to.be.a('function');
|
||||
expect(Filer.Errors.EADDRINUSE).to.be.a('function');
|
||||
expect(Filer.Errors.EADDRNOTAVAIL).to.be.a('function');
|
||||
expect(Filer.Errors.EAFNOSUPPORT).to.be.a('function');
|
||||
expect(Filer.Errors.EALREADY).to.be.a('function');
|
||||
expect(Filer.Errors.EBADF).to.be.a('function');
|
||||
expect(Filer.Errors.EBUSY).to.be.a('function');
|
||||
expect(Filer.Errors.ECONNABORTED).to.be.a('function');
|
||||
expect(Filer.Errors.ECONNREFUSED).to.be.a('function');
|
||||
expect(Filer.Errors.ECONNRESET).to.be.a('function');
|
||||
expect(Filer.Errors.EDESTADDRREQ).to.be.a('function');
|
||||
expect(Filer.Errors.EFAULT).to.be.a('function');
|
||||
expect(Filer.Errors.EHOSTUNREACH).to.be.a('function');
|
||||
expect(Filer.Errors.EINTR).to.be.a('function');
|
||||
expect(Filer.Errors.EINVAL).to.be.a('function');
|
||||
expect(Filer.Errors.EISCONN).to.be.a('function');
|
||||
expect(Filer.Errors.EMFILE).to.be.a('function');
|
||||
expect(Filer.Errors.EMSGSIZE).to.be.a('function');
|
||||
expect(Filer.Errors.ENETDOWN).to.be.a('function');
|
||||
expect(Filer.Errors.ENETUNREACH).to.be.a('function');
|
||||
expect(Filer.Errors.ENFILE).to.be.a('function');
|
||||
expect(Filer.Errors.ENOBUFS).to.be.a('function');
|
||||
expect(Filer.Errors.ENOMEM).to.be.a('function');
|
||||
expect(Filer.Errors.ENOTDIR).to.be.a('function');
|
||||
expect(Filer.Errors.EISDIR).to.be.a('function');
|
||||
expect(Filer.Errors.ENONET).to.be.a('function');
|
||||
expect(Filer.Errors.ENOTCONN).to.be.a('function');
|
||||
expect(Filer.Errors.ENOTSOCK).to.be.a('function');
|
||||
expect(Filer.Errors.ENOTSUP).to.be.a('function');
|
||||
expect(Filer.Errors.ENOENT).to.be.a('function');
|
||||
expect(Filer.Errors.ENOSYS).to.be.a('function');
|
||||
expect(Filer.Errors.EPIPE).to.be.a('function');
|
||||
expect(Filer.Errors.EPROTO).to.be.a('function');
|
||||
expect(Filer.Errors.EPROTONOSUPPORT).to.be.a('function');
|
||||
expect(Filer.Errors.EPROTOTYPE).to.be.a('function');
|
||||
expect(Filer.Errors.ETIMEDOUT).to.be.a('function');
|
||||
expect(Filer.Errors.ECHARSET).to.be.a('function');
|
||||
expect(Filer.Errors.EAIFAMNOSUPPORT).to.be.a('function');
|
||||
expect(Filer.Errors.EAISERVICE).to.be.a('function');
|
||||
expect(Filer.Errors.EAISOCKTYPE).to.be.a('function');
|
||||
expect(Filer.Errors.ESHUTDOWN).to.be.a('function');
|
||||
expect(Filer.Errors.EEXIST).to.be.a('function');
|
||||
expect(Filer.Errors.ESRCH).to.be.a('function');
|
||||
expect(Filer.Errors.ENAMETOOLONG).to.be.a('function');
|
||||
expect(Filer.Errors.EPERM).to.be.a('function');
|
||||
expect(Filer.Errors.ELOOP).to.be.a('function');
|
||||
expect(Filer.Errors.EXDEV).to.be.a('function');
|
||||
expect(Filer.Errors.ENOTEMPTY).to.be.a('function');
|
||||
expect(Filer.Errors.ENOSPC).to.be.a('function');
|
||||
expect(Filer.Errors.EIO).to.be.a('function');
|
||||
expect(Filer.Errors.EROFS).to.be.a('function');
|
||||
expect(Filer.Errors.ENODEV).to.be.a('function');
|
||||
expect(Filer.Errors.ESPIPE).to.be.a('function');
|
||||
expect(Filer.Errors.ECANCELED).to.be.a('function');
|
||||
expect(Filer.Errors.ENOTMOUNTED).to.be.a('function');
|
||||
expect(Filer.Errors.EFILESYSTEMERROR).to.be.a('function');
|
||||
expect(Filer.Errors.ENOATTR).to.be.a('function');
|
||||
|
||||
// By errno
|
||||
expect(Filer.Errors[-1]).to.equal(Filer.Errors.UNKNOWN);
|
||||
expect(Filer.Errors[0]).to.equal(Filer.Errors.OK);
|
||||
expect(Filer.Errors[1]).to.equal(Filer.Errors.EOF);
|
||||
expect(Filer.Errors[2]).to.equal(Filer.Errors.EADDRINFO);
|
||||
expect(Filer.Errors[3]).to.equal(Filer.Errors.EACCES);
|
||||
expect(Filer.Errors[4]).to.equal(Filer.Errors.EAGAIN);
|
||||
expect(Filer.Errors[5]).to.equal(Filer.Errors.EADDRINUSE);
|
||||
expect(Filer.Errors[6]).to.equal(Filer.Errors.EADDRNOTAVAIL);
|
||||
expect(Filer.Errors[7]).to.equal(Filer.Errors.EAFNOSUPPORT);
|
||||
expect(Filer.Errors[8]).to.equal(Filer.Errors.EALREADY);
|
||||
expect(Filer.Errors[9]).to.equal(Filer.Errors.EBADF);
|
||||
expect(Filer.Errors[10]).to.equal(Filer.Errors.EBUSY);
|
||||
expect(Filer.Errors[11]).to.equal(Filer.Errors.ECONNABORTED);
|
||||
expect(Filer.Errors[12]).to.equal(Filer.Errors.ECONNREFUSED);
|
||||
expect(Filer.Errors[13]).to.equal(Filer.Errors.ECONNRESET);
|
||||
expect(Filer.Errors[14]).to.equal(Filer.Errors.EDESTADDRREQ);
|
||||
expect(Filer.Errors[15]).to.equal(Filer.Errors.EFAULT);
|
||||
expect(Filer.Errors[16]).to.equal(Filer.Errors.EHOSTUNREACH);
|
||||
expect(Filer.Errors[17]).to.equal(Filer.Errors.EINTR);
|
||||
expect(Filer.Errors[18]).to.equal(Filer.Errors.EINVAL);
|
||||
expect(Filer.Errors[19]).to.equal(Filer.Errors.EISCONN);
|
||||
expect(Filer.Errors[20]).to.equal(Filer.Errors.EMFILE);
|
||||
expect(Filer.Errors[21]).to.equal(Filer.Errors.EMSGSIZE);
|
||||
expect(Filer.Errors[22]).to.equal(Filer.Errors.ENETDOWN);
|
||||
expect(Filer.Errors[23]).to.equal(Filer.Errors.ENETUNREACH);
|
||||
expect(Filer.Errors[24]).to.equal(Filer.Errors.ENFILE);
|
||||
expect(Filer.Errors[25]).to.equal(Filer.Errors.ENOBUFS);
|
||||
expect(Filer.Errors[26]).to.equal(Filer.Errors.ENOMEM);
|
||||
expect(Filer.Errors[27]).to.equal(Filer.Errors.ENOTDIR);
|
||||
expect(Filer.Errors[28]).to.equal(Filer.Errors.EISDIR);
|
||||
expect(Filer.Errors[29]).to.equal(Filer.Errors.ENONET);
|
||||
expect(Filer.Errors[31]).to.equal(Filer.Errors.ENOTCONN);
|
||||
expect(Filer.Errors[32]).to.equal(Filer.Errors.ENOTSOCK);
|
||||
expect(Filer.Errors[33]).to.equal(Filer.Errors.ENOTSUP);
|
||||
expect(Filer.Errors[34]).to.equal(Filer.Errors.ENOENT);
|
||||
expect(Filer.Errors[35]).to.equal(Filer.Errors.ENOSYS);
|
||||
expect(Filer.Errors[36]).to.equal(Filer.Errors.EPIPE);
|
||||
expect(Filer.Errors[37]).to.equal(Filer.Errors.EPROTO);
|
||||
expect(Filer.Errors[38]).to.equal(Filer.Errors.EPROTONOSUPPORT);
|
||||
expect(Filer.Errors[39]).to.equal(Filer.Errors.EPROTOTYPE);
|
||||
expect(Filer.Errors[40]).to.equal(Filer.Errors.ETIMEDOUT);
|
||||
expect(Filer.Errors[41]).to.equal(Filer.Errors.ECHARSET);
|
||||
expect(Filer.Errors[42]).to.equal(Filer.Errors.EAIFAMNOSUPPORT);
|
||||
expect(Filer.Errors[44]).to.equal(Filer.Errors.EAISERVICE);
|
||||
expect(Filer.Errors[45]).to.equal(Filer.Errors.EAISOCKTYPE);
|
||||
expect(Filer.Errors[46]).to.equal(Filer.Errors.ESHUTDOWN);
|
||||
expect(Filer.Errors[47]).to.equal(Filer.Errors.EEXIST);
|
||||
expect(Filer.Errors[48]).to.equal(Filer.Errors.ESRCH);
|
||||
expect(Filer.Errors[49]).to.equal(Filer.Errors.ENAMETOOLONG);
|
||||
expect(Filer.Errors[50]).to.equal(Filer.Errors.EPERM);
|
||||
expect(Filer.Errors[51]).to.equal(Filer.Errors.ELOOP);
|
||||
expect(Filer.Errors[52]).to.equal(Filer.Errors.EXDEV);
|
||||
expect(Filer.Errors[53]).to.equal(Filer.Errors.ENOTEMPTY);
|
||||
expect(Filer.Errors[54]).to.equal(Filer.Errors.ENOSPC);
|
||||
expect(Filer.Errors[55]).to.equal(Filer.Errors.EIO);
|
||||
expect(Filer.Errors[56]).to.equal(Filer.Errors.EROFS);
|
||||
expect(Filer.Errors[57]).to.equal(Filer.Errors.ENODEV);
|
||||
expect(Filer.Errors[58]).to.equal(Filer.Errors.ESPIPE);
|
||||
expect(Filer.Errors[59]).to.equal(Filer.Errors.ECANCELED);
|
||||
expect(Filer.Errors[60]).to.equal(Filer.Errors.ENOTMOUNTED);
|
||||
expect(Filer.Errors[61]).to.equal(Filer.Errors.EFILESYSTEMERROR);
|
||||
expect(Filer.Errors[62]).to.equal(Filer.Errors.ENOATTR);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -81,7 +81,7 @@ define(["Filer", "util"], function(Filer, util) {
|
|||
|
||||
fs.setxattr('/testfile', 'test', 'value', 'REPLACE', function(error) {
|
||||
expect(error).to.exist;
|
||||
expect(error.code).to.equal('ENoAttr');
|
||||
expect(error.code).to.equal('ENOATTR');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -123,7 +123,7 @@ define(["Filer", "util"], function(Filer, util) {
|
|||
|
||||
fs.getxattr('/testfile', 'test', function(error, value) {
|
||||
expect(error).to.exist;
|
||||
expect(error.code).to.equal('ENoAttr');
|
||||
expect(error.code).to.equal('ENOATTR');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -195,7 +195,7 @@ define(["Filer", "util"], function(Filer, util) {
|
|||
|
||||
fs.removexattr('/testfile', 'testenoattr', function (error) {
|
||||
expect(error).to.exist;
|
||||
expect(error.code).to.equal('ENoAttr');
|
||||
expect(error.code).to.equal('ENOATTR');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -336,7 +336,7 @@ define(["Filer", "util"], function(Filer, util) {
|
|||
|
||||
fs.getxattr('/testfile', 'test', function (error) {
|
||||
expect(error).to.exist;
|
||||
expect(error.code).to.equal('ENoAttr');
|
||||
expect(error.code).to.equal('ENOATTR');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -363,7 +363,7 @@ define(["Filer", "util"], function(Filer, util) {
|
|||
|
||||
fs.fgetxattr(ofd, 'test', function (error) {
|
||||
expect(error).to.exist;
|
||||
expect(error.code).to.equal('ENoAttr');
|
||||
expect(error.code).to.equal('ENOATTR');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -36,6 +36,7 @@ define([
|
|||
"spec/times.spec",
|
||||
"spec/time-flags.spec",
|
||||
"spec/fs.watch.spec",
|
||||
"spec/errors.spec",
|
||||
|
||||
// Filer.FileSystem.providers.*
|
||||
"spec/providers/providers.spec",
|
||||
|
|
Loading…
Reference in New Issue