Performs a resource copy
501213
private IStatus performResourceCopy(CommonDropAdapter dropAdapter,
			Shell shell, IResource[] sources) {
		MultiStatus problems = new MultiStatus(PlatformUI.PLUGIN_ID, 1,
				WorkbenchNavigatorMessages.DropAdapter_problemsMoving, null);
		mergeStatus(problems, validateTarget(dropAdapter.getCurrentTarget(),
				dropAdapter.getCurrentTransfer(), dropAdapter
						.getCurrentOperation()));
		IContainer target = null;

		if (dropAdapter.getCurrentTarget() instanceof IVdmContainer) {
			target = ((IVdmContainer) dropAdapter.getCurrentTarget())
					.getContainer();
		} else {
			target = getActualTarget((IResource) dropAdapter.getCurrentTarget());
		}
		CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(
				shell);
		operation.copyResources(sources, target);

		return problems;
	}
407615
def copy_data_from_scenario(resource_attrs, source_scenario_id, target_scenario_id, **kwargs):
    

    #Get all the resource scenarios we wish to update
    target_resourcescenarios = db.DBSession.query(ResourceScenario).filter(
            ResourceScenario.scenario_id==target_scenario_id,
            ResourceScenario.resource_attr_id.in_(resource_attrs)).all()

    target_rs_dict = {}
    for target_rs in target_resourcescenarios:
        target_rs_dict[target_rs.resource_attr_id] = target_rs

    #get all the resource scenarios we are using to get our datsets source.
    source_resourcescenarios = db.DBSession.query(ResourceScenario).filter(
            ResourceScenario.scenario_id==source_scenario_id,
            ResourceScenario.resource_attr_id.in_(resource_attrs)).all()

    #If there is an RS in scenario 'source' but not in 'target', then create
    #a new one in 'target'
    for source_rs in source_resourcescenarios:
        target_rs = target_rs_dict.get(source_rs.resource_attr_id)
        if target_rs is not None:
            target_rs.dataset_id = source_rs.dataset_id
        else:
            target_rs = ResourceScenario()
            target_rs.scenario_id      = target_scenario_id
            target_rs.dataset_id       = source_rs.dataset_id
            target_rs.resource_attr_id = source_rs.resource_attr_id
            db.DBSession.add(target_rs)

    db.DBSession.flush()

    return target_resourcescenarios
432548
def copy(self, project, name=None):
        
        project = Transform.to_project(project)
        data = {
            'project': project
        }
        if name:
            data['name'] = name
        extra = {'resource': self.__class__.__name__, 'query': {
            'id': self.id,
            'data': data
        }}
        logger.info('Copying file', extra=extra)
        new_file = self._api.post(url=self._URL['copy'].format(id=self.id),
                                  data=data).json()
        return File(api=self._api, **new_file)
464667
def copy(self):
        
        resource = copy.copy(self)

        # workaround for bytes/str issue in Py3 with copy of instance
        # TypeError: a bytes-like object is required, not 'str' (ssl.py)
        resource._request = self.tcex.request(self.tcex.session)

        # reset properties of resource
        resource.copy_reset()

        # Preserve settings
        resource.http_method = self.http_method
        if self._request.payload.get('owner') is not None:
            resource.owner = self._request.payload.get('owner')

        # future bcs - these should not need to be reset. correct?
        # resource._request_entity = self._api_entity
        # resource._request_uri = self._api_uri
        return resource
298915
def copy(source):
    ""

    def do_copy(target):
        if source.__doc__:
            target.__doc__ = source.__doc__
        return target

    return do_copy
114948
def merge_resources(resource1, resource2):
    
    merged = resource1.copy()
    merged.update(resource2)
    return merged
688084
def execute
      options = copy_move_options
      copy_options = @resource.copy_options options

      unless copy_options[:can_copy]
        return :precondition_failed if copy_options[:ancestor_exist]
        return :conflict
      end

      return :locked if copy_options[:locked]

      overwritten = @resource.copy options
      overwritten ? :no_content : :created
    end
147091
public static void checkCopyToOK(Resource source, Resource target) throws IOException {
	if (!source.isFile()) {
	    if (source.isDirectory()) throw new IOException("can't copy [" + source.getPath() + "] to [" + target.getPath() + "], source is a directory");
	    throw new IOException("can't copy [" + source.getPath() + "] to [" + target.getPath() + "], source file does not exist");
	}
	else if (target.isDirectory()) {
	    throw new IOException("can't copy [" + source.getPath() + "] to [" + target.getPath() + "], target is a directory");
	}
    }
