CBFS Connect 2020 Python Edition

Questions / Feedback?

on_cleanup_file Event

Fires when the OS needs to clean up a file.

Syntax

class CBFSCleanupFileEventParams(object):
  @property
  def file_name() -> str: ...
  @property
  def handle_info() -> int: ...
  @property
  def file_context() -> int: ...
  @property
  def handle_context() -> int: ...
  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFS:
@property
def on_cleanup_file() -> Callable[[CBFSCleanupFileEventParams], None]: ...
@on_cleanup_file.setter
def on_cleanup_file(event_hook: Callable[[CBFSCleanupFileEventParams], None]) -> None: ...

Remarks

This event fires when the OS needs to close a handle to the currently-open file specified by FileName. This event differs from on_close_file in that on_cleanup_file fires immediately when an open handle to the specified file is closed by a process, whereas on_close_file may be fired much later when the OS itself decides that the file can be formally closed. (However, similar to on_close_file, this event will only fire for the last handle to a file if the fire_all_open_close_events property is disabled.)

Other events may fire for the file handle in the time between when this event fires and when the on_close_file event fires. For example, system components such as the memory manager or cache manager may cause the on_read_file and on_write_file events to fire.

This event is optional; it is provided to give applications a chance to, e.g., free up resources associated with a file before it's formally closed.

The HandleInfo parameter carries a handle to an object with information about the file handle. While within the event handler, it can be used to call any of the following methods: get_handle_creator_process_id, get_handle_creator_process_name, get_handle_creator_thread_id, or get_handle_creator_token.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. 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.

 
 
Copyright (c) 2021 Callback Technologies, Inc. - All rights reserved.
CBFS Connect 2020 Python Edition - Version 20.0 [Build 7880]