STUD *load() { ifstream ifs; STUD *p,*old,*top; count = 0; cout<<"请输入要读取的文件名:(默认文件名为:"<<tempFile<<"):"; cin>>fname; strcpy(tempFile,fname); ifs.open(fname,ios_base::binary); if(!ifs.is_open()) { cout<<"打不开文件,请重新选择"<<endl; return NULL; } cout<<endl<<"读取文件中..."<<endl; ASK(p); old = top = p; while(ifs.peek() != EOF) { ifs.read(reinterpret_cast<char*>(p),LEN); count++; ASK(p->next); old = p; p = p->next; } old->next = NULL; free(p); ifs.close(); cout<<"读取了"<<count<<"条记录"<<endl; if(count==0) { top = NULL; } return top; }//load
void mainWindow::removeClient() { int index = clients->table->currentRow(); if (index==-1) { WARN(FW_NAME, "You didn't select any client, to perform this action!\n\n" "Please go first to the 'Clients' window and select one by clicking on it."); return; } if (ASK("Are you sure you want to delete this client?\n\n" "ID: "+clients->Client[index]->ID+"\n" "Path: "+clients->Client[index]->Path)) { log->mainLogger->append("------ removed Client ( ID: "+clients->Client[index]->ID+" Path: "+clients->Client[index]->Path+" )"); clients->remove(index); } }
void mainWindow::checkExit() { if (ASK("Are you sure you want to exit?")) qApp->quit(); }