ReplaceVirtualFileIfRevision
Workflow data tools, Virtual files, ActiveX, DLL
Description
Replaces the contents of a virtual file only when its revision still matches
Syntax
ActiveX
Function PDFlib::ReplaceVirtualFileIfRevision(FileName As String, ExpectedRevision As Double, Data As Variant) As LongDLL
int DLReplaceVirtualFileIfRevision(int InstanceID, const wchar_t* FileName, long long ExpectedRevision, const char* Data, int DataLength);
int DLReplaceVirtualFileIfRevisionA(int InstanceID, const char* FileName, long long ExpectedRevision, const char* Data, int DataLength);
Parameters
| InstanceID | Library instance returned by DLCreateLibrary |
|---|---|
| FileName | Registered file name |
| ExpectedRevision | Revision read with GetVirtualFileRevision |
| Data | Replacement bytes; may be Nil when DataLength is 0 |
| DataLength | Number of bytes in Data |
Return values
Returns 1 when the file was replaced and received a new revision, or 0 when the file is missing, the revision changed or a limit would be exceeded
Remarks
The comparison and replacement happen atomically under the registry lock
The virtual file registry is shared by every library instance in the process and is used by every mem:// path and by registered file names; scope workflow resources under a unique prefix
ActiveX exposes this method on IPDFlibrary24; obtain it with CoPDFlibrary.CreateEditionTools24 or query the default interface of PDFlibAX 4.74 or later. ActiveX takes the revision as a Double and the new content as a byte array Variant; an Empty Variant writes an empty file
All editions include these functions. Failed ActiveX calls return an empty string, 0 or Empty and record the reason for GetWorkflowToolsError. The C#, VB.NET and Visual C++ WorkflowTools examples in the DLL and ActiveX demo folders show a complete request, page plan and rollback workflow
See also
Workflow data tools · Virtual file registry · GetWorkflowToolsError