Skip to content

Commit

Permalink
fs: use errno constant with ERR_FS_EISDIR
Browse files Browse the repository at this point in the history
This commit updates rm() to use the EISDIR constant with
ERR_FS_EISDIR instead of hard coding -21.

PR-URL: #35563
Reviewed-By: Ben Coe <bencoe@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
cjihrig authored and MylesBorins committed Oct 14, 2020
1 parent b074717 commit 8e3b11a
Showing 1 changed file with 43 additions and 36 deletions.
79 changes: 43 additions & 36 deletions lib/internal/fs/utils.js
Expand Up @@ -46,40 +46,47 @@ const kStats = Symbol('stats');
const assert = require('internal/assert');

const {
F_OK = 0,
W_OK = 0,
R_OK = 0,
X_OK = 0,
COPYFILE_EXCL,
COPYFILE_FICLONE,
COPYFILE_FICLONE_FORCE,
O_APPEND,
O_CREAT,
O_EXCL,
O_RDONLY,
O_RDWR,
O_SYNC,
O_TRUNC,
O_WRONLY,
S_IFBLK,
S_IFCHR,
S_IFDIR,
S_IFIFO,
S_IFLNK,
S_IFMT,
S_IFREG,
S_IFSOCK,
UV_FS_SYMLINK_DIR,
UV_FS_SYMLINK_JUNCTION,
UV_DIRENT_UNKNOWN,
UV_DIRENT_FILE,
UV_DIRENT_DIR,
UV_DIRENT_LINK,
UV_DIRENT_FIFO,
UV_DIRENT_SOCKET,
UV_DIRENT_CHAR,
UV_DIRENT_BLOCK
} = internalBinding('constants').fs;
fs: {
F_OK = 0,
W_OK = 0,
R_OK = 0,
X_OK = 0,
COPYFILE_EXCL,
COPYFILE_FICLONE,
COPYFILE_FICLONE_FORCE,
O_APPEND,
O_CREAT,
O_EXCL,
O_RDONLY,
O_RDWR,
O_SYNC,
O_TRUNC,
O_WRONLY,
S_IFBLK,
S_IFCHR,
S_IFDIR,
S_IFIFO,
S_IFLNK,
S_IFMT,
S_IFREG,
S_IFSOCK,
UV_FS_SYMLINK_DIR,
UV_FS_SYMLINK_JUNCTION,
UV_DIRENT_UNKNOWN,
UV_DIRENT_FILE,
UV_DIRENT_DIR,
UV_DIRENT_LINK,
UV_DIRENT_FIFO,
UV_DIRENT_SOCKET,
UV_DIRENT_CHAR,
UV_DIRENT_BLOCK
},
os: {
errno: {
EISDIR
}
}
} = internalBinding('constants');

// The access modes can be any of F_OK, R_OK, W_OK or X_OK. Some might not be
// available on specific systems. They can be used in combination as well
Expand Down Expand Up @@ -694,7 +701,7 @@ const validateRmOptions = hideStackFrames((path, options, callback) => {
message: 'is a directory',
path,
syscall: 'rm',
errno: -21
errno: EISDIR
}));
}
return callback(null, options);
Expand All @@ -716,7 +723,7 @@ const validateRmOptionsSync = hideStackFrames((path, options) => {
message: 'is a directory',
path,
syscall: 'rm',
errno: -21
errno: EISDIR
});
}
} catch (err) {
Expand Down

0 comments on commit 8e3b11a

Please sign in to comment.