route_to_file Method
Instructs the class to route future requests directly to a given file.
Syntax
def route_to_file(file_info: int, file_name: str, flags: int) -> bool: ...
Remarks
This method can be called from within the on_create_file or on_open_file event to instruct the class to route any future requests against the file specified by FileInfo directly to the file at the path specified by FileName instead of firing the corresponding events. The Flags parameter is used to specify which kinds of requests should not be routed automatically (see below).
Pass the value obtained from the on_create_file or on_open_file event's FileInfo parameter for this method's FileInfo parameter.
This method returns either True or False to indicate whether routing was set up successfully. If, after this method is called successfully, the application later wishes for routing to cease, it may do one of the following:
- Call the notify_directory_change method, passing CBFS_NOTIFY_FLAG_METADATA_MODIFIED for its Action parameter, and the same FileName value as received in the original on_create_file or on_open_file event.
- Disable the metadata cache entirely using the metadata_cache_enabled property.
The Flags value should be created by OR'ing together zero or more of the following flags:
CBFS_ROUTE_FILE_READ_ONLY | 0x00000001 | Causes files to be treated as read-only; all write operations will be automatically denied. |
CBFS_ROUTE_OPEN_EVENT | 0x00000020 | Prevents 'open' requests from being routed automatically.
If set, the on_open_file event will fire as usual when such requests arrive. Note: This flag is implied if any of the other CBFS_ROUTE_*_EVENT flags are present. |
CBFS_ROUTE_CLEANUP_EVENT | 0x00000040 | Prevents 'cleanup' requests from being routed automatically.
If set, the on_cleanup_file event will fire as usual when such requests arrive. |
CBFS_ROUTE_CLOSE_EVENT | 0x00000080 | Prevents 'close' requests from being routed automatically.
If set, the on_close_file event will fire as usual when such requests arrive. Note: This flag is implied if any of the other CBFS_ROUTE_*_EVENT flags are present. |
CBFS_ROUTE_ENUMERATE_DIRECTORY_EVENT | 0x00000200 | Prevents 'enumerate directory' requests from being routed automatically.
If set, the on_enumerate_directory event will fire as usual when such requests arrive. |
CBFS_ROUTE_SET_SECURITY_EVENT | 0x00000400 | Prevents 'set security' requests from being routed automatically.
If set, the on_set_file_security event will fire as usual when such requests arrive. |
CBFS_ROUTE_GET_SECURITY_EVENT | 0x00000800 | Prevents 'get security' requests from being routed automatically.
If set, the on_get_file_security event will fire as usual when such requests arrive. |
CBFS_ROUTE_SET_FILE_ATTRIBUTES_EVENT | 0x00002000 | Prevents 'set file attributes' requests from being routed automatically.
If set, the on_set_file_attributes event will fire as usual when such requests arrive. |
CBFS_ROUTE_SET_FILE_SIZES_EVENT | 0x00004000 | Prevents 'set file size' requests from being routed automatically.
If set, the on_set_file_size event will fire as usual when such requests arrive. |
CBFS_ROUTE_SET_VALID_DATA_LENGTH_EVENT | 0x00008000 | Prevents 'set valid data length' requests from being routed automatically.
If set, the on_open_file event will fire as usual when such requests arrive. |
CBFS_ROUTE_CREATE_HARD_LINK_EVENT | 0x00020000 | Prevents 'create hard link' requests from being routed automatically.
If set, the on_create_hard_link event will fire as usual when such requests arrive. |
CBFS_ROUTE_QUERY_QUOTA_EVENT | 0x00040000 | Prevents 'query quota' requests from being routed automatically.
If set, the on_query_quotas event will fire as usual when such requests arrive. |
CBFS_ROUTE_SET_QUOTA_EVENT | 0x00080000 | Prevents 'set quota' requests from being routed automatically.
If set, the on_set_quotas event will fire as usual when such requests arrive. |
CBFS_ROUTE_CAN_FILE_BE_DELETED_EVENT | 0x00200000 | Prevents 'can file be deleted' requests from being routed automatically.
If set, the on_can_file_be_deleted event will fire as usual when such requests arrive. |
CBFS_ROUTE_IS_DIRECTORY_EMPTY_EVENT | 0x00400000 | Prevents 'is directory empty' requests from being routed automatically.
If set, the on_is_directory_empty event will fire as usual when such requests arrive. |
CBFS_ROUTE_RENAME_EVENT | 0x00800000 | Prevents 'rename/move' requests from being routed automatically.
If set, the on_rename_or_move_file event will fire as usual when such requests arrive. |
Note: This method can only be called within the on_create_file and on_open_file event handlers.