Compile one or more WhileyFiles into a given WyilFile

@param source The source file being compiled.
@param target The target file being generated.
@return
@throws IOException
340584
private static WyilFile compile(List<Path.Entry<WhileyFile>> sources, Path.Entry<WyilFile> target) throws IOException {
		// Read target WyilFile. This may have already been compiled in a previous run
		// and, in such case, we are invalidating some or all of the existing file.
		WyilFile wyil = target.read();
		// Parse all modules
		for(int i=0;i!=sources.size();++i) {
			Path.Entry<WhileyFile> source = sources.get(i);
			WhileyFileParser wyp = new WhileyFileParser(wyil, source.read());
			// FIXME: what to do with module added to heap? The problem is that this might
			// be replaced a module, for example.
			wyil.getModule().putUnit(wyp.read());
		}
		//
		return wyil;
	}
461940
public void ifne(String target) throws IOException
    {
        if (wideIndex)
        {
            out.writeByte(NOT_IFNE);
            out.writeShort(WIDEFIXOFFSET);
            Branch branch = createBranch(target);
            out.writeByte(GOTO_W);
            out.writeInt(branch);
        }
        else
        {
            Branch branch = createBranch(target);
            out.writeOpCode(IFNE);
            out.writeShort(branch);
        }
    }
72606
public static void generateSource(File file, File sourceOutputPath, List<CodeDependent> cds,
            Set<String> compiledClass) throws IOException {

        doCreatePro(file, true, false, null, true, sourceOutputPath, cds, compiledClass, new HashMap<String, String>(),
                false);
    }
849637
public static void replaceFile(File src, File target) throws IOException {
    /* renameTo() has two limitations on Windows platform.
     * src.renameTo(target) fails if
     * 1) If target already exists OR
     * 2) If target is already open for reading/writing.
     */
    if (!src.renameTo(target)) {
      int retries = 5;
      while (target.exists() && !target.delete() && retries-- >= 0) {
        try {
          Thread.sleep(1000);
        } catch (InterruptedException e) {
          throw new IOException("replaceFile interrupted.");
        }
      }
      if (!src.renameTo(target)) {
        throw new IOException("Unable to rename " + src +
                              " to " + target);
      }
    }
  }
24232
public static void checkMoveToOK(Resource source, Resource target) throws IOException {
	if (!source.exists()) {
	    throw new IOException("can't move [" + source.getPath() + "] to [" + target.getPath() + "], source file does not exist");
	}
	if (source.isDirectory() && target.isFile()) throw new IOException("can't move [" + source.getPath() + "] directory to [" + target.getPath() + "], target is a file");
	if (source.isFile() && target.isDirectory()) throw new IOException("can't move [" + source.getPath() + "] file to [" + target.getPath() + "], target is a directory");
    }
131644
public void copyInto(File source, File targetDir, final VariableResolver resolver) throws IOException{
        FileUtil.copyInto(source, targetDir, new FileUtil.FileCreator(){
            @Override
            public void createFile(File sourceFile, File targetFile) throws IOException{
                replace(new FileReader(sourceFile), new FileWriter(targetFile), resolver);
            }

            @Override
            public String translate(String name){
                return replace(name, resolver);
            }
        });
    }
357994
public static final void copyResource(String source, Path target, Class<?> cls) throws IOException
    {
        try (InputStream is = cls.getResourceAsStream(source))
        {
            Files.copy(is, target, REPLACE_EXISTING);
        }
    }
565412
public static void compress(File source, File target) throws IOException {

        ZipOutputStream zipOut = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(target)));
        ZipEntry zipEntry = new ZipEntry(source.getName());
        zipOut.putNextEntry(zipEntry);
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream(source), BUFFER);
        byte data[] = new byte[BUFFER];

        int count = 0;
        while ((count = bis.read(data, 0, BUFFER)) != -1) {
            zipOut.write(data, 0, count);
        }
        bis.close();
        zipOut.close();

    }
