Retrieves a the hardlink id for a given file.

@param src
the file to lookup
@return the hardlink id
@throws IOException
if the specified file is not a valid hardlink file
177084
public long getHardLinkId(String src) throws IOException {
    byte[][] components = INode.getPathComponents(src);
    readLock();
    try {
      INodeFile node = this.getFileINode(components);
      if ((!exists(node)) || (!(node instanceof INodeHardLinkFile))) {
        throw new IOException(src + " is not a valid hardlink file");
      }
      return ((INodeHardLinkFile) node).getHardLinkID();
    } finally {
      readUnlock();
    }
  }
593885
INodeFile getFileINode(String src) {
    byte[][] components = INodeDirectory.getPathComponents(src);
    readLock();
    try {
      INode inode = rootDir.getNode(components);
      if (inode == null || inode.isDirectory())
        return null;
      return (INodeFile)inode;
    } finally {
      readUnlock();
    }
  }
833325
FileStatus getFileInfo(String src, INode targetNode) {
    String srcs = normalizePath(src);
    readLock();
    try {
      if (targetNode == null) {
        return null;
      }
      else {
        return createFileStatus(srcs, targetNode);
      }
    } finally {
      readUnlock();
    }
  }
1194603
private static int getBlockIdInFile(DistributedFileSystem srcFs, 
      Path srcPath, long blockId) throws IOException {
    FileStatus srcStat = srcFs.getFileStatus(srcPath);
    LocatedBlocks lbs =
        srcFs.getClient().getLocatedBlocks(srcPath.toUri().getPath(), 0, 
            srcStat.getLen());
    
    int i = 0;
    LOG.info("Look for block " + blockId + " in file " + srcPath);
    for (LocatedBlock lb: lbs.getLocatedBlocks()) {
      if (lb.getBlock().getBlockId() == blockId) {
        return i;
      }
      i++;
    }
    
    return -1;
  }
633847
public static void createHardLink(File file, File linkName) 
  throws IOException {
    if (file == null) {
      throw new IOException(
          "invalid arguments to createHardLink: source file is null");
    }
    if (linkName == null) {
      throw new IOException(
          "invalid arguments to createHardLink: link name is null");
    }
	  // construct and execute shell command
    String[] hardLinkCommand = getHardLinkCommand.linkOne(file, linkName);
    Process process = Runtime.getRuntime().exec(hardLinkCommand);
    try {
      if (process.waitFor() != 0) {
        String errMsg = new BufferedReader(new InputStreamReader(
            process.getInputStream())).readLine();
        if (errMsg == null)  errMsg = "";
        String inpMsg = new BufferedReader(new InputStreamReader(
            process.getErrorStream())).readLine();
        if (inpMsg == null)  inpMsg = "";
        throw new IOException(errMsg + inpMsg);
      }
    } catch (InterruptedException e) {
      throw new IOException(e);
    } finally {
      process.destroy();
    }
  }
220825
public static void link(File src, File dst) throws IOException {
    if (src == null || dst == null) {
      throw new IllegalArgumentException("Null parameter passed");
    }
    if (isAvailable()) {
      link(src.getAbsolutePath(), dst.getAbsolutePath());
    } else {
      HardLink.createHardLink(src, dst);
    }
  }
171191
private RemoteIterator<LocatedFileStatus> arrayListing(final String src)
  throws IOException {
    return new RemoteIterator<LocatedFileStatus>() {
      private FileStatus[] stats;
      private int i = 0;

      { //initializer
        stats = listPaths(src);
        if (stats == null) {
          throw new FileNotFoundException("File " + src + " does not exist.");
        }
      }

      @Override
      public boolean hasNext() throws IOException {
        return i<stats.length;
      }

      @Override
      public LocatedFileStatus next() throws IOException {
        if (!hasNext()) {
          throw new NoSuchElementException("No more entry in " + src);
        }
        FileStatus result = stats[i++];
        BlockLocation[] locs = result.isDir() ? null :
            getBlockLocations(
                result.getPath().toUri().getPath(), 0, result.getLen());
        return new LocatedFileStatus(result, locs);
      }
    };
  }
