Fires when the OS wants to rename or move a file or directory within the virtual filesystem.
class CBFSRenameOrMoveFileEventParams(object): @property def file_name() -> str: ... @property def new_file_name() -> str: ... @property def file_context() -> int: ... @file_context.setter def file_context(value) -> None: ... @property def result_code() -> int: ... @result_code.setter def result_code(value) -> None: ... # In class CBFS: @property def on_rename_or_move_file() -> Callable[[CBFSRenameOrMoveFileEventParams], None]: ... @on_rename_or_move_file.setter def on_rename_or_move_file(event_hook: Callable[[CBFSRenameOrMoveFileEventParams], None]) -> None: ...
This event fires when the OS wants to rename or move the specified file or directory from FileName to NewFileName, both of which are fully-qualified and located in the virtual filesystem.
This event only fires if a file or directory with the specified NewFileName does not exist; or if such a file does exist, and an overwrite was requested. Cases where a file with the specified NewFileName exists, and an overwrite was not requested, are handled by the class internally. (Note that Windows only allows files to be overwritten, and denies a rename or move request automatically if the destination is an existing directory.)
To handle this event properly, applications must perform any actions needed to rename or move the specified file or directory in their backend storage, overwriting the destination file if necessary. An application may also, for its own reasons, decide not to overwrite a destination file, in which case it must deny the operation by returning an appropriate error code via ResultCode.
When the FastRenameMove configuration setting is disabled, any handles to the file being renamed are closed before the rename operation and re-opened after the operation. If the rename operation fails, then the file handles are re-opened using the old name. If any of re-open operations fail, the re-opening process is stopped, and any handles that have been re-opened already are closed again.
In any case, the value specified by the ResultCode parameter is passed back to the system.
The FileContext parameter is a placeholder for application-defined data associated with the file. Please refer to the Contexts topic for more information.
The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource isn't available, security checks failed, etc.), set it to a non-zero value to report an appropriate error. Please refer to the Error Reporting and Handling topic for more information.