OpenFile Event
This event instructs the application to handle the file open request.
Syntax
ANSI (Cross Platform) virtual int FireOpenFile(SFTPServerOpenFileEventParams *e);
typedef struct {
int64 ConnectionID;
const char *Path;
int Modes;
int Access;
int OperationStatus;
char *Handle; int reserved; } SFTPServerOpenFileEventParams; Unicode (Windows) virtual INT FireOpenFile(SFTPServerOpenFileEventParams *e);
typedef struct {
LONG64 ConnectionID;
LPCWSTR Path;
INT Modes;
INT Access;
INT OperationStatus;
LPWSTR Handle; INT reserved; } SFTPServerOpenFileEventParams;
- (void)onOpenFile:(long long)connectionID :(NSString*)path :(int)modes :(int)access :(int*)operationStatus :(NSString**)handle;
#define EID_SFTPSERVER_OPENFILE 30 virtual INT SECUREBLACKBOX_CALL FireOpenFile(LONG64 &lConnectionID, LPSTR &lpszPath, INT &iModes, INT &iAccess, INT &iOperationStatus, LPSTR &lpszHandle);
Remarks
This event is fired when a file open request is received from the client and needs to be handled (virtualized) by the server. The ConnectionID parameter specifies in which session the request was received, and Path specifies the location of the file.
Modes can be a combination of one or several file open mode flags:
cfmRead | 1 |
cfmWrite | 2 |
cfmAppend | 4 |
cfmCreate | 8 |
cfmTruncate | 16 |
cfmExcl | 32 |
cfmText | 64 |
cfmOpenOrCreate | 128 |
cfmAppendAtomic | 256 |
cfmNoFollow | 512 |
cfmDeleteOnClose | 1024 |
Different client applications may provide different selections of mode flags. For example, some clients specify (cfmCreate + cfmTruncate) when overwriting files, whereas others would specify cfmOpenOrCreate. Please make sure your code is prepared to receive different combinations of flags here and handles them gracefully.
The Access parameter provides additional file access modifiers:
cfaReadLock | 1 |
cfaWriteLock | 2 |
cfaDeleteLock | 4 |
cfaBlockAdvisory | 8 |
The Handle string represents a unique identifier of the opened file, similar to file handles used in Windows or Unix APIs. Handles are unique across all files opened at the same time. Class generates handles automatically, but you can update the auto-generated values with your own in this event handler (just remember to keep them unique).
Set OperationStatus parameter in accordance with the outcome of the operation to one of the values given below:
ostOk | 1 | |
ostNoSuchFile | 2 | |
ostAccessDenied | 3 | |
ostWriteProtect | 4 | |
ostUnsupported | 5 | |
ostInvalidParameter | 6 | |
ostEOF | 7 |