Search code examples
cmdperforceworking-directory

How to check if a current working directory is under Perforce workspace?


I want to make build automation tool using perforce as version control system.

When I run some batch to automatically download the latest version from the repository I want to check if a current working directory is valid.

For example, when I run

p4 add file.txt

for a file not under workspace, I get this message with error code = 1

Path 'c:\file.txt' is not under client's root 'D:\workspace'.

Is there some way to explicitly check if a directory is under client's root?


Solution

  • Do:

    p4 where ...
    

    to see where (if anywhere) your current directory is mapped in the current client view.

    Note that when you're syncing (downloading) files from the depot the current working directory isn't necessarily important. Just run p4 sync to sync your entire workspace, or use p4 sync //depot/path/... to sync an absolute depot path if that's easier than getting your script to find the correct path relative to the current client machine.