Java 类org.apache.hadoop.io.nativeio.Errno 实例源码

项目:hadoop-on-lustre    文件:SecureIOUtils.java   
/**
 * Open the specified File for write access, ensuring that it does not exist.
 * @param f the file that we want to create
 * @param permissions we want to have on the file (if security is enabled)
 *
 * @throws AlreadyExistsException if the file already exists
 * @throws IOException if any other error occurred
 */
public static FileOutputStream createForWrite(File f, int permissions)
throws IOException {
  if (skipSecurity) {
    return insecureCreateForWrite(f, permissions);
  } else {
    // Use the native wrapper around open(2)
    try {
      FileDescriptor fd = NativeIO.open(f.getAbsolutePath(),
        NativeIO.O_WRONLY | NativeIO.O_CREAT | NativeIO.O_EXCL,
        permissions);
      return new FileOutputStream(fd);
    } catch (NativeIOException nioe) {
      if (nioe.getErrno() == Errno.EEXIST) {
        throw new AlreadyExistsException(nioe);
      }
      throw nioe;
    }
  }
}
项目:hortonworks-extension    文件:SecureIOUtils.java   
/**
 * Open the specified File for write access, ensuring that it does not exist.
 * @param f the file that we want to create
 * @param permissions we want to have on the file (if security is enabled)
 *
 * @throws AlreadyExistsException if the file already exists
 * @throws IOException if any other error occurred
 */
public static FileOutputStream createForWrite(File f, int permissions)
throws IOException {
  if (skipSecurity) {
    return insecureCreateForWrite(f, permissions);
  } else {
    // Use the native wrapper around open(2)
    try {
      FileDescriptor fd = NativeIO.open(f.getAbsolutePath(),
        NativeIO.O_WRONLY | NativeIO.O_CREAT | NativeIO.O_EXCL,
        permissions);
      return new FileOutputStream(fd);
    } catch (NativeIOException nioe) {
      if (nioe.getErrno() == Errno.EEXIST) {
        throw new AlreadyExistsException(nioe);
      }
      throw nioe;
    }
  }
}
项目:hortonworks-extension    文件:SecureIOUtils.java   
/**
 * Open the specified File for write access, ensuring that it does not exist.
 * @param f the file that we want to create
 * @param permissions we want to have on the file (if security is enabled)
 *
 * @throws AlreadyExistsException if the file already exists
 * @throws IOException if any other error occurred
 */
public static FileOutputStream createForWrite(File f, int permissions)
throws IOException {
  if (skipSecurity) {
    return insecureCreateForWrite(f, permissions);
  } else {
    // Use the native wrapper around open(2)
    try {
      FileDescriptor fd = NativeIO.open(f.getAbsolutePath(),
        NativeIO.O_WRONLY | NativeIO.O_CREAT | NativeIO.O_EXCL,
        permissions);
      return new FileOutputStream(fd);
    } catch (NativeIOException nioe) {
      if (nioe.getErrno() == Errno.EEXIST) {
        throw new AlreadyExistsException(nioe);
      }
      throw nioe;
    }
  }
}