Getting the local path for an item

Post your questions regarding using the Vault and Fortress API in your programs.

Moderator: SourceGear

Post Reply
MattTrinder
Posts: 24
Joined: Tue Feb 12, 2008 8:07 am

Getting the local path for an item

Post by MattTrinder » Wed Apr 23, 2008 7:32 am

Hi

Given a vault path to a file

$/path/to/file.txt

Using the API, how can I get the path that the file is checked out to...?

ie. c:\develop\path\to\file.txt

Thanks

Matt

shannon

Post by shannon » Wed Apr 23, 2008 8:13 am

First you need to get the file id from the repository path (if you aren't using ServerOperations/RepositoryUtil, you can look at their code to see how its done there):

VaultClientFile vcf = RepositoryUtil.FindVaultFileatReposOrLocalPath(repoPath);
long fileId = vcf.ID;

Then get the check out list:

VaultCheckOutList coList = ServerOperations.ProcessCommandListCheckOuts();

Then loop over the VaultCheckOutItem objects and match for the one you're looking for by fileId. Once you have the VaultCheckOutItem object matched, then loop over the VaultCheckOutUser[] and match by some quality:

string localPath;
foreach (VaultCheckOutUser coUser in coItem.CheckOutUsers) {
if ( // match here by user name or some other quality)
localPath = coUser.LocalPath;
}

Hope that helps,
Shannon

MattTrinder
Posts: 24
Joined: Tue Feb 12, 2008 8:07 am

Post by MattTrinder » Wed Apr 23, 2008 9:46 am

thanks, that got it... :D

Post Reply