本文整理汇总了C++中FILE_INFO类的典型用法代码示例。如果您正苦于以下问题:C++ FILE_INFO类的具体用法?C++ FILE_INFO怎么用?C++ FILE_INFO使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FILE_INFO类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clear_errors
void APP_VERSION::clear_errors() {
int x;
unsigned int i;
for (i=0; i<app_files.size();i++) {
FILE_INFO* fip = app_files[i].file_info;
if (fip->had_failure(x)) {
fip->reset();
}
}
}
示例2: write_file_transfers_gui
int CLIENT_STATE::write_file_transfers_gui(MIOFILE& f) {
unsigned int i;
f.printf("<file_transfers>\n");
for (i=0; i<file_infos.size(); i++) {
FILE_INFO* fip = file_infos[i];
if (fip->pers_file_xfer) {
fip->write_gui(f);
}
}
f.printf("</file_transfers>\n");
return 0;
}
示例3: get_file_errors
void APP_VERSION::get_file_errors(string& str) {
int errnum;
unsigned int i;
FILE_INFO* fip;
string msg;
str = "couldn't get input files:\n";
for (i=0; i<app_files.size();i++) {
fip = app_files[i].file_info;
if (fip->had_failure(errnum)) {
fip->failure_message(msg);
str = str + msg;
}
}
}
示例4: input_files_available
// Returns zero iff all the input files for a result are present
// (both WU and app version)
// Called from CLIENT_STATE::update_results (with verify=false)
// to transition result from DOWNLOADING to DOWNLOADED.
// Called from ACTIVE_TASK::start() (with verify=true)
// when project has verify_files_on_app_start set.
//
// If fipp is nonzero, return a pointer to offending FILE_INFO on error
//
int CLIENT_STATE::input_files_available(
RESULT* rp, bool verify_contents, FILE_INFO** fipp
) {
WORKUNIT* wup = rp->wup;
FILE_INFO* fip;
unsigned int i;
APP_VERSION* avp;
FILE_REF fr;
PROJECT* project = rp->project;
int retval;
avp = rp->avp;
for (i=0; i<avp->app_files.size(); i++) {
fr = avp->app_files[i];
fip = fr.file_info;
if (fip->status != FILE_PRESENT) {
if (fipp) *fipp = fip;
return ERR_FILE_MISSING;
}
// don't verify app files if using anonymous platform
//
if (verify_contents && !project->anonymous_platform) {
retval = fip->verify_file(true, true, false);
if (retval) {
if (fipp) *fipp = fip;
return retval;
}
}
}
for (i=0; i<wup->input_files.size(); i++) {
fip = wup->input_files[i].file_info;
if (fip->status != FILE_PRESENT) {
if (wup->input_files[i].optional) continue;
if (fipp) *fipp = fip;
return ERR_FILE_MISSING;
}
if (verify_contents) {
retval = fip->verify_file(true, true, false);
if (retval) {
if (fipp) *fipp = fip;
return retval;
}
}
}
return 0;
}
示例5: is_upload_done
// Returns true if the result's output files are all either
// successfully uploaded or have unrecoverable errors
//
bool RESULT::is_upload_done() {
unsigned int i;
FILE_INFO* fip;
int retval;
for (i=0; i<output_files.size(); i++) {
fip = output_files[i].file_info;
if (fip->uploadable()) {
if (fip->had_failure(retval)) continue;
if (!fip->uploaded) {
return false;
}
}
}
return true;
}
示例6: get_output_file_infos
int get_output_file_infos(RESULT& result, vector<FILE_INFO>& fis) {
char path[1024];
MIOFILE mf;
string name;
mf.init_buf_read(result.xml_doc_in);
XML_PARSER xp(&mf);
fis.clear();
while (!xp.get_tag()) {
if (!xp.is_tag) continue;
if (xp.match_tag("file_ref")) {
FILE_INFO fi;
int retval = fi.parse(xp);
if (retval) return retval;
dir_hier_path(
fi.name.c_str(), config.upload_dir, config.uldl_dir_fanout, path
);
fi.path = path;
fis.push_back(fi);
}
}
return 0;
}
示例7: check_file_existence
// for each FILE_INFO (i.e. each project file the client knows about)
// check that the file exists and is of the right size.
// Called at startup.
//
void CLIENT_STATE::check_file_existence() {
unsigned int i;
char path[MAXPATHLEN];
for (i=0; i<file_infos.size(); i++) {
FILE_INFO* fip = file_infos[i];
if (fip->status < 0 && fip->downloadable()) {
// file had an error; reset it so that we download again
get_pathname(fip, path, sizeof(path));
msg_printf(fip->project, MSG_INFO,
"Resetting file %s: %s", path, boincerror(fip->status)
);
fip->reset();
continue;
}
if (cc_config.dont_check_file_sizes) continue;
if (fip->status == FILE_PRESENT) {
get_pathname(fip, path, sizeof(path));
double size;
int retval = file_size(path, size);
if (retval) {
delete_project_owned_file(path, true);
fip->status = FILE_NOT_PRESENT;
msg_printf(fip->project, MSG_INFO, "File %s not found", path);
} else if (fip->nbytes && (size != fip->nbytes)) {
if (gstate.global_prefs.dont_verify_images && is_image_file(path)) continue;
delete_project_owned_file(path, true);
fip->status = FILE_NOT_PRESENT;
msg_printf(fip->project, MSG_INFO,
"File %s has wrong size: expected %.0f, got %.0f",
path, fip->nbytes, size
);
}
}
}
}
示例8: get_output_file_info
int get_output_file_info(RESULT& result, FILE_INFO& fi) {
char path[1024];
string name;
MIOFILE mf;
mf.init_buf_read(result.xml_doc_in);
XML_PARSER xp(&mf);
while (!xp.get_tag()) {
if (!xp.is_tag) continue;
if (xp.match_tag("file_ref")) {
int retval = fi.parse(xp);
if (retval) return retval;
dir_hier_path(
fi.name.c_str(), config.upload_dir, config.uldl_dir_fanout, path
);
fi.path = path;
return 0;
}
}
return ERR_XML_PARSE;
}
示例9: xp
// parse a project's app_info.xml (anonymous platform) file
//
int CLIENT_STATE::parse_app_info(PROJECT* p, FILE* in) {
char buf[256], path[MAXPATHLEN];
MIOFILE mf;
mf.init_file(in);
XML_PARSER xp(&mf);
while (!xp.get_tag()) {
if (xp.match_tag("app_info")) continue;
if (xp.match_tag("/app_info")) {
notices.remove_notices(p, REMOVE_APP_INFO_MSG);
return 0;
}
if (xp.match_tag("file_info") || xp.match_tag("file")) {
FILE_INFO* fip = new FILE_INFO;
if (fip->parse(xp)) {
delete fip;
continue;
}
if (!fip->download_urls.empty() || !fip->upload_urls.empty()) {
msg_printf(p, MSG_INFO,
"Can't specify URLs in app_info.xml"
);
delete fip;
continue;
}
if (link_file_info(p, fip)) {
delete fip;
continue;
}
// check that the file is actually there
//
get_pathname(fip, path, sizeof(path));
if (!boinc_file_exists(path)) {
safe_strcpy(buf,
_("File referenced in app_info.xml does not exist: ")
);
strcat(buf, fip->name);
msg_printf(p, MSG_USER_ALERT, "%s", buf);
delete fip;
continue;
}
fip->status = FILE_PRESENT;
fip->anonymous_platform_file = true;
file_infos.push_back(fip);
continue;
}
if (xp.match_tag("app")) {
APP* app = new APP;
if (app->parse(xp)) {
delete app;
continue;
}
if (lookup_app(p, app->name)) {
delete app;
continue;
}
link_app(p, app);
apps.push_back(app);
continue;
}
if (xp.match_tag("app_version")) {
APP_VERSION* avp = new APP_VERSION;
if (avp->parse(xp)) {
delete avp;
continue;
}
if (cc_config.dont_use_vbox && strstr(avp->plan_class, "vbox")) {
msg_printf(p, MSG_INFO,
"skipping vbox app in app_info.xml; vbox disabled in cc_config.xml"
);
delete avp;
continue;
}
if (strlen(avp->platform) == 0) {
safe_strcpy(avp->platform, get_primary_platform());
}
if (link_app_version(p, avp)) {
delete avp;
continue;
}
app_versions.push_back(avp);
continue;
}
if (log_flags.unparsed_xml) {
msg_printf(p, MSG_INFO,
"Unparsed line in app_info.xml: %s",
xp.parsed_tag
);
}
}
return ERR_XML_PARSE;
}
示例10: strcpy
//.........这里部分代码省略.........
handle_time_stats_log(fin);
have_time_stats_log = true;
continue;
}
if (match_tag(buf, "<net_stats>")) {
host.parse_net_stats(fin);
continue;
}
if (match_tag(buf, "<disk_usage>")) {
host.parse_disk_usage(fin);
continue;
}
if (match_tag(buf, "<result>")) {
result.parse_from_client(fin);
static int max_results = 200;
--max_results;
if (max_results >= 0)
results.push_back(result);
continue;
}
if (match_tag(buf, "<code_sign_key>")) {
copy_element_contents(fin, "</code_sign_key>", code_sign_key, sizeof(code_sign_key));
continue;
}
if (match_tag(buf, "<msg_from_host>")) {
MSG_FROM_HOST_DESC md;
retval = md.parse(fin);
if (!retval) {
msgs_from_host.push_back(md);
}
continue;
}
if (match_tag(buf, "<file_info>")) {
FILE_INFO fi;
retval = fi.parse(fin);
if (!retval) {
file_infos.push_back(fi);
}
continue;
}
if (match_tag(buf, "<host_venue>")) {
continue;
}
if (match_tag(buf, "<other_results>")) {
have_other_results_list = true;
while (fgets(buf, sizeof(buf), fin)) {
if (match_tag(buf, "</other_results>")) break;
if (match_tag(buf, "<other_result>")) {
OTHER_RESULT o_r;
retval = o_r.parse(fin);
if (!retval) {
other_results.push_back(o_r);
}
}
}
continue;
}
if (match_tag(buf, "<in_progress_results>")) {
have_ip_results_list = true;
int i = 0;
double now = time(0);
while (fgets(buf, sizeof(buf), fin)) {
if (match_tag(buf, "</in_progress_results>")) break;
if (match_tag(buf, "<ip_result>")) {
IP_RESULT ir;
retval = ir.parse(fin);
示例11: fprintf
int CLIENT_STATE::write_state(MIOFILE& f) {
unsigned int i, j;
int retval;
#ifdef SIM
fprintf(stderr, "simulator shouldn't write state file\n");
exit(1);
#endif
f.printf("<client_state>\n");
retval = host_info.write(f, true, true);
if (retval) return retval;
retval = time_stats.write(f, false);
if (retval) return retval;
retval = net_stats.write(f);
if (retval) return retval;
for (j=0; j<projects.size(); j++) {
PROJECT* p = projects[j];
retval = p->write_state(f);
if (retval) return retval;
for (i=0; i<apps.size(); i++) {
if (apps[i]->project == p) {
retval = apps[i]->write(f);
if (retval) return retval;
}
}
for (i=0; i<file_infos.size(); i++) {
if (file_infos[i]->project != p) continue;
FILE_INFO* fip = file_infos[i];
// don't write file infos for anonymous platform app files
//
if (fip->anonymous_platform_file) continue;
retval = fip->write(f, false);
if (retval) return retval;
}
for (i=0; i<app_versions.size(); i++) {
if (app_versions[i]->project == p) {
app_versions[i]->write(f);
}
}
for (i=0; i<workunits.size(); i++) {
if (workunits[i]->project == p) workunits[i]->write(f);
}
for (i=0; i<results.size(); i++) {
if (results[i]->project == p) results[i]->write(f, false);
}
p->write_project_files(f);
#ifdef ENABLE_AUTO_UPDATE
if (auto_update.present && auto_update.project==p) {
auto_update.write(f);
}
#endif
}
active_tasks.write(f);
f.printf(
"<platform_name>%s</platform_name>\n"
"<core_client_major_version>%d</core_client_major_version>\n"
"<core_client_minor_version>%d</core_client_minor_version>\n"
"<core_client_release>%d</core_client_release>\n"
"<user_run_request>%d</user_run_request>\n"
"<user_run_prev_request>%d</user_run_prev_request>\n"
"<user_gpu_request>%d</user_gpu_request>\n"
"<user_gpu_prev_request>%d</user_gpu_prev_request>\n"
"<user_network_request>%d</user_network_request>\n"
"<new_version_check_time>%f</new_version_check_time>\n"
"<all_projects_list_check_time>%f</all_projects_list_check_time>\n",
get_primary_platform(),
core_client_version.major,
core_client_version.minor,
core_client_version.release,
cpu_run_mode.get_perm(),
cpu_run_mode.get_prev(),
gpu_run_mode.get_perm(),
gpu_run_mode.get_prev(),
network_run_mode.get_perm(),
new_version_check_time,
all_projects_list_check_time
);
if (strlen(language)) {
f.printf("<language>%s</language>\n", language);
}
if (newer_version.size()) {
f.printf("<newer_version>%s</newer_version>\n", newer_version.c_str());
}
for (i=1; i<platforms.size(); i++) {
f.printf("<alt_platform>%s</alt_platform>\n", platforms[i].name.c_str());
}
if (gui_proxy_info.present) {
gui_proxy_info.write(f);
}
if (strlen(main_host_venue)) {
f.printf("<host_venue>%s</host_venue>\n", main_host_venue);
}
f.printf("</client_state>\n");
return 0;
}
示例12: fopen
int CLIENT_STATE::parse_state_file_aux(const char* fname) {
PROJECT *project=NULL;
int retval=0;
string stemp;
FILE* f = fopen(fname, "r");
if (!f) return ERR_FOPEN;
MIOFILE mf;
XML_PARSER xp(&mf);
mf.init_file(f);
while (!xp.get_tag()) {
if (xp.match_tag("/client_state")) {
break;
}
if (xp.match_tag("client_state")) {
continue;
}
if (xp.match_tag("project")) {
PROJECT temp_project;
retval = temp_project.parse_state(xp);
if (retval) {
msg_printf(NULL, MSG_INTERNAL_ERROR, "Can't parse project in state file");
} else {
#ifdef SIM
project = new PROJECT;
*project = temp_project;
projects.push_back(project);
#else
project = lookup_project(temp_project.master_url);
if (project) {
project->copy_state_fields(temp_project);
} else {
msg_printf(&temp_project, MSG_INTERNAL_ERROR,
"Project %s is in state file but no account file found",
temp_project.get_project_name()
);
}
#endif
}
continue;
}
if (xp.match_tag("app")) {
APP* app = new APP;
retval = app->parse(xp);
if (!project) {
msg_printf(NULL, MSG_INTERNAL_ERROR,
"Application %s outside project in state file",
app->name
);
delete app;
continue;
}
if (project->anonymous_platform) {
delete app;
continue;
}
if (retval) {
msg_printf(NULL, MSG_INTERNAL_ERROR,
"Can't parse application in state file"
);
delete app;
continue;
}
retval = link_app(project, app);
if (retval) {
msg_printf(project, MSG_INTERNAL_ERROR,
"Can't handle application %s in state file",
app->name
);
delete app;
continue;
}
apps.push_back(app);
continue;
}
if (xp.match_tag("file_info") || xp.match_tag("file")) {
FILE_INFO* fip = new FILE_INFO;
retval = fip->parse(xp);
if (!project) {
msg_printf(NULL, MSG_INTERNAL_ERROR,
"File info outside project in state file"
);
delete fip;
continue;
}
if (retval) {
msg_printf(NULL, MSG_INTERNAL_ERROR,
"Can't handle file info in state file"
);
delete fip;
continue;
}
retval = link_file_info(project, fip);
if (project->anonymous_platform && retval == ERR_NOT_UNIQUE) {
delete fip;
continue;
}
if (retval) {
msg_printf(project, MSG_INTERNAL_ERROR,
"Can't handle file info %s in state file",
//.........这里部分代码省略.........
示例13: create_and_delete_pers_file_xfers
// scan FILE_INFOs and create PERS_FILE_XFERs as needed.
// NOTE: this doesn't start the file transfers
// scan PERS_FILE_XFERs and delete finished ones.
//
bool CLIENT_STATE::create_and_delete_pers_file_xfers() {
unsigned int i;
FILE_INFO* fip;
PERS_FILE_XFER *pfx;
bool action = false;
int retval;
static double last_time;
if (!clock_change && now - last_time < PERS_FILE_XFER_START_PERIOD) return false;
last_time = now;
// Look for FILE_INFOs for which we should start a transfer,
// and make PERS_FILE_XFERs for them
//
for (i=0; i<file_infos.size(); i++) {
fip = file_infos[i];
pfx = fip->pers_file_xfer;
if (pfx) continue;
if (fip->downloadable() && fip->status == FILE_NOT_PRESENT) {
pfx = new PERS_FILE_XFER;
pfx->init(fip, false);
fip->pers_file_xfer = pfx;
pers_file_xfers->insert(fip->pers_file_xfer);
action = true;
} else if (fip->uploadable() && fip->status == FILE_PRESENT && !fip->uploaded) {
pfx = new PERS_FILE_XFER;
pfx->init(fip, true);
fip->pers_file_xfer = pfx;
pers_file_xfers->insert(fip->pers_file_xfer);
action = true;
}
}
// Scan existing PERS_FILE_XFERs, looking for those that are done,
// and deleting them
//
vector<PERS_FILE_XFER*>::iterator iter;
iter = pers_file_xfers->pers_file_xfers.begin();
while (iter != pers_file_xfers->pers_file_xfers.end()) {
pfx = *iter;
// If the transfer finished, remove the PERS_FILE_XFER object
// from the set and delete it
//
if (pfx->pers_xfer_done) {
fip = pfx->fip;
if (pfx->is_upload) {
// file has been uploaded - delete if not sticky
//
if (!fip->sticky) {
fip->delete_file();
}
fip->uploaded = true;
active_tasks.upload_notify_app(fip);
} else if (fip->status >= 0) {
// file transfer did not fail (non-negative status)
// If this was a compressed download, rename .gzt to .gz
//
if (fip->download_gzipped) {
char path[MAXPATHLEN], from_path[MAXPATHLEN], to_path[MAXPATHLEN];
get_pathname(fip, path, sizeof(path));
snprintf(from_path, sizeof(from_path), "%s.gzt", path);
snprintf(to_path, sizeof(to_path), "%s.gz", path);
boinc_rename(from_path, to_path);
}
// verify the file with RSA or MD5, and change permissions
//
retval = fip->verify_file(true, true, true);
if (retval == ERR_IN_PROGRESS) {
// do nothing
} else if (retval) {
msg_printf(fip->project, MSG_INTERNAL_ERROR,
"Checksum or signature error for %s", fip->name
);
fip->status = retval;
} else {
// Set the appropriate permissions depending on whether
// it's an executable or normal file
//
retval = fip->set_permissions();
fip->status = FILE_PRESENT;
}
// if it's a user file, tell running apps to reread prefs
//
if (fip->is_user_file) {
active_tasks.request_reread_prefs(fip->project);
}
// if it's a project file, make a link in project dir
//
if (fip->is_project_file) {
PROJECT* p = fip->project;
//.........这里部分代码省略.........
示例14: strcpy
//.........这里部分代码省略.........
if (results.size() >= 1024) {
continue;
}
#endif
// check if client is sending the same result twice.
// Shouldn't happen, but if it does bad things will happen
//
bool found = false;
for (unsigned int i=0; i<results.size(); i++) {
if (!strcmp(results[i].name, result.name)) {
found = true;
break;
}
}
if (!found) {
results.push_back(result);
}
continue;
}
if (xp.match_tag("code_sign_key")) {
copy_element_contents(xp.f->f, "</code_sign_key>", code_sign_key, sizeof(code_sign_key));
strip_whitespace(code_sign_key);
continue;
}
if (xp.match_tag("msg_from_host")) {
MSG_FROM_HOST_DESC md;
retval = md.parse(xp);
if (!retval) {
msgs_from_host.push_back(md);
}
continue;
}
if (xp.match_tag("file_info")) {
FILE_INFO fi;
retval = fi.parse(xp);
if (!retval) {
file_infos.push_back(fi);
}
continue;
}
if (xp.match_tag("host_venue")) {
continue;
}
if (xp.match_tag("other_results")) {
have_other_results_list = true;
while (!xp.get_tag()) {
if (xp.match_tag("/other_results")) break;
if (xp.match_tag("other_result")) {
OTHER_RESULT o_r;
retval = o_r.parse(xp);
if (!retval) {
other_results.push_back(o_r);
}
}
}
continue;
}
if (xp.match_tag("in_progress_results")) {
have_ip_results_list = true;
int i = 0;
double now = time(0);
while (!xp.get_tag()) {
if (xp.match_tag("/in_progress_results")) break;
if (xp.match_tag("ip_result")) {
IP_RESULT ir;
retval = ir.parse(xp);
示例15: write
int RESULT::write(MIOFILE& out, bool to_server) {
unsigned int i;
FILE_INFO* fip;
int n, retval;
out.printf(
"<result>\n"
" <name>%s</name>\n"
" <final_cpu_time>%f</final_cpu_time>\n"
" <final_elapsed_time>%f</final_elapsed_time>\n"
" <exit_status>%d</exit_status>\n"
" <state>%d</state>\n"
" <platform>%s</platform>\n"
" <version_num>%d</version_num>\n",
name,
final_cpu_time,
final_elapsed_time,
exit_status,
state(),
platform,
version_num
);
if (strlen(plan_class)) {
out.printf(" <plan_class>%s</plan_class>\n", plan_class);
}
if (fpops_per_cpu_sec) {
out.printf(" <fpops_per_cpu_sec>%f</fpops_per_cpu_sec>\n", fpops_per_cpu_sec);
}
if (fpops_cumulative) {
out.printf(" <fpops_cumulative>%f</fpops_cumulative>\n", fpops_cumulative);
}
if (intops_per_cpu_sec) {
out.printf(" <intops_per_cpu_sec>%f</intops_per_cpu_sec>\n", intops_per_cpu_sec);
}
if (intops_cumulative) {
out.printf(" <intops_cumulative>%f</intops_cumulative>\n", intops_cumulative);
}
if (final_peak_working_set_size) {
out.printf(
" <final_peak_working_set_size>%.0f</final_peak_working_set_size>\n",
final_peak_working_set_size
);
}
if (final_peak_swap_size) {
out.printf(
" <final_peak_swap_size>%.0f</final_peak_swap_size>\n",
final_peak_swap_size
);
}
if (final_peak_disk_usage) {
out.printf(
" <final_peak_disk_usage>%.0f</final_peak_disk_usage>\n",
final_peak_disk_usage
);
}
if (final_bytes_sent) {
out.printf(
" <final_bytes_sent>%.0f</final_bytes_sent>\n",
final_bytes_sent
);
}
if (final_bytes_received) {
out.printf(
" <final_bytes_received>%.0f</final_bytes_received>\n",
final_bytes_received
);
}
if (to_server) {
out.printf(
" <app_version_num>%d</app_version_num>\n",
wup->version_num
);
}
n = (int)stderr_out.length();
if (n || to_server) {
out.printf("<stderr_out>\n");
// the following is here so that it gets recorded on server
// (there's no core_client_version field of result table)
//
if (to_server) {
out.printf(
"<core_client_version>%d.%d.%d</core_client_version>\n",
gstate.core_client_version.major,
gstate.core_client_version.minor,
gstate.core_client_version.release
);
}
if (n) {
out.printf("<![CDATA[\n");
out.printf("%s",stderr_out.c_str());
if (stderr_out[n-1] != '\n') {
out.printf("\n");
}
out.printf("]]>\n");
}
out.printf("</stderr_out>\n");
}
if (to_server) {
for (i=0; i<output_files.size(); i++) {
//.........这里部分代码省略.........