How to use the send2trash.compat.binary_type function in Send2Trash

To help you get started, we’ve selected a few Send2Trash examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hsoft / send2trash / send2trash / plat_osx.py View on Github external
def send2trash(path):
    if not isinstance(path, binary_type):
        path = path.encode('utf-8')
    fp = FSRef()
    opts = kFSPathMakeRefDoNotFollowLeafSymlink
    op_result = FSPathMakeRefWithOptions(path, opts, byref(fp), None)
    check_op_result(op_result)
    opts = kFSFileOperationDefaultOptions
    op_result = FSMoveObjectToTrashSync(byref(fp), None, opts)
    check_op_result(op_result)