I'm using perforce api to read the list of folders in a branch in java.
I reached to a point which tells me to get Branch spec.
http://www.perforce.com/perforce/doc.current/manuals/p4java-javadoc/com/perforce/p4java/server/IServer.html#getBranchSpec(java.lang.String)
Used the following code to implement getDirectories()
method.
String serverUri = "p4java://<server-address>:1666?userName=username&password=password";
IServer server = ServerFactory.getServer(serverUri, null);
server.connect();
List<IFileSpec> inputList = FileSpecBuilder.makeFileSpecList("//domain/code/branches/");
System.out.println("HelloPerforce.main() >> passed list >> " + inputList );
List<IFileSpec> outputList = server.getDirectories(inputList , false, false, false);
System.out.println("HelloPerforce.main() >> directory list >> " + outputList );
Output: The outputList is null.
Expected output: List of folder names inside //domain/code/branches
directory.
Can someone please point me what am I missing here?
What you want is getDirectories(). A branch spec is a mapping between two branches (which are usually but not necessarily top-level depot paths). Usually if you're talking about a single "branch" what you're talking about is a depot path, e.g. "//depot/main", rather than a branch spec. To get the list of folders under the "main" branch you'd ask for the list of directories matching "//depot/main/*".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With