Jump to content


Getting local path from depot path using C#


  • Please log in to reply
3 replies to this topic

#1 ghost654

ghost654

    Member

  • Members
  • PipPip
  • 14 posts

Posted 16 January 2019 - 06:40 PM

If I had the depot path, which command would give me the local workspace path from that depot path.  Using the API in c#

#2 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 894 posts

Posted 16 January 2019 - 09:52 PM


For a synced file, p4 have is the canonical/simplest way to find out the local path given a depot path.  p4 fstat will also work.

For a file that has not yet been synced p4 have will return nothing, but p4 where will show you where any given path is mapped to.

For cases where a file has been synced but the mapping has changed since then, p4 have and p4 where will show you two different things (have shows the path you have the file at currently, whereshows where it will go the next time you sync).


#3 ghost654

ghost654

    Member

  • Members
  • PipPip
  • 14 posts

Posted 16 January 2019 - 11:16 PM

yeah im already syncing the file with this

FileSpec dirToSync = new FileSpec(new DepotPath(depotPath), null);
IList<FileSpec> syncedFiles = p4Connection.P4Client.SyncFiles(null, dirToSync);


I don't think any of those commands exist for the C# .net api.... I have used 'p4 where' in some python tools i made, but I need to do this in c#

#4 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 894 posts

Posted 17 January 2019 - 01:08 AM

I haven't ever used the C# API, but all the different APIs are mostly just thin wrappers around the CLI commands.  Doesn't that FileSpec object you get back from SyncFiles contain a "LocalPath" property already?

If you need to run "p4 have" from the C# API it's here (thanks, Google!):
https://www.perforce...SyncedFiles.htm




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users