Пример #1
0
/// Set up a file reference, given a slot dir and project dir.
/// This means:
/// -# copy the file to slot dir, if reference is by copy
/// -# else make a soft link
static int setup_file(
    const PROJECT* project, const FILE_INFO* fip, const FILE_REF& fref,
    const std::string& file_path, const std::string& slot_dir, bool input
) {
    int retval;

    std::string link_path = slot_dir + std::string("/");
    if (strlen(fref.open_name)) {
        link_path += std::string(fref.open_name);
    } else {
        link_path += std::string(fip->name);
    }
    std::string rel_file_path = std::string("../../") + file_path;

    // if anonymous platform, this is called even if not first time,
    // so link may already be there
    //
    if (input && project->anonymous_platform && boinc_file_exists(link_path.c_str())) {
        return 0;
    }

    if (fref.copy_file) {
        if (input) {
            retval = boinc_copy(file_path.c_str(), link_path.c_str());
            if (retval) {
                msg_printf(project, MSG_INTERNAL_ERROR,
                    "Can't copy %s to %s: %s", file_path.c_str(), link_path.c_str(),
                    boincerror(retval)
                );
                return retval;
            }
        }
        return 0;
    }

#ifdef _WIN32
    retval = make_soft_link(project, link_path.c_str(), rel_file_path.c_str());
    if (retval) return retval;
#else
    if (project->use_symlinks) {
        retval = symlink(rel_file_path.c_str(), link_path.c_str());
    } else {
        retval = make_soft_link(project, link_path.c_str(), rel_file_path.c_str());
    }
    if (retval) return retval;
#endif
#ifdef SANDBOX
    return set_to_project_group(link_path.c_str());
#endif
    return 0;
}
Пример #2
0
// write symlinks for project files.
// Note: it's conceivable that one physical file
// has several logical names, so try them all
//
int PROJECT::write_symlink_for_project_file(FILE_INFO* fip) {
    char link_path[MAXPATHLEN], file_path[MAXPATHLEN];
    unsigned int i;

    for (i=0; i<project_files.size(); i++) {
        FILE_REF& fref = project_files[i];
        if (fref.file_info != fip) continue;
        snprintf(link_path, sizeof(link_path), "%s/%s", project_dir(), fref.open_name);
        snprintf(file_path, sizeof(file_path), "%s/%s", project_dir(), fip->name);
        make_soft_link(this, link_path, file_path);
    }
    return 0;
}