Hi,
I'm currently working on a program in C++ using the latest API.
My problem starts when I delete a file using the program. If I create a new file at the same place with the same name, the file will be "marked for delete" or "deleted at HEAD revision".
I'm trying to add a check when I add the file to prevent this. But I can't find a way to get the state of the file since the file is no longer in the folder! How can I check, using the API, if the file is "marked for delete" or "deleted at HEAD revision"?
Thank you very much!


C++ API / How to get state of deleted file
Started by mazay, Oct 26 2018 07:25 PM
API C++ deleted state
4 replies to this topic
#1
Posted 26 October 2018 - 07:25 PM
#2
Posted 27 October 2018 - 09:46 PM
Quote
My problem starts when I delete a file using the program. If I create a new file at the same place with the same name, the file will be "marked for delete" or "deleted at HEAD revision".
How do you "delete the file" and "create a new file" in the context of the program? Simply deleting/creating a file on your local filesystem won't change its state in Perforce, so you're clearly running some Perforce commands, but you don't say which ones.
Quote
How can I check, using the API, if the file is "marked for delete" or "deleted at HEAD revision"?
To see if a file is open and for what action, you can use "p4 opened".
To see what the head revision of a file is, you can use "p4 files".
You can also use "p4 fstat" which bundles together a whole bunch of information (including those two pieces).
#3
Posted 29 October 2018 - 03:11 PM
Thanks for your help
I use the method ClientAPI::Run() for every command. For example, when I delete a file, I use ClientAPI::Run("delete", ClientUser). My problem is that if I run ClientAPI::Run(fstat, ClientUser), The method only returns a success or fail and no information about the files. How can I access the information using ClientAPI::Run()?
I use the method ClientAPI::Run() for every command. For example, when I delete a file, I use ClientAPI::Run("delete", ClientUser). My problem is that if I run ClientAPI::Run(fstat, ClientUser), The method only returns a success or fail and no information about the files. How can I access the information using ClientAPI::Run()?
#4
Posted 29 October 2018 - 05:36 PM
To handle output you need to implement the Output* handlers in your ClientUser subclass. Most output will be returned via either ClientUser::Message() (which handles an Error message object -- for legacy reasons these are called "Error"s but they can actually represent any kind of human-readable message) or ClientUser::OutputStat() (which handles a StrDict dictionary object).
To get an idea of what these output objects look like, run commands at the command line with the global flags "-e" (to see Error info) or "-Ztag" (to see "tagged" StrDicts). Note that "p4 fstat" is a special case and always runs in "tagged" mode rather than returning a human-readable message.
To get an idea of what these output objects look like, run commands at the command line with the global flags "-e" (to see Error info) or "-Ztag" (to see "tagged" StrDicts). Note that "p4 fstat" is a special case and always runs in "tagged" mode rather than returning a human-readable message.
#5
Posted 30 October 2018 - 07:55 PM
Thanks, that answered my question
Also tagged with one or more of these keywords: API, C++, deleted, state
Usage →
APIs →
BOM Issue with "Perforce Java API 2019.1.1827134"Started by Jerry, 06 Sep 2019 ![]() |
|
![]() |
||
Usage →
APIs →
User Access to a Change ListStarted by Vishwajit, 28 Mar 2019 ![]() |
|
![]() |
||
Usage →
Swarm →
Updating review subscription/reviewer list through apiStarted by aegissid, 05 Feb 2019 ![]() |
|
![]() |
||
Usage →
APIs →
Issues with P4 API (2017.2, 2018.3, 2018.4)Started by GEngines, 13 Jan 2019 ![]() |
|
![]() |
||
Usage →
APIs →
Setting changelist review-id and review-stateStarted by mbolduc, 14 Dec 2018 ![]() |
|
![]() |
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users