705072
protected void processCopyResources(CmsObject cms, String resourcename, CmsMacroResolver resolver) {

        Map<String, String> copiedResources = new HashMap<String, String>();
        for (CmsConfigurationCopyResource oriCopyResource : m_copyResources) {

            // store original copy target
            String oriTarget = oriCopyResource.getTarget();
            String target = oriTarget;

            List<CmsConfigurationCopyResource> copyResources = new ArrayList<CmsConfigurationCopyResource>();
            try {
                // determine if source definition has a wild card character at the end
                if (oriCopyResource.getSource().endsWith("*")) {
                    // add all sub resources of the specified source folder to the set of resources to copy
                    String source = oriCopyResource.getSource().substring(0, oriCopyResource.getSource().length() - 1);
                    List<CmsResource> sources = cms.readResources(source, CmsResourceFilter.IGNORE_EXPIRATION, false);
                    for (CmsResource sourceRes : sources) {
                        copyResources.add(
                            new CmsConfigurationCopyResource(
                                cms.getSitePath(sourceRes),
                                oriCopyResource.getTarget(),
                                oriCopyResource.getTypeString()));
                    }
                    copiedResources.put(source, resolver.resolveMacros(target));
                } else {
                    // just add the single specified source
                    copyResources.add(oriCopyResource);
                }

                // loop the calculated resources to copy
                for (CmsConfigurationCopyResource copyResource : copyResources) {

                    target = copyResource.getTarget();
                    if (copyResource.isTargetWasNull()
                        || CmsMacroResolver.isMacro(target, MACRO_RESOURCE_FOLDER_PATH)
                        || CmsMacroResolver.isMacro(target, MACRO_RESOURCE_FOLDER_PATH_TOUCH)) {
                        // target is just the resource folder, must add source file name to target
                        target = target.concat(CmsResource.getName(copyResource.getSource()));
                    }
                    // now resolve the macros in the target name
                    target = resolver.resolveMacros(target);
                    // now resolve possible relative paths in the target
                    target = CmsFileUtil.normalizePath(CmsLinkManager.getAbsoluteUri(target, resourcename), '/');

                    // copy the resource
                    cms.copyResource(copyResource.getSource(), target, copyResource.getType());
                    copiedResources.put(copyResource.getSource(), target);
                    if (CmsMacroResolver.isMacro(oriTarget, MACRO_RESOURCE_FOLDER_PATH_TOUCH)) {
                        // copied resources should be touched in order to be able to do additional stuff
                        CmsResource res = cms.readResource(target);
                        if (res.isFile()) {
                            // single file, just rewrite it
                            CmsFile file = cms.readFile(res);
                            cms.writeFile(file);
                        } else {
                            // folder, get all sub resources that are files
                            Iterator<CmsResource> it = cms.readResources(
                                target,
                                CmsResourceFilter.DEFAULT_FILES,
                                true).iterator();
                            while (it.hasNext()) {
                                // rewrite the sub resource
                                CmsResource subRes = it.next();
                                CmsFile file = cms.readFile(subRes);
                                cms.writeFile(file);
                            }
                        }
                    }

                }
            } catch (Exception e) {
                // CmsIllegalArgumentException as well as CmsException
                // log the error and continue with the other copy resources
                if (LOG.isDebugEnabled()) {
                    // log stack trace in debug level only
                    LOG.debug(
                        Messages.get().getBundle().key(
                            Messages.LOG_PROCESS_COPY_RESOURCES_3,
                            resourcename,
                            oriCopyResource,
                            target),
                        e);
                } else {
                    LOG.error(
                        Messages.get().getBundle().key(
                            Messages.LOG_PROCESS_COPY_RESOURCES_3,
                            resourcename,
                            oriCopyResource,
                            target));
                }
            }
        }
        // only adjust links for successfully copied resources and if the feature is enabled
        try {
            if (!CmsStringUtil.isEmptyOrWhitespaceOnly(m_adjustLinksFolder) && !copiedResources.isEmpty()) {
                String realAdjustFolderPath = resolver.resolveMacros(m_adjustLinksFolder);
                cms.adjustLinks(copiedResources, realAdjustFolderPath);
            }
        } catch (CmsException e) {
            LOG.error(e.getLocalizedMessage(), e);
        } catch (CmsIllegalArgumentException e) {
            LOG.error(e.getLocalizedMessage(), e);
        }
    }
1307710
public static void copyInstanceResources( Instance instance, Map<String,byte[]> fileNameToFileContent )
	throws IOException {

		File dir = InstanceHelpers.findInstanceDirectoryOnAgent( instance );
		Utils.createDirectory( dir );

		if( fileNameToFileContent != null ) {
			for( Map.Entry<String,byte[]> entry : fileNameToFileContent.entrySet()) {

				File f = new File( dir, entry.getKey());
				Utils.createDirectory( f.getParentFile());

				ByteArrayInputStream in = new ByteArrayInputStream( entry.getValue());
				Utils.copyStream( in, f );
			}
		}
	}
