mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.62k stars 2.92k forks source link

mp.utils.remove_file for JS API #13305

Open Kagami opened 10 months ago

Kagami commented 10 months ago

There are: https://github.com/mpv-player/mpv/blob/22e21edbd40ed0f937ab3bb52d0aa18db7ef18f8/player/javascript/defaults.js#L708-L709 https://github.com/mpv-player/mpv/blob/22e21edbd40ed0f937ab3bb52d0aa18db7ef18f8/player/javascript.c#L1211-L1212

but no mp.utils.remove_file which is also very useful.

Right now my workaround:

function remove_file(path: string) {
  if (mp.get_property("platform") === "windows") {
    mp.command_native({
      name: "subprocess",
      args: ["del", path],
      playback_only: false,
    });
  } else {
    mp.command_native({
      name: "subprocess",
      args: ["rm", path],
      playback_only: false,
    });
  }
}
Kagami commented 10 months ago

Also would be nice to have mkdir, rmdir, etc.