1014113
private void compile(AssetInfo asset, File source, File target) throws ServiceException {
        File watched = watchedAssets.get(asset);
        if (watched == null) {
            if (isDevMode()) {
                new Thread(() -> {
                    try {
                        // avoid recursive compiles
                        if (isDevMode())
                            watchedAssets.put(asset, target);
                        doCompile(asset, source, target);
                    }
                    catch (Exception ex) {
                        logger.severeException(ex.getMessage(), ex);
                    }
                }).start();
            }
            else {
                doCompile(asset, source, target);
            }
        }
    }
5151
public void execute(final CCTask task, final List<File> sources, final Map<String, TargetInfo> targets,
      final TargetInfo linkTarget) {
    try {
      this.projectWriter.writeProject(this.outFile, task, this, sources, targets, linkTarget);
    } catch (final BuildException ex) {
      if (this.failOnError) {
        throw ex;
      } else {
        task.log(ex.toString());
      }
    } catch (final Exception ex) {
      if (this.failOnError) {
        throw new BuildException(ex);
      } else {
        task.log(ex.toString());
      }
    }
  }
1058705
public void copyFromPagesToView(
			AbstractPagedInputView source, DataOutputView target) throws IOException {
		checkSkipReadForFixLengthPart(source);
		int length = source.readInt();
		target.writeInt(length);
		target.write(source, length);
	}
598557
public static void zip(File source, File target) throws IOException {
		zip(source, target, null);
	}
722363
static void backupDirectory(final File source, final File target) throws IOException {
        if (!target.exists()) {
            if (!target.mkdirs()) {
                throw PatchLogger.ROOT_LOGGER.cannotCreateDirectory(target.getAbsolutePath());
            }
        }
        final File[] files = source.listFiles(CONFIG_FILTER);
        for (final File file : files) {
            final File t = new File(target, file.getName());
            IoUtils.copyFile(file, t);
        }
    }
104752
public void compile() throws JasperException, FileNotFoundException {
        createCompiler();
        if (jspCompiler.isOutDated()) {
            if (isRemoved()) {
                throw new FileNotFoundException(jspUri);
            }
            try {
                jspCompiler.removeGeneratedFiles();
                jspLoader = null;
                jspCompiler.compile();
                jsw.setReload(true);
                jsw.setCompilationException(null);
            } catch (JasperException ex) {
                // Cache compilation exception
                jsw.setCompilationException(ex);
                if (options.getDevelopment() && options.getRecompileOnFail()) {
                    // Force a recompilation attempt on next access
                    jsw.setLastModificationTest(-1);
                }
                throw ex;
            } catch (FileNotFoundException fnfe) {
                // Re-throw to let caller handle this - will result in a 404
                throw fnfe;
            } catch (Exception ex) {
                JasperException je = new JasperException(
                        Localizer.getMessage("jsp.error.unable.compile"),
                        ex);
                // Cache compilation exception
                jsw.setCompilationException(je);
                throw je;
            }
        }
    }
741179
private void copyToTargetBufferFrom(ByteBuffer source) {
		if (this.targetBuffer == null) {
			return;
		}

		int needed = source.remaining();
		int available = this.limit - this.position;
		int toCopy = Math.min(needed, available);

		this.targetBuffer.getMemorySegment().put(this.position, source, toCopy);

		this.position += toCopy;
	}
774268
@Override
    public List<FileSource> createSources(String srcName) {
        final File dirOrFile = new File(srcName);

        final File[] files = dirOrFile.listFiles(FILTER);
        if (files != null) {
            final List<FileSource> sources = new ArrayList<FileSource>(files.length);
            for (File file : files) {
                sources.add(new FileSource(file));
            }
            return sources;
        } else {
            return Util.list(new FileSource(dirOrFile));
        }
    }
1094409
public void compile(final CCTask task, final File outputDir, final String[] sourceFiles, String[] args,
      final String[] endArgs, final boolean relentless, final CommandLineCompilerConfiguration config,
      final ProgressMonitor monitor) throws BuildException {
    BuildException exc = null;
    //
    // determine length of executable name and args
    //
    String command = getCommandWithPath(config);
    if (config.isUseCcache()) {
      // Replace the command with "ccache" and push the old compiler
      // command into the args.
      final String compilerCommand = command;
      command = CCACHE_CMD;
      args = ObjectArrays.concat(compilerCommand, args);
    }
    int baseLength = command.length() + args.length + endArgs.length;
    if (this.libtool) {
      baseLength += 8;
    }
    for (final String arg : args) {
      baseLength += arg.length();
    }
    for (final String endArg : endArgs) {
      baseLength += endArg.length();
    }
    if (baseLength > getMaximumCommandLength()) {
      throw new BuildException("Command line is over maximum length without specifying source file");
    }
    //
    // typically either 1 or Integer.MAX_VALUE
    //
    final int maxInputFilesPerCommand = getMaximumInputFilesPerCommand();
    final int argumentCountPerInputFile = getArgumentCountPerInputFile();
    for (int sourceIndex = 0; sourceIndex < sourceFiles.length;) {
      int cmdLength = baseLength;
      int firstFileNextExec;
      for (firstFileNextExec = sourceIndex; firstFileNextExec < sourceFiles.length
          && firstFileNextExec - sourceIndex < maxInputFilesPerCommand; firstFileNextExec++) {
        cmdLength += getTotalArgumentLengthForInputFile(outputDir, sourceFiles[firstFileNextExec]);
        if (cmdLength >= getMaximumCommandLength()) {
          break;
        }
      }
      if (firstFileNextExec == sourceIndex) {
        throw new BuildException("Extremely long file name, can't fit on command line");
      }

      ArrayList<String> commandlinePrefix = new ArrayList<>();
      if (this.libtool) {
        commandlinePrefix.add("libtool");
      }
      if((this.fortifyID !=null) && (!this.fortifyID.equals("")))
      {// If FortifyID attribute was set, run the Fortify framework

        commandlinePrefix.add("sourceanalyzer");
        commandlinePrefix.add("-b");
        commandlinePrefix.add(this.fortifyID);
      }
      commandlinePrefix.add(command);
      Collections.addAll(commandlinePrefix, args);

      int retval = 0;
      for (int j = sourceIndex; j < firstFileNextExec; j++) {
        ArrayList<String> commandlineSuffix = new ArrayList<>();

        for (int k = 0; k < argumentCountPerInputFile; k++) {
          commandlineSuffix.add(getInputFileArgument(outputDir, sourceFiles[j], k));
        }
        Collections.addAll(commandlineSuffix, endArgs);

        ArrayList<String> commandline = new ArrayList<>(commandlinePrefix);
        commandline.addAll(commandlineSuffix);
        final int ret = runCommand(task, workDir,
            commandline.toArray(new String[commandline.size()]));
        if (ret != 0) { retval = ret; }
      }
      if (monitor != null) {
        final String[] fileNames = new String[firstFileNextExec - sourceIndex];

        System.arraycopy(sourceFiles, sourceIndex + 0, fileNames, 0, fileNames.length);
        monitor.progress(fileNames);
      }
      //
      // if the process returned a failure code and
      // we aren't holding an exception from an earlier
      // interation
      if (retval != 0 && exc == null) {
        //
        // construct the exception
        //
        exc = new BuildException(getCommandWithPath(config) + " failed with return code " + retval, task.getLocation());

        //
        // and throw it now unless we are relentless
        //
        if (!relentless) {
          throw exc;
        }
      }
      sourceIndex = firstFileNextExec;
    }
    //
    // if the compiler returned a failure value earlier
    // then throw an exception
    if (exc != null) {
      throw exc;
    }
  }