Each of these functions returns the location of one program as a string:
find_ffmpeg(), find_ffprobe(), find_ffplay() and find_mediainfo().
Details
The function looks on the PATH first. If the program is not there, the
function reads the location that set_program() saved. That location is in
a file under tools::R_user_dir("tidymedia", "config"). If neither place has
the program, the function gives a warning and returns NULL.
Problems with a saved location
A saved location that no longer works gives a warning, and the function
returns NULL. The warning has one of three classes that you can catch:
tidymedia_location_gone: the function read the location, but no program is there now. The condition holds the program name intm_programand the location intm_location, as the file holds it.tidymedia_location_not_executable: a file is at the saved location, and it cannot be run. Give it permission to execute, or use theset_*()function to point at another copy. The condition holds the program name intm_programand the location intm_location, as the file holds it. This case does not arise on Windows, which has no execute bit. There a location is read the way R's ownSys.which()reads it, except that a folder never counts and a leading~is expanded.tidymedia_location_unreadable: the file does not hold exactly one location. It is empty, has more than one line, or has one empty line. Or the package cannot read the file, because it has no read permission. Or a folder is where that file belongs, and no file for the program is in either place. The condition holds the program name intm_programand the path intm_file. For folders, that is the first folder the function looked in.
A line that holds only spaces counts as a location. So it gives
tidymedia_location_gone, not tidymedia_location_unreadable.
To fix a location that is gone or cannot be run, or a file that does not
hold one location, forget the location with unset_program(), or replace it
with set_program(). A file that cannot be run can also be fixed by giving
it permission to execute. A file the package cannot read can be fixed by
giving it read permission, or removed with unset_program().
unset_program() removes an empty folder where the file belongs, in either
folder, and set_program() removes one in the current folder. A folder
counts as empty only when it holds nothing, not even a hidden file or an
empty folder. A folder the package cannot read never counts as empty. Both
functions leave a folder that is not empty. set_program() gives a
tidymedia_location_folder error for one in the current folder.
unset_program() removes the
location files and empty folders at the two paths, and gives a
tidymedia_location_folder_kept warning for the folder it leaves. If it
keeps such a folder and the removal at the other path fails, it gives a
tidymedia_location_not_removed error in place of the warning, and the
error message names the kept folder. If each
path that holds something holds a folder that is not empty,
unset_program() gives the tidymedia_location_folder error and removes
nothing. The warning from the find_*() functions says which case you
have: it advises
unset_program() when every folder it found is empty, and otherwise it
names each folder to delete by hand.
Locations saved by earlier versions
Versions of the package before 0.2.0 saved locations in a different folder,
rappdirs::user_config_dir("tidymedia", "R"). The functions still read a
file in that folder. They read it only when the current folder has no file
for the program. A folder in the place of the current file does not count
as a file, so the old file is still read. program_status() looks in the
same places, in the same order.
A tidymedia_location_unreadable warning names the file that the function
read. That file can be the one in the old folder.
set_program() writes to the current folder only. After it writes a file
for a program, the old file for that program is not read.
unset_program() removes the file in both folders. So the old location does
not come back after the current file is gone.
See also
set_program() to save the location of a program that is not on
the PATH, and install_on_win() to download FFmpeg on Windows.
Other program management functions:
install_on_win(),
program_status(),
set_program(),
unset_program()