Takes a {@link FilePath}+{@link FileCallable} pair and returns the equivalent {@link Callable}.
When executing the resulting {@link Callable}, it executes {@link FileCallable#act(FileCallable)}
on this {@link FilePath}.

@since 1.522
518612
public <V> Callable<V,IOException> asCallableWith(final FileCallable<V> task) {
        return new CallableWith<>(task);
    }
553589
public V action(Callable<V> callable) throws Exception {
        Exception re;
        RetryState retryState = retryStrategy.getRetryState();
        do {
            try {
                return callable.call();
            } catch (Exception e) {
                re = e;
                if (Thread.interrupted() || isInterruptTransitively(e)) {
                    re = new InterruptedException(e.getMessage());
                    break;
                }
                if (!transientExceptionDetector.isTransient(e)) {
                    break;
                }
            }
            enqueueRetryEvent(new RetryEvent(this, retryState, re));
            retryState.delayRetry();
        } while (retryState.hasRetries());
        throw re;
    }
578312
@Override
    public <Result> String add(final Callable<Result> callable,
                               final TaskCallback<Result> callback,
                               final Object caller) {
        return execute(callable, callback, caller);
    }
564282
public static <T> T executeIn(URL[] urls, Callable<T> callable) throws Exception
   {
      ClassLoader savedClassLoader = Thread.currentThread().getContextClassLoader();
      URLClassLoader newClassLoader = null;
      try
      {
         newClassLoader = new URLClassLoader(urls, savedClassLoader);
         return executeIn(newClassLoader, callable);
      }
      finally
      {
         Streams.closeQuietly(newClassLoader);
      }
   }
602736
public static void doFile(File f)
                              throws Exception {
        // If this is a directory, walk each file/dir in that directory
        if (f.isDirectory()) {
            String files[] = f.list();
            for(int i=0; i < files.length; i++)
                doFile(new File(f, files[i]));
        }

        // otherwise, if this is a groovy file, parse it!
        else if (f.getName().endsWith(".groovy")) {
            System.err.println(" --- "+f.getAbsolutePath());
            // parseFile(f.getName(), new FileInputStream(f));
            SourceBuffer sourceBuffer = new SourceBuffer();
            UnicodeEscapingReader unicodeReader = new UnicodeEscapingReader(new FileReader(f),sourceBuffer);
            GroovyLexer lexer = new GroovyLexer(unicodeReader);
            unicodeReader.setLexer(lexer);
            parseFile(f.getName(),lexer,sourceBuffer);
        }
    }

    // Here's where we do the real work...
    public static void parseFile(String f, GroovyLexer l, SourceBuffer sourceBuffer)
                                 throws Exception {
        try {
            // Create a parser that reads from the scanner
            GroovyRecognizer parser = GroovyRecognizer.make(l);
            parser.setSourceBuffer(sourceBuffer);
            parser.setFilename(f);
                        
                        if (whitespaceIncluded) {
                            GroovyLexer lexer = parser.getLexer();
                            lexer.setWhitespaceIncluded(true);
                            while (true) {
                                Token t = lexer.nextToken();
                                System.out.println(t);
                                if (t == null || t.getType() == Token.EOF_TYPE)  break;
                            }
                            return;
                        }

            // start parsing at the compilationUnit rule
            parser.compilationUnit();
            
            System.out.println("parseFile "+f+" => "+parser.getAST());

            // do something with the tree
            doTreeAction(f, parser.getAST(), parser.getTokenNames());
        }
1146551
public static <T> T executeWithinProcessApplication(Callable<T> callback, ProcessApplicationReference processApplicationReference) {
    return executeWithinProcessApplication(callback, processApplicationReference, null);
  }
988064
@Override
    public boolean isSameFile(final Path path1, final Path path2) throws IOException {

        // Only equal if pointing to same FS
        final FileSystem fs1 = path1.getFileSystem();
        final FileSystem fs2 = path2.getFileSystem();
        if (fs1 != fs2) {
            return false;
        }

        // Same if the normalized form points to the same location
        final String normalized1 = path1.normalize().toString();
        final String normalized2 = path2.normalize().toString();
        return normalized1.equals(normalized2);
    }
237840
@Override
    public File call() throws Exception {
        try {
            latch.await();

            if (isTimeoutEnabled()) {
                timedExecutor.schedule(new Runnable() {
                    public void run() {
                        try {
                            if (abortableDownload.getState() != Transfer.TransferState.Completed) {
                                abortableDownload.abort();
                            }
                        } catch (Exception e) {
                            throw new SdkClientException(
                                "Unable to abort download after timeout", e);
                        }
                    }
                }, timeout, TimeUnit.MILLISECONDS);
            }

            setState(Transfer.TransferState.InProgress);
            createParentDirectoryIfNecessary(dstfile);

            if (isDownloadParallel) {
                downloadInParallel();
            } else {
                downloadAsSingleObject();
            }
            return dstfile;
        } catch (Throwable t) {
            cleanupAfterException();
            if (t instanceof Exception) {
                throw (Exception) t;
            } else {
                throw (Error) t;
            }
        }
    }
1120374
function attemptCallback(filePath, callback, attempts) {

	try {

		callback();
		return;

	} catch (error) {

		if (attempts === 0) {
			console.error('takeown: callback failed - exceeded attempts');
			throw error;
		}

		switch (error.code) {

			case 'EPERM':
			case 'EACCES':
			case 'EBUSY':
			case 'ENOTEMPTY':
				return attemptCallback(filePath, callback, --attempts);

			default:
				throw error;
		}
	}
}
1069838
public <V> V run(Callable<V> testCallable) throws Exception {
    try {
      beforeRun();
      return testCallable.call();
    } finally {
      afterRun();
      restoreOriginal();
    }
  }
449256
public static boolean isFileExist(String filePath) {
        if (StringUtils.isEmpty(filePath)) {
            return false;
        }

        File file = new File(filePath);
        return (file.exists() && file.isFile());
    }
5604
public static <V,T extends Throwable> V execute(TaskListener listener, String rootUsername, String rootPassword, final Callable<V, T> closure) throws T, IOException, InterruptedException {
        VirtualChannel ch = start(listener, rootUsername, rootPassword);
        try {
            return ch.call(closure);
        } finally {
            ch.close();
            ch.join(3000); // give some time for orderly shutdown, but don't block forever.
        }
    }
820706
private <T> T call(UfsCallable<T> callable) throws IOException {
    LOG.debug("Enter: {}", callable);
    String methodName = callable.toString().split(NAME_SEPARATOR)[0];
    try (Timer.Context ctx = MetricsSystem.timer(getQualifiedMetricName(methodName)).time()) {
      T ret = callable.call();
      LOG.debug("Exit (OK): {}", callable);
      return ret;
    } catch (IOException e) {
      MetricsSystem.counter(getQualifiedFailureMetricName(methodName)).inc();
      LOG.debug("Exit (Error): {}, Error={}", callable, e.getMessage());
      throw e;
    }
  }
520486
public static <T> Callable<T> callable(CheckedCallable<T> callable) {
        return callable(callable, THROWABLE_TO_RUNTIME_EXCEPTION);
    }
1153108
@SuppressWarnings("squid:S2221")
    public <T> T runAsSystem(final Callable<T> callable) {
        return runAsSystemAsTenant(callable, tenantAware.getCurrentTenant());
    }
1257381
def _perform_file_action(self, filename, action):
        
        ext = os.path.splitext(filename)[1]
        try:
            func = getattr(self, '_{}_{}'.format(action, ext[1:]))
        except AttributeError:
            raise Exception('Unsupported file type {}'.format(ext[1:]))
        func(filename)
546591
static PathFileObject createJarPathFileObject(JavacPathFileManager fileManager,
            final Path path) {
        return new PathFileObject(fileManager, path) {
            @Override
            String inferBinaryName(Iterable<? extends Path> paths) {
                return toBinaryName(path);
            }
        };
    }