Merge branch 'master' of github.com:filerjs/filer
This commit is contained in:
commit
6cfed81996
|
@ -620,7 +620,7 @@ function open_file(context, path, flags, mode, callback) {
|
||||||
directoryData = result;
|
directoryData = result;
|
||||||
if(directoryData.hasOwnProperty(name)) {
|
if(directoryData.hasOwnProperty(name)) {
|
||||||
if(flags.includes(O_EXCLUSIVE)) {
|
if(flags.includes(O_EXCLUSIVE)) {
|
||||||
callback(new Errors.ENOENT('O_CREATE and O_EXCLUSIVE are set, and the named file exists', path));
|
callback(new Errors.EEXIST('O_CREATE and O_EXCLUSIVE are set, and the named file exists', path));
|
||||||
} else {
|
} else {
|
||||||
directoryEntry = directoryData[name];
|
directoryEntry = directoryData[name];
|
||||||
if(directoryEntry.type === NODE_TYPE_DIRECTORY && flags.includes(O_WRITE)) {
|
if(directoryEntry.type === NODE_TYPE_DIRECTORY && flags.includes(O_WRITE)) {
|
||||||
|
|
|
@ -47,6 +47,23 @@ describe('fs.open', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return an error when flagged for write and the path exists', function(done) {
|
||||||
|
var fs = util.fs();
|
||||||
|
|
||||||
|
fs.mkdir('/tmp', function(error) {
|
||||||
|
if(error) throw error;
|
||||||
|
fs.writeFile('/tmp/file', 'data', function(error) {
|
||||||
|
if(error) throw error;
|
||||||
|
fs.open('/tmp/file', 'wx', function(error, result) {
|
||||||
|
expect(error).to.exist;
|
||||||
|
expect(error.code).to.equal('EEXIST');
|
||||||
|
expect(result).not.to.exist;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should return an error when flagged for append and the path is a directory', function(done) {
|
it('should return an error when flagged for append and the path is a directory', function(done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue