• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java FileUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.jgit.util.FileUtils的典型用法代码示例。如果您正苦于以下问题:Java FileUtils类的具体用法?Java FileUtils怎么用?Java FileUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FileUtils类属于org.eclipse.jgit.util包,在下文中一共展示了FileUtils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: clone

import org.eclipse.jgit.util.FileUtils; //导入依赖的package包/类
@Override
public File clone(String branch, Set<String> checkoutFiles, ProgressMonitor monitor) throws GitException {
    checkGitUrl();

    File gitDir = getGitPath().toFile();

    // delete existing git folder since may have conflict
    if (gitDir.exists()) {
        try {
            FileUtils.delete(gitDir.getParentFile(), FileUtils.RECURSIVE);
        } catch (IOException e) {
            // IO error on delete existing folder
        }
    }

    // git init
    initGit(checkoutFiles);

    pull(branch, monitor);
    return gitDir;
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:22,代码来源:JGitBasedClient.java


示例2: add

import org.eclipse.jgit.util.FileUtils; //导入依赖的package包/类
@Override
public void add( String name ) {
  try {
    if ( name.matches( ".*\\.mine$|.*\\.r\\d+$" ) ) { // Resolve a conflict
      File conflicted = new File( directory + File.separator + FilenameUtils.separatorsToSystem( FilenameUtils.removeExtension( name ) ) );
      FileUtils.rename( new File( directory, name ),
          conflicted,
          StandardCopyOption.REPLACE_EXISTING );
      svnClient.resolved( conflicted );
    } else {
      svnClient.addFile( new File( directory, name ) );
    }
  } catch ( Exception e ) {
    showMessageBox( BaseMessages.getString( PKG, "Dialog.Error" ), e.getMessage() );
  }
}
 
开发者ID:HiromuHota,项目名称:pdi-git-plugin,代码行数:17,代码来源:SVN.java


示例3: add

import org.eclipse.jgit.util.FileUtils; //导入依赖的package包/类
@Override
public void add( String filepattern ) {
  try {
    if ( filepattern.endsWith( ".ours" ) || filepattern.endsWith( ".theirs" ) ) {
      FileUtils.rename( new File( directory, filepattern ),
          new File( directory, FilenameUtils.removeExtension( filepattern ) ),
          StandardCopyOption.REPLACE_EXISTING );
      filepattern = FilenameUtils.removeExtension( filepattern );
      org.apache.commons.io.FileUtils.deleteQuietly( new File( directory, filepattern + ".ours" ) );
      org.apache.commons.io.FileUtils.deleteQuietly( new File( directory, filepattern + ".theirs" ) );
    }
    git.add().addFilepattern( filepattern ).call();
  } catch ( Exception e ) {
    showMessageBox( BaseMessages.getString( PKG, "Dialog.Error" ), e.getMessage() );
  }
}
 
开发者ID:HiromuHota,项目名称:pdi-git-plugin,代码行数:17,代码来源:UIGit.java


示例4: revertPath

import org.eclipse.jgit.util.FileUtils; //导入依赖的package包/类
@Override
public void revertPath( String path ) {
  try {
    // Delete added files
    Status status = git.status().addPath( path ).call();
    if ( status.getUntracked().size() != 0 || status.getAdded().size() != 0 ) {
      resetPath( path );
      org.apache.commons.io.FileUtils.deleteQuietly( new File( directory, path ) );
    }

    /*
     * This is a work-around to discard changes of conflicting files
     * Git CLI `git checkout -- conflicted.txt` discards the changes, but jgit does not
     */
    git.add().addFilepattern( path ).call();

    git.checkout().setStartPoint( Constants.HEAD ).addPath( path ).call();
    org.apache.commons.io.FileUtils.deleteQuietly( new File( directory, path + ".ours" ) );
    org.apache.commons.io.FileUtils.deleteQuietly( new File( directory, path + ".theirs" ) );
  } catch ( Exception e ) {
    showMessageBox( BaseMessages.getString( PKG, "Dialog.Error" ), e.getMessage() );
  }
}
 
开发者ID:HiromuHota,项目名称:pdi-git-plugin,代码行数:24,代码来源:UIGit.java


示例5: writeLargeFile_shouldWork

import org.eclipse.jgit.util.FileUtils; //导入依赖的package包/类
@Test
public void writeLargeFile_shouldWork() throws IOException {
  repoDir = FileUtils.createTempDir(getClass().getSimpleName(), null, null);
  repo = RepositoryUtils.createRepository(repoDir, true);
  DirCacheBuilder builder = CacheUtils.keepEverything(cache);
  byte[] largeData = new byte[50*1024*1024+1];
  Random random = new Random();
  random.nextBytes(largeData);
  AnyObjectId blobId = BlobUtils.insertBlob(largeData, repo);
  addFile("large.txt", REGULAR_FILE, blobId, builder);
  builder.finish();
  commitToMaster();
  initGitFileSystemForBranch(MASTER);
  byte[] data = someBytes();
  Path file = gfs.getPath("/large.txt");
  Files.write(file, data, APPEND);
}
 
开发者ID:beijunyi,项目名称:ParallelGit,代码行数:18,代码来源:FilesWriteTest.java


示例6: deleteFS

import org.eclipse.jgit.util.FileUtils; //导入依赖的package包/类
private boolean deleteFS(final FileSystem fileSystem) {
    final File gitDir = ((JGitFileSystemImpl) fileSystem).getGit().getRepository().getDirectory();
    fileSystem.close();
    fileSystem.dispose();

    try {
        if (System.getProperty("os.name").toLowerCase().contains("windows")) {
            //this operation forces a cache clean freeing any lock -> windows only issue!
            WindowCache.reconfigure(new WindowCacheConfig());
        }
        FileUtils.delete(gitDir,
                         FileUtils.RECURSIVE | FileUtils.RETRY);
        return true;
    } catch (java.io.IOException e) {
        throw new IOException("Failed to remove the git repository.",
                              e);
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:19,代码来源:JGitFileSystemProvider.java


示例7: deleteRepository

import org.eclipse.jgit.util.FileUtils; //导入依赖的package包/类
/**
 * Deletes the repository from the file system and removes the repository
 * permission from all repository users.
 * 
 * @param repositoryName
 * @return true if successful
 */
public boolean deleteRepository(String repositoryName) {
	try {
		closeRepository(repositoryName);
		// clear the repository cache
		clearRepositoryMetadataCache(repositoryName);
		
		RepositoryModel model = removeFromCachedRepositoryList(repositoryName);
		if (model != null && !ArrayUtils.isEmpty(model.forks)) {
			resetRepositoryListCache();
		}

		File folder = new File(repositoriesFolder, repositoryName);
		if (folder.exists() && folder.isDirectory()) {
			FileUtils.delete(folder, FileUtils.RECURSIVE | FileUtils.RETRY);
			if (userService.deleteRepositoryRole(repositoryName)) {
				logger.info(MessageFormat.format("Repository \"{0}\" deleted", repositoryName));
				return true;
			}
		}
	} catch (Throwable t) {
		logger.error(MessageFormat.format("Failed to delete repository {0}", repositoryName), t);
	}
	return false;
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:32,代码来源:GitBlit.java


示例8: submitFederationProposal

import org.eclipse.jgit.util.FileUtils; //导入依赖的package包/类
/**
 * Submit a federation proposal. The proposal is cached locally and the
 * Gitblit administrator(s) are notified via email.
 * 
 * @param proposal
 *            the proposal
 * @param gitblitUrl
 *            the url of your gitblit instance to send an email to
 *            administrators
 * @return true if the proposal was submitted
 */
public boolean submitFederationProposal(FederationProposal proposal, String gitblitUrl) {
	// convert proposal to json
	String json = JsonUtils.toJsonString(proposal);

	try {
		// make the proposals folder
		File proposalsFolder = getProposalsFolder();
		proposalsFolder.mkdirs();

		// cache json to a file
		File file = new File(proposalsFolder, proposal.token + Constants.PROPOSAL_EXT);
		com.gitblit.utils.FileUtils.writeContent(file, json);
	} catch (Exception e) {
		logger.error(MessageFormat.format("Failed to cache proposal from {0}", proposal.url), e);
	}

	// send an email, if possible
	sendMailToAdministrators("Federation proposal from " + proposal.url,
			"Please review the proposal @ " + gitblitUrl + "/proposal/" + proposal.token);
	return true;
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:33,代码来源:GitBlit.java


示例9: deleteWorkingFolders

import org.eclipse.jgit.util.FileUtils; //导入依赖的package包/类
public static void deleteWorkingFolders() throws Exception {
	if (ticgitFolder.exists()) {
		GitBlitSuite.close(ticgitFolder);
		FileUtils.delete(ticgitFolder, FileUtils.RECURSIVE);
	}
	if (ticgit2Folder.exists()) {
		GitBlitSuite.close(ticgit2Folder);
		FileUtils.delete(ticgit2Folder, FileUtils.RECURSIVE);
	}
	if (jgitFolder.exists()) {
		GitBlitSuite.close(jgitFolder);
		FileUtils.delete(jgitFolder, FileUtils.RECURSIVE);
	}
	if (jgit2Folder.exists()) {
		GitBlitSuite.close(jgit2Folder);
		FileUtils.delete(jgit2Folder, FileUtils.RECURSIVE);
	}
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:19,代码来源:GitDaemonTest.java


示例10: testAnonymousClone

import org.eclipse.jgit.util.FileUtils; //导入依赖的package包/类
@Test
public void testAnonymousClone() throws Exception {
	GitBlitSuite.close(ticgitFolder);
	if (ticgitFolder.exists()) {
		FileUtils.delete(ticgitFolder, FileUtils.RECURSIVE | FileUtils.RETRY);
	}

	// set push restriction
	RepositoryModel model = GitBlit.self().getRepositoryModel("ticgit.git");
	model.accessRestriction = AccessRestrictionType.PUSH;
	model.authorizationControl = AuthorizationControl.NAMED;
	GitBlit.self().updateRepositoryModel(model.name, model, false);
	
	CloneCommand clone = Git.cloneRepository();
	clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
	clone.setDirectory(ticgitFolder);
	clone.setBare(false);
	clone.setCloneAllBranches(true);
	GitBlitSuite.close(clone.call());		
	assertTrue(true);
	
	// restore anonymous repository access
	model.accessRestriction = AccessRestrictionType.NONE;
	model.authorizationControl = AuthorizationControl.NAMED;
	GitBlit.self().updateRepositoryModel(model.name, model, false);
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:27,代码来源:GitDaemonTest.java


示例11: testCreateRepository

import org.eclipse.jgit.util.FileUtils; //导入依赖的package包/类
@Test
public void testCreateRepository() throws Exception {
	String[] repositories = { "NewTestRepository.git", "NewTestRepository" };
	for (String repositoryName : repositories) {
		Repository repository = JGitUtils.createRepository(GitBlitSuite.REPOSITORIES,
				repositoryName);
		File folder = FileKey.resolve(new File(GitBlitSuite.REPOSITORIES, repositoryName),
				FS.DETECTED);
		assertNotNull(repository);
		assertFalse(JGitUtils.hasCommits(repository));
		assertNull(JGitUtils.getFirstCommit(repository, null));
		assertEquals(folder.lastModified(), JGitUtils.getFirstChange(repository, null)
				.getTime());
		assertEquals(folder.lastModified(), JGitUtils.getLastChange(repository).getTime());
		assertNull(JGitUtils.getCommit(repository, null));
		repository.close();
		RepositoryCache.close(repository);
		FileUtils.delete(repository.getDirectory(), FileUtils.RECURSIVE);
	}
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:21,代码来源:JGitUtilsTest.java


示例12: testClone

import org.eclipse.jgit.util.FileUtils; //导入依赖的package包/类
@Test
public void testClone() throws Exception {
	GitBlitSuite.close(ticgitFolder);
	if (ticgitFolder.exists()) {
		FileUtils.delete(ticgitFolder, FileUtils.RECURSIVE | FileUtils.RETRY);
	}
	
	CloneCommand clone = Git.cloneRepository();
	clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
	clone.setDirectory(ticgitFolder);
	clone.setBare(false);
	clone.setCloneAllBranches(true);
	clone.setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password));
	GitBlitSuite.close(clone.call());		
	assertTrue(true);
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:17,代码来源:GitServletTest.java


示例13: deleteBaseDirIfExists

import org.eclipse.jgit.util.FileUtils; //导入依赖的package包/类
private void deleteBaseDirIfExists() {
	if (this.basedir.exists()) {
		try {
			FileUtils.delete(this.basedir, FileUtils.RECURSIVE);
		}
		catch (IOException e) {
			throw new IllegalStateException("Failed to initialize base directory", e);
		}
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-release-tools,代码行数:11,代码来源:GitRepo.java


示例14: prepareLocalRepo

import org.eclipse.jgit.util.FileUtils; //导入依赖的package包/类
private static void prepareLocalRepo(String buildDir, String repoPath) throws IOException {
	File dotGit = new File(buildDir + repoPath + "/.git");
	File git = new File(buildDir + repoPath + "/git");
	if (git.exists()) {
		if (dotGit.exists()) {
			FileUtils.delete(dotGit, FileUtils.RECURSIVE);
		}
	}
	git.renameTo(dotGit);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-release-tools,代码行数:11,代码来源:TestUtils.java


示例15: checkout

import org.eclipse.jgit.util.FileUtils; //导入依赖的package包/类
private void checkout( String path, String commitId, String postfix ) {
  InputStream stream = open( path, commitId );
  File file = new File( directory + Const.FILE_SEPARATOR + path + postfix );
  try {
    org.apache.commons.io.FileUtils.copyInputStreamToFile( stream, file );
    stream.close();
  } catch ( IOException e ) {
    e.printStackTrace();
  }
}
 
开发者ID:HiromuHota,项目名称:pdi-git-plugin,代码行数:11,代码来源:UIGit.java


示例16: tryDeleteRepository

import org.eclipse.jgit.util.FileUtils; //导入依赖的package包/类
public static void tryDeleteRepository(String remoteUrl) {
	RepositoryCache repositoryCache = Activator.getDefault().getRepositoryCache();
	Repository[] repositories = repositoryCache.getAllRepositories();
	for (Repository repository : repositories) {
		if (getRemotesUrls(repository).contains(remoteUrl)) {
			try {
				FileUtils.delete(repository.getDirectory(),
						FileUtils.RECURSIVE | FileUtils.RETRY | FileUtils.SKIP_MISSING);
				FileUtils.delete(repository.getWorkTree(),
						FileUtils.RECURSIVE | FileUtils.RETRY | FileUtils.SKIP_MISSING);
			} catch (IOException e) {
			}
		}
	}
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:16,代码来源:GitTestHelper.java


示例17: closeRepository

import org.eclipse.jgit.util.FileUtils; //导入依赖的package包/类
@After
public void closeRepository() throws IOException {
  if(repo != null)
    repo.close();
  if(repoDir != null && repoDir.exists())
    FileUtils.delete(repoDir, FileUtils.RECURSIVE);
}
 
开发者ID:beijunyi,项目名称:ParallelGit,代码行数:8,代码来源:AbstractParallelGitTest.java


示例18: deleteRepositoryFolder

import org.eclipse.jgit.util.FileUtils; //导入依赖的package包/类
private void deleteRepositoryFolder() {
  try {
    if (repository.getDirectory().exists()) {
      FileUtils.delete(repository.getDirectory(), FileUtils.RECURSIVE | FileUtils.IGNORE_ERRORS);
    }
  } catch (Exception exception) {
    // Ignore the error since we want to throw the original error
    LOG.error(
        "Could not remove .git folder in path " + repository.getDirectory().getPath(), exception);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:12,代码来源:JGitConnection.java


示例19: destroyGitFsProvider

import org.eclipse.jgit.util.FileUtils; //导入依赖的package包/类
@After
public void destroyGitFsProvider() throws IOException {
    if (provider == null) {
        // this would mean that setup failed. no need to clean up.
        return;
    }

    provider.shutdown();

    if (provider.getGitRepoContainerDir() != null && provider.getGitRepoContainerDir().exists()) {
        FileUtils.delete(provider.getGitRepoContainerDir(),
                         FileUtils.RECURSIVE);
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:15,代码来源:AbstractTestInfra.java


示例20: cleanup

import org.eclipse.jgit.util.FileUtils; //导入依赖的package包/类
@AfterClass
@BeforeClass
public static void cleanup() {
    for (final File tempFile : tempFiles) {
        try {
            FileUtils.delete(tempFile,
                             FileUtils.RECURSIVE);
        } catch (IOException e) {
        }
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:12,代码来源:AbstractTestInfra.java



注:本文中的org.eclipse.jgit.util.FileUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ThrowsTree类代码示例发布时间:2022-05-22
下一篇:
Java BlockFileLoader类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap