ThingWorx C SDK
|
ThingWorx file transfer structure definitions and functions. More...
#include "twOSPort.h"
#include "twDefinitions.h"
#include "twDefaultSettings.h"
#include "twList.h"
#include "twInfoTable.h"
Go to the source code of this file.
Classes | |
struct | twFileTransferInfo |
File Transfer Information structure definition. More... | |
struct | twFile |
File/directory data structure. More... | |
Typedefs | |
typedef struct twFileTransferInfo | twFileTransferInfo |
File Transfer Information structure definition. | |
typedef void(* | file_cb) (char fileRcvd, twFileTransferInfo *info, void *userdata) |
Signature of a callback function that is registered to be called when a file transfer completes or fails. More... | |
typedef struct twFile | twFile |
File/directory data structure. | |
Functions | |
twFileTransferInfo * | twFileTransferInfo_Create (twInfoTable *it) |
Creates a new twFileTransferInfo structure. More... | |
void | twFileTransferInfo_Delete (void *transferInfo) |
Frees all memory associated with a twFileTransferInfo structure and all its owned substructures. More... | |
int | twFileManager_Create () |
Creates the twFileManager singleton. More... | |
int | twFileManager_Delete () |
Deletes the twFileManager singleton and all its owned substructures. More... | |
int | twFileManager_AddVirtualDir (const char *thingName, char *dirName, char *path) |
Adds a virtual directory to the twFileManager singleton. More... | |
int | twFileManager_RemoveVirtualDir (const char *thingName, char *dirName) |
Removes a virtual directory from the twFileManager singleton. More... | |
twList * | twFileManager_ListVirtualDirs (const char *entityName) |
Returns a list of all virtual directories from the twFileManager singleton. More... | |
twFile * | twFileManager_OpenFile (const char *thingName, const char *path, const char *filename, char *mode) |
Creates a new twFile structure and populates it with information obtained from a file/directory. More... | |
void | twFileManager_CloseFile (void *file) |
Closes a file and frees all memory associated with the twFile structure. More... | |
twFile * | twFileManager_GetOpenFile (const char *thingName, const char *path, const char *filename, const char *tid, char *isTimedOut) |
Checks to see if the specified file is already open. More... | |
char * | twFileManager_GetRealPath (const char *thingName, const char *path, const char *filename) |
Gets the native file system path for a file. More... | |
void | twFileManager_MakeFileCallback (char rcvd, twFileTransferInfo *fti) |
Forces the file to complete a callback. More... | |
int | twFileManager_RegisterFileCallback (file_cb cb, char *filter, char onceOnly, void *userdata) |
Registers a function to be called when a file transfer completes. More... | |
int | twFileManager_UnregisterFileCallback (file_cb cb, char *filter, void *userdata) |
Unregisters a file callback function registered via twFileManager_RegisterFileCallback(). More... | |
int | twFileManager_SendFile (const char *sourceRepo, const char *sourcePath, const char *sourceFile, const char *targetRepo, const char *targetPath, const char *targetFile, uint32_t timeout, char asynch, char **tid) |
int | twFileManager_GetFile (const char *sourceRepo, const char *sourcePath, const char *sourceFile, const char *targetRepo, const char *targetPath, const char *targetFile, uint32_t timeout, char asynch, char **tid) |
Gets a file from the server. More... | |
void | twFileManager_CheckStalledTransfers () |
Checks for any stalled file transfers and deletes them. More... | |
twList * | twFileManager_ListEntities (const char *entityName, const char *path, const char *namemask, char returnType) |
Lists the files or subdirectories in a directory path . More... | |
void | twFile_SetIsInUse (twFile *file, const char isInUse) |
uses the file->inUseMutex to safely set file->isInUse to the value of the isInUse parameter More... | |
twFile * | twFile_Create () |
allocates memory for the twFile and initializes the twFile->inUseMutex More... | |
void | twFile_Delete (void *f) |
Deletes mutex's, file handles, and Free's memory realted to the twFile struct. More... | |
ThingWorx file transfer structure definitions and functions.
Contains structure type definitions and function prototypes for ThingWorx API file transfer operations.
typedef void(* file_cb) (char fileRcvd, twFileTransferInfo *info, void *userdata) |
Signature of a callback function that is registered to be called when a file transfer completes or fails.
[in] | fileRcvd | #TRUE if the file was received, #FALSE if it was sent. |
[in] | info | A pointer to the twFileTransferInfo associated with the callback. |
[in] | userdata | An opaque pointer that is passed in when the callback is registered. |
twFile* twFile_Create | ( | ) |
void twFile_Delete | ( | void * | f | ) |
void twFile_SetIsInUse | ( | twFile * | file, |
const char | isInUse | ||
) |
uses the file->inUseMutex to safely set file->isInUse to the value of the isInUse parameter
[in] | file | The twFile to be modified |
[in] | path | boolean value to use for file->isInUse |
int twFileManager_AddVirtualDir | ( | const char * | thingName, |
char * | dirName, | ||
char * | path | ||
) |
Adds a virtual directory to the twFileManager singleton.
[in] | thingName | The name of the ::twThing that this virtual directory is associated with. |
[in] | dirName | A name to apply to this virtual directory. |
[in] | path | The absolute path to the underlying directory in the filesystem. |
void twFileManager_CheckStalledTransfers | ( | ) |
Checks for any stalled file transfers and deletes them.
void twFileManager_CloseFile | ( | void * | file | ) |
int twFileManager_Create | ( | ) |
Creates the twFileManager singleton.
int twFileManager_Delete | ( | ) |
Deletes the twFileManager singleton and all its owned substructures.
int twFileManager_GetFile | ( | const char * | sourceRepo, |
const char * | sourcePath, | ||
const char * | sourceFile, | ||
const char * | targetRepo, | ||
const char * | targetPath, | ||
const char * | targetFile, | ||
uint32_t | timeout, | ||
char | asynch, | ||
char ** | tid | ||
) |
Gets a file from the server.
[in] | sourceRepo | The entity name to get the file from. |
[in] | sourcePath | The virtual path of the file to get (not including the file name). |
[in] | sourceFile | The name of the file to get. |
[in] | targetRepo | The target repository of the file. |
[in] | targetPath | The path of the resulting file in the target repository (not including the file name). |
[in] | targetFile | The name of the resulting file in the target directory. |
[in] | timeout | The timeout for the transfer in seconds. Zero will use the system's default timeout. |
[in] | asynch | If #TRUE return immediately and call the callback function when the transfer completes. If #FALSE block until the transfer is complete. |
[out] | tid | A pointer to the transfer ID used for this transfer. |
twFile* twFileManager_GetOpenFile | ( | const char * | thingName, |
const char * | path, | ||
const char * | filename, | ||
const char * | tid, | ||
char * | isTimedOut | ||
) |
Checks to see if the specified file is already open.
[in] | thingName | The name of the ::twThing this file is associated with. |
[in] | path | The full path to the file or directory. May be passed as NULL if tid is specified. |
[in] | filename | The name of the file or directory. |
[in] | tid | The tid of an open transaction. May be passed as NULL if path is specified. |
[out] | isTimedOut | pointer to boolean which will signal if the specified file has timed out, NULL can be passed in if the calling funciton does not care about this value |
char* twFileManager_GetRealPath | ( | const char * | thingName, |
const char * | path, | ||
const char * | filename | ||
) |
Gets the native file system path for a file.
[in] | thingName | The name of the ::twThing this file is associated with. |
[in] | path | The virtual path of the file. |
[in] | filename | The name of the file. Passing NULL will assume file name is already appended to path. |
twList* twFileManager_ListEntities | ( | const char * | entityName, |
const char * | path, | ||
const char * | namemask, | ||
char | returnType | ||
) |
Lists the files or subdirectories in a directory path
.
[in] | entityName | The entity name to use when looking up a virtual directory path. |
[in] | path | The virtual path to the directory to investigate. |
[in] | namemask | A wildcard enabled mask to list only files that match the mask. |
[in] | returnType | #LIST_ALL returns all files and directories, #LIST_FILES returns files only, #LIST_DIRS returns directories only. |
path
. Returns if an error was encountered.twList* twFileManager_ListVirtualDirs | ( | const char * | entityName | ) |
Returns a list of all virtual directories from the twFileManager singleton.
[in] | entityName | A filter on virtual directories registered with a given entity name (NULL returns all virtual directories). |
void twFileManager_MakeFileCallback | ( | char | rcvd, |
twFileTransferInfo * | fti | ||
) |
Forces the file to complete a callback.
[in] | rcvd | TRUE if the file was received, FALSE if it was sent. |
[in] | fti | A pointer to the twFileTransferInfo structure. |
twFile* twFileManager_OpenFile | ( | const char * | thingName, |
const char * | path, | ||
const char * | filename, | ||
char * | mode | ||
) |
Creates a new twFile structure and populates it with information obtained from a file/directory.
[in] | thingName | The name of the ::twThing this file is associated with. |
[in] | path | Virtual path to the file or directory. |
[in] | filename | The name of the file or directory. |
[in] | mode | The mode to open the file in (see Cfopen() documentation). |
int twFileManager_RegisterFileCallback | ( | file_cb | cb, |
char * | filter, | ||
char | onceOnly, | ||
void * | userdata | ||
) |
Registers a function to be called when a file transfer completes.
[in] | cb | The function to be registered. |
[in] | filter | A wildcard-supporting filter to apply to the filename of transfers to be associated with the callback. |
[in] | onceOnly | If #TRUE, this registration will be deleted after it is called once. |
[in] | userdata | An opaque pointer that is passed in when the callback is registered. |
int twFileManager_RemoveVirtualDir | ( | const char * | thingName, |
char * | dirName | ||
) |
Removes a virtual directory from the twFileManager singleton.
[in] | thingName | The name of the ::twThing that this virtual directory is associated with. |
[in] | dirName | The name of the virtual directory to remove ("*" removes all associated with thingName ). |
int twFileManager_SendFile | ( | const char * | sourceRepo, |
const char * | sourcePath, | ||
const char * | sourceFile, | ||
const char * | targetRepo, | ||
const char * | targetPath, | ||
const char * | targetFile, | ||
uint32_t | timeout, | ||
char | asynch, | ||
char ** | tid | ||
) |
Sends | a file to the server. | |
[in] | sourceRepo | The entity name to use when sending the file (and looking up the virtual path). |
[in] | sourcePath | The virtual path of the file to send (not including the file name). |
[in] | sourceFile | The name of the file to send. |
[in] | targetRepo | The target repository of the file. |
[in] | targetPath | The path of the resulting file in the target repository (not including the file name). |
[in] | targetFile | The name of the resulting file in the target directory. |
[in] | timeout | The timeout for the transfer in seconds. Zero will use the system's default timeout. |
[in] | asynch | If #TRUE return immediately and call the callback function when the transfer completes. If #FALSE block until the transfer is complete. |
[out] | tid | A pointer to the transfer ID used for this transfer. |
int twFileManager_UnregisterFileCallback | ( | file_cb | cb, |
char * | filter, | ||
void * | userdata | ||
) |
Unregisters a file callback function registered via twFileManager_RegisterFileCallback().
[in] | cb | The function to be unregistered. |
[in] | filter | A wildcard-supporting filter to apply to the filename of transfers to be unregistered. |
[in] | userdata | An opaque pointer that is passed in when the callback is registered. |
twFileTransferInfo* twFileTransferInfo_Create | ( | twInfoTable * | it | ) |
Creates a new twFileTransferInfo structure.
[in] | it | A twInfoTable containing all file transfer information for the new twFileTransferInfo structure. |
it
pointer. void twFileTransferInfo_Delete | ( | void * | transferInfo | ) |
Frees all memory associated with a twFileTransferInfo structure and all its owned substructures.
[in] | transferInfo | A pointer to the twFileTransferInfo structure to delete. |