version 2003
PA_DocumentExistOnServer (docName; fileType; fileCreator) char
Parameter | Type | Description | |
docName | char * | Name of the file to test | |
fileType | unsigned long | 4 bytes FileType of the file to test | |
fileCreator | unsigned long | 4 bytes FileCreator of the file to test | |
Function result | char | 1 = The document exists. 0 = File not found |
Description
While running under 4D Client, the routine PA_DocumentExistOnServer allows the 4D plug-in to test if a document located on the server machine exists and if the plug-in can access to it.
NOTE:
This routine is available only with 4D Client. To detect if the 4D plug-in is running on 4D Client, use PA_Is4DClient.
Before the call the 4D plug-in passes:
The name, in docName, of the document to test. The 4D plug-in MUST pass the short name of the document, NOT the pathname to the document. The document will be located in the same folder/directory than the structure.
The File Type, in fileType, and File Creator in fileCreator, of the file to test. Under Windows, this information is mapped to the Windows file plug-ins declared within the database using the 4D command MAP FILE TYPES or by a ExtW resource located in the .RSR file of a 4D plug-in available for the database.
After the call:
If the document does not exist, the routine returns 0.
If the document exists and the 4D plug-in can access it (*), the routine returns 1.
If the document exists but cannot be not accessed (*), the routine returns 1 and the appropriate MacOS-based File Manager error code in PA_GetLastError.
(*) This routine actually tries to open the document in read-write access (and then immediately close it if successful) in order to determine if the document can be accessed.
Example
Try to avoid error before reading a document on the server.
long WrapReceiveDocument(char *name, char *data) { if( PA_DocumentExistsOnServer(name) && PA_GetLastError() == eER_NoErr) ) { /* . . . read the doc . . . */ } }
See Also
PA_ReceiveDocumentFromServer, PA_SendDocumentToServer.
Error Handling
Use PA_GetLastError to see if an error occurred