Copy or link the resource.
496368
public function main() {
    $this->validate();

    // Remove existing destination first.
    if ($this->dest->exists()) {
      $this->log("Replacing existing resource '" . $this->dest->getPath() . "'");

      if ($this->dest->delete(TRUE) === FALSE) {
        throw new BuildException("Failed to delete existing destination '$this->dest'");
      }
    }

    // Link or copy the source artifact.
    $this->dest->getParentFile()->mkdirs();
    if ($this->mode == 'copy') {
      $this->log(sprintf("Copying '%s' to '%s'", $this->source->getPath(), $this->dest->getPath()));
      $this->source->copyTo($this->dest);
    }
    else {
      $this->log(sprintf("Linking '%s' to '%s'", $this->source->getPath(), $this->dest->getPath()));
      FileSystem::getFileSystem()->symlink($this->source->getPath(), $this->dest->getPath());
    }
  }
183894
def add(self, resource, replace=False):
        """"""
        uri = resource.uri
        if (uri in self and not replace):
            raise ResourceSetDupeError(
                "Attempt to add resource already in this set")
        self[uri] = resource
574446
def copy(opts = {})
      res = connection.get("#{resource_uri}/#{@id}/copy", {:query => opts})
      self.class.verify_response res
      self.class.new(res["id"], nil, res)
    end
906408
def copy(self):
        """"""
        return self.__class__(self._key, self._load, self._iteritems())
890927
def copy(self, path_patterns, symbolic_link=False, root=None,
             conflicts='fail'):
        '''  '''
        new_filename = build_path(self.entities, path_patterns)
        if not new_filename:
            return None

        if new_filename[-1] == os.sep:
            new_filename += self.filename

        if isabs(self.path) or root is None:
            path = self.path
        else:
            path = join(root, self.path)

        if not exists(path):
            raise ValueError("Target filename to copy/symlink (%s) doesn't "
                             "exist." % path)

        if symbolic_link:
            contents = None
            link_to = path
        else:
            with open(path, 'r') as f:
                contents = f.read()
            link_to = None

        write_contents_to_file(new_filename, contents=contents,
                               link_to=link_to, content_mode='text', root=root,
                               conflicts=conflicts)
738959
def copy(self, target, timeout=500):
        """"""

        if self.metadata and 'encoding' in self.metadata:
            with io.open(target,'w', encoding=self.metadata['encoding']) as f:
                for line in self:
                    f.write(line)
        else:
            with io.open(target,'wb') as f:
                for line in self:
                    if sys.version < '3' and isinstance(line,unicode): #pylint: disable=undefined-variable
                        f.write(line.encode('utf-8'))
                    elif sys.version >= '3' and isinstance(line,str):
                        f.write(line.encode('utf-8'))
                    else:
                        f.write(line)
328791
def write(url, content, **args):
    """"""
    with HTTPSResource(url, **args) as resource:
        resource.write(content)
531821
def _copy(self):
    """"""
    copied_uri = Uri(self.uri.scheme, self.uri.host, self.uri.port,
                     self.uri.path, self.uri.query.copy())
    new_request = HttpRequest(uri=copied_uri, method=self.method,
                              headers=self.headers.copy())
    new_request._body_parts = self._body_parts[:]
    return new_request
739159
def Copy(From, To):
    
    from benchbuild.utils.cmd import cp
    cp("-ar", "--reflink=auto", From, To)
564082
def copy(self, target):
        
        shutil.copy(self.path, self._to_backend(target))
533475
def linkorcopy(src, dst):
    """"""
    if not os.path.isfile(src):
        raise error.ButcherError('linkorcopy called with non-file source. '
                                 '(src: %s  dst: %s)' % src, dst)
    elif os.path.isdir(dst):
        dst = os.path.join(dst, os.path.basename(src))
    elif os.path.exists(dst):
        os.unlink(dst)
    elif not os.path.exists(os.path.dirname(dst)):
        os.makedirs(os.path.dirname(dst))

    try:
        os.link(src, dst)
        log.debug('Hardlinked: %s -> %s', src, dst)
    except OSError:
        shutil.copy2(src, dst)
        log.debug('Couldn\'t hardlink. Copied: %s -> %s', src, dst)
998289
def _download_extract(self, resource):
    """"""
    if isinstance(resource, six.string_types):
      resource = resource_lib.Resource(url=resource)
    def callback(path):
      resource.path = path
      return self._extract(resource)
    return self._download(resource).then(callback)
418861
def download(self, project, filename, targetfilename, loadmetadata=None):
        """"""
        if loadmetadata is None: loadmetadata = self.loadmetadata
        f = clam.common.data.CLAMOutputFile(self.url + project,  filename, loadmetadata, self)
        f.copy(targetfilename)
35577
static void copyResources(URL resourceUrl, File targetPath) throws IOException, URISyntaxException {
        if (resourceUrl == null) {
            return;
        }

        URLConnection urlConnection = resourceUrl.openConnection();

        /**
         * Copy resources either from inside jar or from project folder.
         */
        if (urlConnection instanceof JarURLConnection) {
            copyJarResourceToPath((JarURLConnection) urlConnection, targetPath);
        } else if (VFS_PROTOCOL.equals(resourceUrl.getProtocol())) {
            VirtualFile virtualFileOrFolder = VFS.getChild(resourceUrl.toURI());
            copyFromWarToFolder(virtualFileOrFolder, targetPath);
        } else {
            File file = new File(resourceUrl.getPath());
            if (file.isDirectory()) {
                for (File resourceFile : FileUtils.listFiles(file, null, true)) {
                    int index = resourceFile.getPath().lastIndexOf(targetPath.getName()) + targetPath.getName().length();
                    File targetFile = new File(targetPath, resourceFile.getPath().substring(index));
                    if (!targetFile.exists() || targetFile.length() != resourceFile.length()) {
                        if (resourceFile.isFile()) {
                            FileUtils.copyFile(resourceFile, targetFile);
                        }
                    }
                }
            } else {
                if (!targetPath.exists() || targetPath.length() != file.length()) {
                    FileUtils.copyFile(file, targetPath);
                }
            }
        }
    }
852512
def copy_resource(src, dest):
    
    package_name = "yass"
    dest = (dest + "/" + os.path.basename(src)).rstrip("/")
    if pkg_resources.resource_isdir(package_name, src):
        if not os.path.isdir(dest):
            os.makedirs(dest)
        for res in pkg_resources.resource_listdir(__name__, src):
            copy_resource(src + "/" + res, dest)
    else:
        if not os.path.isfile(dest) \
                and os.path.splitext(src)[1] not in [".pyc"]:
            with open(dest, "wb") as f:
                f.write(pkg_resources.resource_string(__name__, src))
        else:
            print("File exists: %s " % dest)
1181163
def add_resource(self, resource):
        """"""
        if resource.exists():
            self.resources[resource] = self.timekeeper.get_indicator(resource)
        else:
            self.resources[resource] = None
221280
def copy(url, destination, options = {})
      connection(url, options) do |uri, conn|
        conn.copy(uri.request_uri, destination, options)
      end
    end