RepositoryGetFileContents Method (IListFileSpec, Options)
|
Return the contents of the files identified by the passed-in file specs.
Namespace:
Perforce.P4
Assembly:
p4api.net (in p4api.net.dll) Version: 2024.2.269.3570
Syntax public IList<string> GetFileContents(
IList<FileSpec> filespecs,
Options options
)
Public Function GetFileContents (
filespecs As IList(Of FileSpec),
options As Options
) As IList(Of String)
public:
IList<String^>^ GetFileContents(
IList<FileSpec^>^ filespecs,
Options^ options
)
member GetFileContents :
filespecs : IList<FileSpec> *
options : Options -> IList<string>
Parameters
- filespecs
- Type: System.Collections.GenericIListFileSpec
- options
- Type: Perforce.P4Options
Return Value
Type:
IListStringRemarks
p4 help print
print -- Write a depot file to standard output
p4 print [-a -A -k -o localFile -q -m max] file[revRange] ...
p4 print -U unloadfile ...
Retrieve the contents of a depot file to the client's standard output.
The file is not synced. If file is specified using client syntax,
Perforce uses the client view to determine the corresponding depot
file.
By default, the head revision is printed. If the file argument
includes a revision, the specified revision is printed. If the
file argument has a revision range, then only files selected by
that revision range are printed, and the highest revision in the
range is printed. For details about revision specifiers, see 'p4
help revisions'.
The -a flag prints all revisions within the specified range, rather
than just the highest revision in the range.
The -A flag prints files in archive depots.
The -k flag suppresses keyword expansion.
The -o localFile flag redirects the output to the specified file on
the client filesystem.
The -q flag suppresses the initial line that displays the file name
and revision.
The -m flag limits print to the first 'max' number of files.
The -U option prints files in the unload depot (see 'p4 help unload'
for more information about the unload depot).
Examples
To get the contents of the file //depot/MyCode/README.txt:
GetFileContentsCmdOptions opts =
new GetFileContentsCmdOptions(GetFileContentsCmdFlags.None, null);
FileSpec filespec =
new FileSpec(new DepotPath("//depot/MyCode/README.txt"), null);
IList<FileSpec> filespecs = new List<FileSpec>();
filespecs.Add(filespec);
IList<String> target = Repository.GetFileContents(filespecs, opts);
To get the contents of the file //depot/MyCode/README.txt redirecting the
contents to local file C:\Doc\README.txt and supressing the file name
and revision line:
GetFileContentsCmdOptions opts =
new GetFileContentsCmdOptions(GetFileContentsCmdFlags.Suppress,
"C:\\Doc\\README.txt");
FileSpec filespec =
new FileSpec(new DepotPath("//depot/MyCode/README.txt"), null);
IList<FileSpec> filespecs = new List<FileSpec>();
filespecs.Add(filespec);
IList<String> target = Repository.GetFileContents(filespecs, opts);
See Also