获取文件更改集的完整路径
问题描述:
我正在搜索位于更改集的.txt文件。 然后我需要通过我的电脑本地创建此文件的完整路径目录。获取文件更改集的完整路径
例如,如果有一个名为“test.txt的”,它的位于文件: PROJECT1 - > Folder1中 - >文件夹2 - > test.txt的
到目前为止我已成功地搜索此文件。 现在我需要获取完整的目录,并创建了我的电脑类似的一个:在我的电脑 结果: Folder1中 - >文件夹2 - > test.txt的
这就是我所做的搜索中的文件变更和检索:
public IFileItem getTextFileFile(IChangeSet changeSet, ITeamRepository repository) throws TeamRepositoryException{
IVersionableManager vm = SCMPlatform.getWorkspaceManager(repository).versionableManager();
List changes = changeSet.changes();
IFileItem toReturn = null;
for(int i=0;i<changes.size();i++) {="" <br=""> Change change = (Change) changes.get(i);
IVersionableHandle after = change.afterState();
if(after != null && after instanceof IFileItemHandle) {
IFileItem fileItem = (IFileItem) vm.fetchCompleteState(after, null);
if(fileItem.getName().contains(".txt")) {
toReturn = fileItem;
break;
} else {
continue;
}
}
}
if(toReturn == null){
throw new TeamRepositoryException("Could not find the file");
}
return toReturn;
}
我使用RTC:4 运:XP提前
感谢。
答
我有以下IConfiguration那我拿来用以下:
IWorkspaceManager workspaceManager = SCMPlatform.getWorkspaceManager(repository);
IWorkspaceSearchCriteria wsSearchCriteria = WorkspaceSearchCriteria.FACTORY.newInstance();
wsSearchCriteria.setKind(IWorkspaceSearchCriteria.STREAMS);
wsSearchCriteria.setPartialOwnerNameIgnoreCase(projectAreaName);
List <iworkspacehandle> workspaceHandles = workspaceManager.findWorkspaces(wsSearchCriteria, Integer.MAX_VALUE, Application.getMonitor());
IWorkspaceConnection workspaceConnection = workspaceManager.getWorkspaceConnection(workspaceHandles.get(0),Application.getMonitor());
IComponentHandle component = changeSet.getComponent();
IConfiguration configuration = workspaceConnection.configuration(component);
List lst = new ArrayList<string>();
lst=configuration.locateAncestors(lst,Application.getMonitor());
=========================== ==============
我们得到的文件项的完整路径,我提出了以下方法,我从有:
=== ======================================
private String getFullPath(List ancestor, ITeamRepository repository)
throws TeamRepositoryException {
String directoryPath = "";
for (Object ancestorObj : ancestor) {
IAncestorReport ancestorImpl = (IAncestorReport) ancestorObj;
for (Object nameItemPairObj : ancestorImpl.getNameItemPairs()) {
NameItemPairImpl nameItemPair = (NameItemPairImpl) nameItemPairObj;
Object item = SCMPlatform.getWorkspaceManager(repository)
.versionableManager()
.fetchCompleteState(nameItemPair.getItem(), null);
String pathName = "";
if (item instanceof IFolder) {
pathName = ((IFolder) item).getName();
}
else if (item instanceof IFileItem) {
pathName = ((IFileItem) item).getName();
}
if (!pathName.equals(""))
directoryPath = directoryPath + "\\" + pathName;
}
}
return directoryPath;
}
=========================================
所以...... Tim Mok在https://jazz.net/forum/questions/103355/java-get-the-full-path-of-a-file-at-change-set问你,你还在不愿意“在这里提供你的尝试给出这些答案出了什么问题”?没有错误信息?没什么? (更不用说Java的RTC,操作系统的版本......基本知识:它可以帮助我们帮助你) – VonC 2013-02-20 21:57:52
它是RTC 4的win.xp – Echo 2013-02-20 22:27:11
对不起,因为我一直在这里和那里搜索对于任何能够帮助像我这样的新手进入RTC的东西。我已经在那里更新了我的问题 – Echo 2013-02-20 22:29:02