How can I move file into Recycle Bin / trash on different platforms using PyQt4?

前端 未结 3 1389
渐次进展
渐次进展 2021-02-01 02:36

I would like to add the next feature to my cross-platform PyQt4 application: when user selects some file and select \"remove\" action on it that file will be moved to Recycle Bi

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-01 03:03

    I guess there really is no cross-platform solution provided by Qt and it's not a totally trivial task to implement the trash concept in Linux since it's slightly different based on which file manager is in use.

    Here's a site discussing the trash concept in Nautilus and another one for KDE.

    Under Windows you can use the Win32 API like you said. Python solution available here.

    Mac OS X puts the trashed files in ~/.Trash similar to other *NIX OSes, but I couldn't quickly Google any documentation for it. It seems that the OS X trash info file is some kind of binary format and not plain text like in Linux.

    Symbian doesn't have a desktop concept and thus no trashcan concept either. It might be similar for other mobile platforms.

    EDIT: Super User has some discussion revealing that .DS_Store does indeed store information about trashed files, but no specifics about the format.

提交回复
热议问题