Delete a file using Java Plain API
Marc Bauer (11●1)
| asked Jan 29 '18, 7:01 a.m.
edited Jan 22 '19, 1:56 p.m. by David Lafreniere (4.8k●7) How do I delete a file using Plain Java API?
|
One answer
ITeamRepository repo = getRepo();
IWorkspaceHandle workspaceHandle = getWorkspace();
IVersionableHandle fileToDelete = getVersionable();
IChangeSetHandle changeSet = getChangeSet(); // Change set to check into
IWorkspaceManager wm = ScmPlatform.getWorkspaceManager(repo);
IWorkspaceConnection wc = wm.getWorkspaceConnection(workspaceHandle, monitor);
Collection ops = new ArrayList();
Comments
Gidi Gal
commented Mar 31 '19, 11:18 a.m.
Is there a public API for deleting file\folder from sandbox without committing the local change to change-set ?
Did you mean undo the unresolved file changes? If so,
ILocalChangeManager lcm = FileSystemCore.getSharingManager().getLocalChangeManager();
You have to iterate over the changes to find your change:
ILocalChange[] localChanges = lscm.getPendingChanges(...);
Then call undo changes only for those changes you have to undo:
lscm.undoChanges(localChanges, ...);
Gidi Gal
commented Apr 01 '19, 6:30 a.m.
Thanks for your reply, Shashikant.
No, the file in sandbox may be in sync with the stream. Up until now I used java.io.File.delete to delete the file and then I fetched the local changes with ILocalChangeManager in order to check-in them or check-in and deliver. java.io.File.delete returns sometimes false on failure with no documentation on the relevant error. I'm looking for a public RTC SDK client API to replace it.
|
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.