throw new ResourceException.NotFound(absolutePath()); } else if (!file.canWrite()) { throw new ResourceException.PermissionDenied(absolutePath()); } else {
throw new ResourceException.NotFound(absolutePath()); } else if (!file.canWrite()) { throw new ResourceException.PermissionDenied(absolutePath()); } else {
private void throwFromErrno(final int err) throws IOException { Errno errno = Errno.valueOf(err); switch (errno) { case EACCES: throw new ResourceException.PermissionDenied(absolutePath()); case EEXIST: throw new ResourceException.FileExists(absolutePath()); case EINVAL: throw new ResourceException.InvalidArguments(absolutePath()); case ENOENT: throw new ResourceException.NotFound(absolutePath()); case ELOOP: throw new ResourceException.TooManySymlinks(absolutePath()); case EISDIR: throw new ResourceException.FileIsDirectory(absolutePath()); case ENOTDIR: throw new ResourceException.FileIsNotDirectory(absolutePath()); case EMFILE: default: throw new InternalIOException(errno.description()); } }
private void throwFromErrno(final int err) throws IOException { Errno errno = Errno.valueOf(err); switch (errno) { case EACCES: throw new ResourceException.PermissionDenied(absolutePath()); case EEXIST: throw new ResourceException.FileExists(absolutePath()); case EINVAL: throw new ResourceException.InvalidArguments(absolutePath()); case ENOENT: throw new ResourceException.NotFound(absolutePath()); case ELOOP: throw new ResourceException.TooManySymlinks(absolutePath()); case EISDIR: throw new ResourceException.FileIsDirectory(absolutePath()); case ENOTDIR: throw new ResourceException.FileIsNotDirectory(absolutePath()); case EMFILE: default: throw new InternalIOException(errno.description()); } }
@Override public Channel openChannel(final int flags, int perm) throws ResourceException { // opening a directory seems to blow up with EACCESS in jruby // (although MRI allows instantiation but blows up on read). // So mimicking that for now. throw new ResourceException.PermissionDenied(absolutePath()); }
static IOException mapFileNotFoundOnGetChannel(final FileResource file, final FileNotFoundException ex) { // Java throws FileNotFoundException both if the file doesn't exist or there were // permission issues, but Ruby needs to disambiguate those two cases return file.exists() ? new ResourceException.PermissionDenied(file.absolutePath()) : new ResourceException.NotFound(file.absolutePath()); }
static IOException mapFileNotFoundOnGetChannel(final FileResource file, final FileNotFoundException ex) { // Java throws FileNotFoundException both if the file doesn't exist or there were // permission issues, but Ruby needs to disambiguate those two cases return file.exists() ? new ResourceException.PermissionDenied(file.absolutePath()) : new ResourceException.NotFound(file.absolutePath()); }
@Override public Channel openChannel(final int flags, int perm) throws ResourceException { // opening a directory seems to blow up with EACCESS in jruby // (although MRI allows instantiation but blows up on read). // So mimicking that for now. throw new ResourceException.PermissionDenied(absolutePath()); }