# Task: output local pathnames of opened files # # num of calls to 'p4': 2 # status: tested on Darwin Mac OS X using "p4 -R" # # room for optimization/improvement: add getopts call # # Copyright 2004 Perforce Corporation, Inc. All rights reserved. require "readp4marshal" p4 = P4Marshal.new #----------------------------------------------------------- # first call to P4: 'p4 client -o' #----------------------------------------------------------- cl_spec = p4.run("client", "-o")[0] cl_name = cl_spec['Client'] cl_root = cl_spec['Root'] #----------------------------------------------------------- # second call to P4: 'p4 opened' # # Loop through the output of 'p4 opened'. The tagged # output gives us a client-syntax version of the name # in the form "//clientName/rest-of-local-path", # so we substitute the client root dir before printing. #----------------------------------------------------------- p4.run("opened").each do |o| clientName = o['clientFile'] localName = clientName.sub("//#{cl_name}/", "#{cl_root}") puts localName end