You can take a look at the file_get_* and file_put_* callbacks, these give you the ability to transfer a binary or ascii file.
file_get_start (directory, file, type, buffer_size, start_pos)
Get the first part of a file. The controller will return the following parameters:
‘file_content’ string or void data area containing the first section of the file (see type below to determine type).
‘id’ string identifier to be used in file_get_next and file_get_end calls.
‘position’ current file position
‘read’ bytes read by this call. If this value is 0, the next call should be file_get_end.
Parameter | Type | Req | Description |
directory | string | yes | The directory containing the file. |
file | string | yes | The file to fetch. |
type | string | yes | The file type, basically “binary”, “ascii” or “string”. Specify “binary” if the ‘raw’ contents of the file are needed. Specify “string” if you want the file contents returned as a PDS_PCH instead of PDS_VOID. This is useful for interactive checking of a file, but note that the file must be a ‘clean’ text file. |
buffer_size | integer | no | Specify the size of each chunk you want to fetch from the file. The default is 1k. Note that the default buffer_size is only appropriate for small files. |
start_pos | integer | no | Seek to this file position before starting to read the file. The default is 0. |
file_get_next (id)
Get the next part of the file. Returns the same as the file_get_first call above.
Parameter | Type | Req | Description |
id | string | yes | The file identifier returned by the file_get_start call. |
file_get_end (id)
Finish fetching from the file.
Parameter | Type | Req | Description |
id | string | yes | The file identifier returned by the file_get_start call. |
file_put_start (directory,file,type,mode)
Write the first part of a file. The file contents to be written are supplied in an additional parameter ‘file_content’ of type VOID. The following parameters are returned:
‘id’ – string identifier to be used with subsequent calls to file_put_next and file_put_end.
‘written’ – total bytes written to the file.
Parameter | Type | Req | Description |
directory | string | yes | The directory that will contain the file. A directory hierarchy will be created if it does not exist. |
file | string | yes | The file to store. |
type | string | no | The file type, “binary” or “ascii”. “ascii” is the default if not specified. |
mode | string | yes | Octal string defining the file permissions on file creation. Only significant on UNIX/Linux platforms. |
file_put_next (id)
Write the next part of the file. The data to be added to the file are supplied in an additional parameter ‘file_content’ of type VOID. The following parameters are returned:
‘id’ – string identifier to be used with subsequent calls to file_put_next and file_put_end.
‘written’ – total bytes written to the file.
Parameter | Type | Req | Description |
id | string | yes | The file identifier returned by the file_put_start call. |
file_put_end (id)
Finish writing to the file. The controller will clean up internal information about the file identified by the ‘id’ parameter. The following parameters are returned:
‘id’ – string identifier to be used with subsequent calls to file_put_next and file_put_end.
‘written’ – total bytes written to the file.