@Override public FileStat stat(POSIX posix) { return posix.stat(absolutePath()); }
@Override public FileStat lstat(POSIX posix) { return posix.lstat(absolutePath()); }
@Override public InputStream openInputStream() throws IOException { if (!exists()) { throw new ResourceException.NotFound(absolutePath()); } if (isDirectory()) { throw new ResourceException.FileIsDirectory(absolutePath()); } return new FileInputStream(file); }
@Override public InputStream openInputStream() throws IOException { if (!exists()) { throw new ResourceException.NotFound(absolutePath()); } if (isDirectory()) { throw new ResourceException.FileIsDirectory(absolutePath()); } return new FileInputStream(file); }
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 boolean isSymLink() { try { return symlinkPosix.lstat(absolutePath()).isSymlink(); } catch (Throwable t) { return false; } }
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()); } }
final ModeFlags modeFlags = ModeFlags.createModeFlags(flags); if (posix.isNative() && !Platform.IS_WINDOWS) { int fd = posix.open(absolutePath(), modeFlags.getFlags(), perm); if (fd < 0) throwFromErrno(posix.errno()); posix.fcntlInt(fd, Fcntl.F_SETFD, posix.fcntl(fd, Fcntl.F_GETFD) | FcntlLibrary.FD_CLOEXEC); throw new ResourceException.NotFound(absolutePath()); } else if (!file.canWrite()) { throw new ResourceException.PermissionDenied(absolutePath()); } else { throw new ResourceException.FileExists(absolutePath()); throw new ResourceException.FileIsDirectory(absolutePath()); throw new ResourceException.NotFound(absolutePath());
final ModeFlags modeFlags = ModeFlags.createModeFlags(flags); if (posix.isNative() && !Platform.IS_WINDOWS) { int fd = posix.open(absolutePath(), modeFlags.getFlags(), perm); if (fd < 0) throwFromErrno(posix.errno()); posix.fcntlInt(fd, Fcntl.F_SETFD, posix.fcntl(fd, Fcntl.F_GETFD) | FcntlLibrary.FD_CLOEXEC); throw new ResourceException.NotFound(absolutePath()); } else if (!file.canWrite()) { throw new ResourceException.PermissionDenied(absolutePath()); } else { throw new ResourceException.FileExists(absolutePath()); throw new ResourceException.FileIsDirectory(absolutePath()); throw new ResourceException.NotFound(absolutePath());