当前位置: 首页>>代码示例>>Java>>正文


Java FileUtils类代码示例

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


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


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