DeleteFile Event

Fires when the OS needs to delete a file or directory.

Syntax

// CBFSDeleteFileEventArgs carries the CBFS DeleteFile event's parameters.
type CBFSDeleteFileEventArgs struct {...}

func (args *CBFSDeleteFileEventArgs) FileName() string
func (args *CBFSDeleteFileEventArgs) FileContext() int64
func (args *CBFSDeleteFileEventArgs) SetFileContext(value int64)
func (args *CBFSDeleteFileEventArgs) ResultCode() int32
func (args *CBFSDeleteFileEventArgs) SetResultCode(value int32)

// CBFSDeleteFileEvent defines the signature of the CBFS DeleteFile event's handler function.
type CBFSDeleteFileEvent func(sender *CBFS, args *CBFSDeleteFileEventArgs)

func (obj *CBFS) GetOnDeleteFileHandler() CBFSDeleteFileEvent
func (obj *CBFS) SetOnDeleteFileHandler(handlerFunc CBFSDeleteFileEvent)

Remarks

This event fires when the OS has decided to delete the file or directory specified by FileName.

To handle this event properly, applications must perform any actions needed to delete the specified file or directory from their backend storage. If the UseHardLinks property is enabled, a file's data should only be deleted when its last hard link is deleted; please refer to the Hard Links topic for more information.

Important:

  • A deletion cannot be cancelled from this event; applications that wish to prevent a deletion must do so via the CanFileBeDeleted event.
  • This event fires immediately after the last CloseFile event. If the application disposes of the FileContext in the CloseFile event handler, it will be invalid when this event fires. The CloseFile event includes a DeleteFile parameter that helps address this situation.

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.

Copyright (c) 2022 Callback Technologies, Inc. - All rights reserved.
CBFS Connect 2020 Go Edition - Version 20.0 [Build 8348]