647402
def copy_resources(self):
        """"""
        if not os.path.isdir('resources'):
            os.mkdir('resources')

        resource_dir = os.path.join(os.getcwd(), 'resources', '')
        copied_resources = []

        for resource in self.resources:
            src = os.path.join(EULER_DATA, 'resources', resource)
            if os.path.isfile(src):
                shutil.copy(src, resource_dir)
                copied_resources.append(resource)

        if copied_resources:
            copied = ', '.join(copied_resources)
            path = os.path.relpath(resource_dir, os.pardir)
            msg = "Copied {} to {}.".format(copied, path)

            click.secho(msg, fg='green')
391966
public static int copy(Resource in, File out) throws IOException {
        assert in != null : "No input File specified";
        assert out != null : "No output File specified";
        return copy(new BufferedInputStream(in.getInputStream()),
                new BufferedOutputStream(new FileOutputStream(out)));
    }
622124
private Response copyContent(String spaceID,
                                 String contentID,
                                 String storeID,
                                 String sourceStoreID,
                                 String copySource) {
        StringBuilder msg = new StringBuilder("copying content from (");
        msg.append(copySource);
        msg.append(") to (");
        msg.append(spaceID);
        msg.append(" / ");
        msg.append(contentID);
        msg.append(", ");
        msg.append(storeID);
        msg.append(")");
        log.info(msg.toString());

        try {
            return doCopyContent(spaceID, contentID, storeID, sourceStoreID, copySource);

        } catch (InvalidIdException e) {
            return responseBad(msg.toString(), e, BAD_REQUEST);

        } catch (InvalidRequestException e) {
            return responseBad(msg.toString(), e, BAD_REQUEST);

        } catch (ResourceNotFoundException e) {
            return responseNotFound(msg.toString(), e, NOT_FOUND);

        } catch (ResourceStateException e) {
            return responseBad(msg.toString(), e, CONFLICT);

        } catch (ResourceException e) {
            return responseBad(msg.toString(), e, INTERNAL_SERVER_ERROR);

        } catch (Exception e) {
            return responseBad(msg.toString(), e, INTERNAL_SERVER_ERROR);
        }
    }
539156
def copy(secure = false)
      # since only the Content streams are modified (Resource hashes are created anew),
      # it should be safe (and a lot faster) to create a deep copy only for the content hashes and streams.
      delete :Parent
      prep_content_array
      page_copy = clone
      page_copy[:Contents] = page_copy[:Contents].map do |obj|
        obj = obj.dup
        obj[:referenced_object] = obj[:referenced_object].dup if obj[:referenced_object]
        obj[:referenced_object][:raw_stream_content] = obj[:referenced_object][:raw_stream_content].dup if obj[:referenced_object] && obj[:referenced_object][:raw_stream_content]
        obj
      end
      if page_copy[:Resources]
        page_res = page_copy[:Resources] = page_copy[:Resources].dup
        page_res = page_copy[:Resources][:referenced_object] = page_copy[:Resources][:referenced_object].dup if page_copy[:Resources][:referenced_object]
        page_res.each do |k, v|
          v = page_res[k] = v.dup if v.is_a?(Array) || v.is_a?(Hash)
          v = v[:referenced_object] = v[:referenced_object].dup if v.is_a?(Hash) && v[:referenced_object]
        end
      end
      page_copy.instance_exec(secure || @secure_injection) { |s| secure_for_copy if s; init_contents; self }
    end
505829
private void writeResources(List<Resource> resources)
            throws JsonGenerationException, IOException {

        List<String> resourceStrings = new ArrayList<String>();

        for (Resource resource : resources) {
            resourceStrings.add(resource.getId());
        }
        writeJsonArray(JsonDocumentFields.RESOURCE, resourceStrings);
    }
745522
def update_resource(self, resource):
        ''''''
        index = self.resources.index(resource)
        data = {
            'resources__{index}'.format(index=index): resource
        }
        self.update(**data)
        self.reload()
        post_save.send(self.__class__, document=self)
599879
def write_resources(self, resources):
        
        for filename, data in list(resources.get('outputs', {}).items()):
            # Determine where to write the file to
            dest = os.path.join(self.output_dir, filename)
            path = os.path.dirname(dest)
            if path and not os.path.isdir(path):
                os.makedirs(path)

            # Write file
            with open(dest, 'wb') as f:
                f.write(data)