Create a soft link between a src and destination
only on a local disk. HDFS does not support this
@param target the target for symlink
@param linkname the symlink
@return value returned by the command
192106
public static int symLink(String target, String linkname) throws IOException{
    String cmd = "ln -s " + target + " " + linkname;
    Process p = Runtime.getRuntime().exec(cmd, null);
    int returnVal = -1;
    try{
      returnVal = p.waitFor();
    } catch(InterruptedException e){
      //do nothing as of yet
    }
    return returnVal;
  }
763611
public function symlink($target, $link)
    {
        if (!file_exists($target)) {
            throw new \InvalidArgumentException('Target not found: ' . $target);
        }
        if ($this->relative) {
            $target = $this->makePathRelative($target, dirname($link));
        }
        $this->fs->symlink($target, $link, $this->copyOnWindows);
    }
464239
protected function createLink($source, $target)
    {
        $success = $this->filesystem->relativeSymlink($source, $target);
        if (!$success) {
            throw new RuntimeException("Could not create symlink at $target");
        }
    }
179217
public function GetNamedLink($name, $link, $target = null)
    {
        $result = '';
        if (strlen($name) != 0) {
            $result = $name;
            if (strlen($link) != 0) {
                $result = "<a href=\"".$link."\"".(is_null($target) ? "" : " target=\"".$target."\"").">".$result."</a>";
            }
        }
        return $result;
    }
683120
private File transfer2SpecifyDir(File srcFile, String targetDirPath, String fileName,
                                     boolean isMove) throws Exception {

        // make dir
        OsUtil.makeDirs(targetDirPath);

        File targetPath = new File(OsUtil.pathJoin(targetDirPath, fileName));
        // 从下载文件 复制/mv 到targetPath 原子性的做转移
        OsUtil.transferFileAtom(srcFile, targetPath, isMove);
        return targetPath;

    }
1043578
@Nullable
  private DirectoryEntry lookUpLast(
      @Nullable File dir, Name name, Set<? super LinkOption> options, int linkDepth)
      throws IOException {
    Directory directory = toDirectory(dir);
    if (directory == null) {
      return null;
    }

    DirectoryEntry entry = directory.get(name);
    if (entry == null) {
      return new DirectoryEntry(directory, name, null);
    }

    File file = entry.file();
    if (!options.contains(LinkOption.NOFOLLOW_LINKS) && file.isSymbolicLink()) {
      return followSymbolicLink(dir, (SymbolicLink) file, linkDepth);
    }

    return getRealEntry(entry);
  }
736640
public BoxWebLink.Info createWebLink(URL linkURL, String description) {
        return this.createWebLink(null, linkURL, description);
    }
230651
public static int createDeepHardlink(final File sourceDir, final File destDir)
      throws IOException {
    if (!sourceDir.exists()) {
      throw new IOException("Source directory " + sourceDir.getPath()
          + " doesn't exist");
    } else if (!destDir.exists()) {
      throw new IOException("Destination directory " + destDir.getPath()
          + " doesn't exist");
    } else if (sourceDir.isFile() && destDir.isFile()) {
      throw new IOException("Source or Destination is not a directory.");
    }

    final Set<String> paths = new HashSet<>();
    createDirsFindFiles(sourceDir, sourceDir, destDir, paths);

    int linkCount = 0;
    for (String path : paths) {
      final File sourceLink = new File(sourceDir, path);
      path = destDir + path;

      final File[] targetFiles = sourceLink.listFiles();
      for (final File targetFile : targetFiles) {
        if (targetFile.isFile()) {
          final File linkFile = new File(path, targetFile.getName());
          // NOTE!! If modifying this, you must run this ignored test manually to validate:
          // FileIOUtilsTest#testHardlinkCopyOfBigDir
          Files.createLink(linkFile.toPath(), Paths.get(targetFile.getAbsolutePath()));
          linkCount++;
        }
      }
    }
    return linkCount;
  }
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);
    }
  }
22307
public Content getTargetModuleLink(String target, Content label, ModuleElement mdle) {
        return getHyperLink(pathToRoot.resolve(
                DocPaths.moduleSummary(mdle)), label, "", target);
    }
462164
protected function symlink($target, $link)
    {
        $fs = FileSystem::getFileSystem();

        if ($this->isRelative()) {
            $link = (new PhingFile($link))->getAbsolutePath();
            $target = rtrim($this->makePathRelative($target, dirname($link)), '/');
        }

        if (is_link($link) && @readlink($link) == $target) {
            $this->log('Link exists: ' . $link, Project::MSG_INFO);

            return true;
        }

        if (file_exists($link) || is_link($link)) {
            if (!$this->getOverwrite()) {
                $this->log('Not overwriting existing link ' . $link, Project::MSG_ERR);

                return false;
            }

            if (is_link($link) || is_file($link)) {
                $fs->unlink($link);
                $this->log('Link removed: ' . $link, Project::MSG_INFO);
            } else {
                $fs->rmdir($link, true);
                $this->log('Directory removed: ' . $link, Project::MSG_INFO);
            }
        }

        $this->log('Linking: ' . $target . ' to ' . $link, Project::MSG_INFO);

        return $fs->symlink($target, $link);
    }
315065
public function link($target, $link)
    {
        if (! windows_os()) {
            return symlink($target, $link);
        }

        $mode = $this->isDirectory($target) ? 'J' : 'H';

        exec("mklink /{$mode} \"{$link}\" \"{$target}\"");
    }
483880
@Override
  public boolean hardLink(Path src, Path dst) throws IOException {  
    return dfs.hardLink(getPathName(src), getPathName(dst));  
  }
1014862
public void link(Name name, File file) {
    DirectoryEntry entry = new DirectoryEntry(this, checkNotReserved(name, "link"), file);
    put(entry);
    file.linked(entry);
  }
722715
public Nfs3LinkRequest makeLinkRequest(byte[] fileHandle, byte[] parentDirectoryFileHandle, String name) throws FileNotFoundException {
        return new Nfs3LinkRequest(fileHandle, parentDirectoryFileHandle, name, _credential);
    }
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;
    }
662973
function fileLinkCopy( $srcPath, $dstPath, $symLink )
    {
        $srcPath = self::cleanPath( $srcPath );
        $dstPath = self::cleanPath( $dstPath );
        eZDebugSetting::writeDebug( 'kernel-clustering', "dfs::fileLinkCopy( '$srcPath', '$dstPath' )" );

        self::$dbbackend->_linkCopy( $srcPath, $dstPath );
    }