FindVersionsByCRCs

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

Moderator: SourceGear

Post Reply
poschdi
Posts: 20
Joined: Fri Apr 25, 2008 3:49 am

FindVersionsByCRCs

Post by poschdi » Tue May 26, 2009 6:29 am

Hi,

I wanted to determine the current local file version and I find the FindVersionsByCRCs function.
I tried it with this code:

Code: Select all

FileCRC32 crc = new FileCRC32();
UInt32 icrc = crc.GetCRC(localFile);
VaultClientFile vcf = RepositoryUtil.FindVaultFileAtReposOrLocalPath(repFile);
Int64 version = ServerOperations.client.ClientInstance.FindVersionsByCRCs(vcf.ObjVerID,icrc);
Version was by all tests -1. If I compare the crc32 from this 2 files they are the same.
If the ObjVerID the correct parameter? Or where is my fault?

regards Florian

shannon

Re: FindVersionsByCRCs

Post by shannon » Tue May 26, 2009 7:20 am

The parameter is the objid not objverid. So you'd want to pass vcf.ID.

However, this function is going to return the ObjVerID, not a user-friendly Version, is that really what you're looking for?

poschdi
Posts: 20
Joined: Fri Apr 25, 2008 3:49 am

Re: FindVersionsByCRCs

Post by poschdi » Tue May 26, 2009 10:50 am

I want to determine which version a local file has. The function name sound good for that. That is the best function to analyse a file and get the versionnumber?

shannon

Re: FindVersionsByCRCs

Post by shannon » Tue May 26, 2009 11:02 am

I think I need to know more about what you're doing, so that I can better answer your questions. Is there always going to be a working folder set for the item you're looking at? You're basically looking for the number that the GUI client displays in the Local Version column?

poschdi
Posts: 20
Joined: Fri Apr 25, 2008 3:49 am

Re: FindVersionsByCRCs

Post by poschdi » Tue May 26, 2009 3:15 pm

No there isn´t set a working folder. I write a build tool with client and server functions. The client send command to the server with file he should get and build. Now I needed to know which local version is already exists to decide if the server can get this file or if there trouble with other changes. If there exists any function to do that? If not I had to save the latest get version manually.

shannon

Re: FindVersionsByCRCs

Post by shannon » Wed May 27, 2009 7:58 am

Try something like this:

Code: Select all

FileCRC32 crc = new FileCRC32();
UInt32 icrc = crc.GetCRC(localFile);
VaultClientFile vcf = RepositoryUtil.FindVaultFileAtReposOrLocalPath(repFile);
VaultVersionByCRCRequest[] req = new VaultVersionByCRCRequest[1];
req[0] = new VaultVersionByCRCRequest();
req[0].ObjID = vcf.ID;
req[0].CRC = icrc;

int retval = FindVersionsByCRCs(ref req);
if (retval == VaultStatusCode.Success)
	Int64 version = req[0].FoundVersion;
Note: if it doesn't find a version matching that crc, req.FoundVersion will be -1.

poschdi
Posts: 20
Joined: Fri Apr 25, 2008 3:49 am

Re: FindVersionsByCRCs

Post by poschdi » Thu May 28, 2009 6:48 am

Thy for this code example. I tried it but I get only this compiler error.
The name 'FindVersionsByCRCs' does not exist in the current context
Which assembly is needed for that function?

shannon

Re: FindVersionsByCRCs

Post by shannon » Thu May 28, 2009 7:21 am

Sorry, add this in front, like you did before:

ServerOperations.client.ClientInstance.

so the line will be this now:

int retval = ServerOperations.client.ClientInstance.FindVersionsByCRCs(ref req);

poschdi
Posts: 20
Joined: Fri Apr 25, 2008 3:49 am

Re: FindVersionsByCRCs

Post by poschdi » Thu May 28, 2009 8:10 am

Sorry I should be able to solve this by my self ;)

I my first tests and it look great. Exactly what I am looking for. Thy very much.

shannon

Re: FindVersionsByCRCs

Post by shannon » Thu May 28, 2009 8:19 am

Great, sorry for the typo.

If you need more help, let us know.

Post Reply