Some functions create output files during their execution; some of them are slow, so the probability that something goes wrong during their execution is not null, with the consequence that output files are incomplete, or that undesired temporary files are left on the filesystem.

This functions is though to manage these situations.

trace_function runs a function and checks if errors occur during its execution; in this case, the files created by it are deleted (only if the timestamp of the files is subsequent to the time of execution of the function). If the code interrupts before the function ends, the paths of the files intended to be created by the function are saved within the package, so that they can be easily deleted in a second time; to do it, simply run clean_traces.

Other intermediate functions are used internally: start_trace saves the paths of the files intended to be created within a text file; end_trace deletes this text file (it is used by trace_function when a function stops without errors); clean_trace deletes this text file and the intended output files (it is used by trace_function when a function stops with errors).

start_trace(trace_files, trace_funname)

end_trace(tracename)

clean_trace(tracename)

trace_function(trace_fun, trace_files, trace_funname = NA, ...)

clean_traces(trace_funname = NA)

Arguments

trace_files

Vector of the files intended to be created by fun (for now, providing it is mandatory). Also temporary files can be indicated here.

trace_funname

The name of the function to be run (in start_trace) or to be cleaned (in clean_traces; if NA, all the traces are cleaned).

tracename

The path of the text file containing the log information generated by start_trace.

trace_fun

The function to be run.

...

Arguments of the function fun

Note

License: GPL 3.0