3 BackendUtilities
David Anderson edited this page 2023-08-22 13:15:33 -07:00

Back-end utility functions

The following functions (in sched/validate_util.cpp and sched/sched_util.cpp) can be used in your validator and assimilator code.

struct OUTPUT_FILE_INFO {
    std::string path;
    bool optional;
};

extern int get_output_file_info(RESULT& result, OUTPUT_FILE_INFO&);
extern int get_output_file_infos(RESULT& result, std::vector<OUTPUT_FILE_INFO>&);
extern int get_output_file_path(RESULT& result, std::string&);
extern int get_output_file_paths(RESULT& result, std::vector<std::string>&);

Returns the paths of a result's output file(s). The OUTPUT_FILE_INFO variants also return each file's "optional" attribute.

int try_fopen(char* path, FILE*& f, char* mode);

Open a file, distinguishing between recoverable and nonrecoverable errors. Returns zero on success. Returns ERR_FOPEN if the directory is present but not the file (this is considered a nonrecoverable error). Returns ERR_OPENDIR if the directory is not there (this is generally a recoverable error, like NFS mount failure).

int cancel_jobs(int min_id, int max_id);

Cancel jobs (workunits) with IDs min_id to max_id inclusive.