374859
static void saveINode2Image(INode node,
                                      DataOutputStream out) throws IOException {
    byte[] name = node.getLocalNameBytes();
    out.writeShort(name.length);
    out.write(name);
    out.writeLong(node.getId());
    
    if (node instanceof INodeHardLinkFile) {
      // Process the hard link file:  
      // If the hard link has more than 1 reference cnt, then store its type with the hard link ID  
      // Otherwise, just store the regular INodeFile's inode type.  
      INodeHardLinkFile hardLink = (INodeHardLinkFile)node; 
      if (hardLink.getHardLinkFileInfo().getReferenceCnt() > 1) {
        out.writeByte(INode.INodeType.HARDLINKED_INODE.type); 
        WritableUtils.writeVLong(out, ((INodeHardLinkFile)node).getHardLinkID()); 
      } else {
        throw new IOException("Invalid reference count for the hardlink file: " +
            node.getFullPathName() + " with the hardlink ID: " + hardLink.getHardLinkID() +
            " and reference cnt: " + hardLink.getHardLinkFileInfo().getReferenceCnt());
      }
    } else if (node instanceof INodeFile && 
        ((INodeFile)node).getStorageType() == StorageType.RAID_STORAGE) {
      INodeFile raidFile = (INodeFile)node;
      INodeRaidStorage storage = (INodeRaidStorage)raidFile.getStorage();
      out.writeByte(INode.INodeType.RAIDED_INODE.type);
      WritableUtils.writeString(out, storage.getCodec().id);
    } else {
      // Process the regular files and directory: just store its inode type 
      out.writeByte(INode.INodeType.REGULAR_INODE.type); 
    }

    FsPermission filePerm = TL_DATA.get().FILE_PERM;
    if (!node.isDirectory()) {  // write file/hardlink inode
      INodeFile fileINode = (INodeFile)node;
      out.writeShort(fileINode.getReplication());
      out.writeLong(fileINode.getModificationTime());
      out.writeLong(fileINode.getAccessTime());
      out.writeLong(fileINode.getPreferredBlockSize());
      writeBlocks(fileINode.getBlocks(), out);
      filePerm.fromShort(fileINode.getFsPermissionShort());
      PermissionStatus.write(out, fileINode.getUserName(),
                             fileINode.getGroupName(),
                             filePerm);
    } else {   // write directory inode
      out.writeShort(0);  // replication
      out.writeLong(node.getModificationTime());
      out.writeLong(0);   // access time
      out.writeLong(0);   // preferred block size
      out.writeInt(-1);    // # of blocks
      out.writeLong(node.getNsQuota());
      out.writeLong(node.getDsQuota());
      filePerm.fromShort(node.getFsPermissionShort());
      PermissionStatus.write(out, node.getUserName(),
                             node.getGroupName(),
                             filePerm);
    }
  }
1247265
public static String getSourceFile(TypeElement type) {
    if (type instanceof ClassSymbol) {
      JavaFileObject srcFile = ((ClassSymbol) type).sourcefile;
      if (srcFile != null) {
        return srcFile.getName();
      }
    }
    return null;
  }
1232016
public T link(T dest) throws LinkException {
        if (!getClass().equals(dest.getClass())) {
            throw new IllegalArgumentException(this.getClass() + " vs " + dest.getClass());
        }
        try {
            checkExists();
        } catch (IOException e) {
            throw new LinkException(this, e);
        }
        // TODO: getRoot() for ssh root ...
        dest.mklink(Filesystem.SEPARATOR_STRING + this.getPath());
        return dest;
    }
1242778
public String getText(String src){
	    if (end > src.length()) {
	        end = src.length();
	    }
	    return src.substring(start, end);
	}
522808
def GetLinkedFileEntry(self):
    
    link = self._GetLink()
    if not link:
      return None

    # TODO: is there a way to determine the identifier here?
    link_identifier = None

    parent_path_spec = getattr(self.path_spec, 'parent', None)
    path_spec = apfs_path_spec.APFSPathSpec(
        location=link, parent=parent_path_spec)

    is_root = bool(
        link == self._file_system.LOCATION_ROOT or
        link_identifier == self._file_system.ROOT_DIRECTORY_IDENTIFIER)

    return APFSFileEntry(
        self._resolver_context, self._file_system, path_spec, is_root=is_root)
1357077
public static boolean copyFile(final File src, final File dest)
    throws FileNotFoundException, IOException {
        return copyFile(src, dest, -1, true);
    }
163809
private URI getImageFile(final URI href) {
        final URI fileName;
        final FileInfo fi = job.getFileInfo(currentFile.resolve(href));
        if (fi != null) {
            fileName = job.getInputDir().relativize(fi.src);
        } else {
            fileName = href;
        }

        final URI outputURI = outputDir.toURI().resolve(fileName);
        if (exists(outputURI)) {
            logger.debug("Found " + outputURI);
            return outputURI;
        }

        final URI tempURI = job.tempDirURI.resolve(fileName);
        if (exists(tempURI)) {
            logger.debug("Found " + tempURI);
            return tempURI;
        }

        if (fi != null) {
            final URI srcTempURI = job.tempDirURI.resolve(fi.uri);
            if (exists(srcTempURI)) {
                logger.debug("Found " + srcTempURI);
                return srcTempURI;
            }
        }

        final URI srcURI = job.getInputDir().resolve(fileName);
        if (exists(srcURI)) {
            logger.debug("Found " + srcURI);
            return srcURI;
        }

        return null;
    }
814129
public long getId(final Address address) throws IOException {
    return retryRPC(() -> mClient
        .getMasterId(GetMasterIdPRequest.newBuilder().setMasterAddress(address.toProto()).build())
        .getMasterId());
  }
755345
public long getDbId() throws IOException {
        FileTxnIterator itr = new FileTxnIterator(logDir, 0);
        FileHeader fh=readHeader(itr.logFile);
        itr.close();
        if(fh==null)
            throw new IOException("Unsupported Format.");
        return fh.getDbid();
    }
374691
Block[] getFileBlocks(String src) {
    waitForReady();
    byte[][] components = INodeDirectory.getPathComponents(src);
    readLock();
    try {
      INode targetNode = rootDir.getNode(components);
      if (targetNode == null)
        return null;
      if(targetNode.isDirectory())
        return null;
      return ((INodeFile)targetNode).getBlocks();
    } finally {
      readUnlock();
    }
  }