void TrashImpl::migrateOldTrash() { kdDebug() << k_funcinfo << endl; const TQString oldTrashDir = TDEGlobalSettings::trashPath(); const TQStrList entries = listDir( oldTrashDir ); bool allOK = true; TQStrListIterator entryIt( entries ); for (; entryIt.current(); ++entryIt) { TQString srcPath = TQFile::decodeName( *entryIt ); if ( srcPath == "." || srcPath == ".." || srcPath == ".directory" ) continue; srcPath.prepend( oldTrashDir ); // make absolute int trashId; TQString fileId; if ( !createInfo( srcPath, trashId, fileId ) ) { kdWarning() << "Trash migration: failed to create info for " << srcPath << endl; allOK = false; } else { bool ok = moveToTrash( srcPath, trashId, fileId ); if ( !ok ) { (void)deleteInfo( trashId, fileId ); kdWarning() << "Trash migration: failed to create info for " << srcPath << endl; allOK = false; } else { kdDebug() << "Trash migration: moved " << srcPath << endl; } } } if ( allOK ) { // We need to remove the old one, otherwise the desktop will have two trashcans... kdDebug() << "Trash migration: all OK, removing old trash directory" << endl; synchronousDel( oldTrashDir, false, true ); } }
Goods *chooseOr(int select,Goods *head) { if (0 != select) { switch (select) { case 1: //输入库存记录 head = createList(); break; case 2: //删除一条记录 deleteInfo(head); break; case 3: //查找修改记录 findAndEdit(head); break; case 4: //浏览所有记录 traverse(head); break; case 5: //添加一条记录 insertInfo(head); break; case 6: //查看每种货物总价 outputTp(head); break; } } else { printf("\n退出系统!\n\n"); } return head; }
void MainWindow::on_pushButton_2_clicked() { //QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF8")); //QMessageBox::warning(this,tr("警告"),data->name,QMessageBox::Yes); // QString tmpstr = ui->lineEdit_2->text(); // char * tmpname = toChar(tmpstr); // Resetbro(tmpname); int tmpid = ui->lineEdit_2->text().toInt(); deleteInfo(tmpid); }
void deleteBTfile(dictionary * info) { deleteInfo(info); }
int main() { int i; int j; int k; int arrLen=50;//이중포인터 안의 총 배열의 길이 int chooseNum = 0;//명령 선택할 변수 char targetName[30];//찾거나 지울때, 이름 받음 int arrCount;//지금 사용하고 있는 배열의 최종 인덱스 PhoneInfo*** phoneInfoArr; char c = '0';//입력버퍼가 빠지지 않아서 생기는 문제를 해결하기 위한 임시변수 FILE *inputConfigInfo, *outputConfigInfo; FILE *inputPhoneInfo, *outputPhoneinfo; char buffer[1000]; char *pointerForBuffer; char *context = NULL;//strtok_s를 쓰기위한 세번째 변수 char *token = NULL;//strtok_s의 토큰 char criteria = '\t'; system("mode con:cols=100 lines=40"); system("title Final Project By WonYoung"); //총 몇 개의 정보가 들어가 있는지에 대한 txt파일을 읽어서 arrCount에 저장 START fopen_s(&inputConfigInfo, "InformationOfPhoneBook.txt", "r"); fscanf_s(inputConfigInfo, "%d", &arrCount); fclose(inputConfigInfo); //총 몇 개의 정보가 들어가 있는지에 대한 txt파일을 읽어서 arrCount에 저장 END //다른 메소드로 넘기기 위한 삼중 포인터 하나를 동적으로 할당 START phoneInfoArr = (PhoneInfo***)malloc(sizeof(PhoneInfo**)); if (phoneInfoArr == NULL) { exit(-1); } //다른 메소드로 넘기기 위한 삼중 포인터 하나를 동적으로 할당 START //배열을 동적으로 할당(arrLen) START phoneInfoArr[0] = (PhoneInfo**)malloc(sizeof(PhoneInfo*) * arrLen); if (phoneInfoArr == NULL) { exit(-1); } //배열을 동적으로 할당(arrLen) END //개수(arrLen)만큼 돌면서 PhoneInfo가 들어갈 자리를 동적으로 할당 시작 for (i = 0; i < arrLen; i++) { phoneInfoArr[0][i] = (PhoneInfo*)malloc(sizeof(PhoneInfo)); memset(phoneInfoArr[0][i], 0, sizeof(PhoneInfo)); if (phoneInfoArr[0][i] == NULL) { for (j = 0; j < i; j++) { free(phoneInfoArr[0][j]); } free(phoneInfoArr[0]); exit(-1); } phoneInfoArr[0][i]->numberInfoArr = (NumberInfo**)malloc(sizeof(NumberInfo*));//numberInfo들이 들어갈 NumberInfoArr 박스를 만듦 if (phoneInfoArr[0][i]->numberInfoArr == NULL) { free(phoneInfoArr[0][i]->numberInfoArr); exit(-1); } //전화번호 들어갈 자리 하나 씩은 만들어주기 START phoneInfoArr[0][i]->countNumInfo = 1; phoneInfoArr[0][i]->numberInfoArr[0] = (NumberInfo*)malloc(sizeof(NumberInfo)); memset(phoneInfoArr[0][i]->numberInfoArr[0], 0, sizeof(NumberInfo)); //전화번호 들어갈 자리 하나 씩은 만들어주기 END } //개수(arrLen)만큼 돌면서 PhoneInfo가 들어갈 자리를 동적으로 할당 종료 //파일을 읽어서 정보를 입력 START fopen_s(&inputPhoneInfo, "PhoneBook.txt", "r"); i = 0; while (i<arrCount) { fgets(buffer, 1000, inputPhoneInfo); buffer[strlen(buffer) - 1] = '\0'; //tab 단위로 떼어내서 각 요소에 넣을 것 START strcpy(phoneInfoArr[0][i]->name, strtok_s(buffer, &criteria, &context));//첫 번째 자름. 이름 strcpy(phoneInfoArr[0][i]->address, strtok_s(context, &criteria, &context));//두 번째 자름. 주소 strcpy(phoneInfoArr[0][i]->birthday, strtok_s(context, &criteria, &context));//세 번째 자름. 생일 strcpy(phoneInfoArr[0][i]->memo, strtok_s(context, &criteria, &context));//네 번째 자름. 메모 phoneInfoArr[0][i]->countNumInfo = atoi(strtok_s(context, &criteria, &context));//다섯 번째 자름. 전화번호 몇 개? //tab 단위로 떼어내서 각 요소에 넣을 것 END //NumberInfoArr안의 NumberInfo를 countNumInfo만큼 말록 시작 for (j = 0; j < phoneInfoArr[0][i]->countNumInfo; j++) { phoneInfoArr[0][i]->numberInfoArr[j] = (NumberInfo*)malloc(sizeof(NumberInfo)); memset(phoneInfoArr[0][i]->numberInfoArr[j], 0, sizeof(NumberInfo)); } //NumberInfoArr안의 NumberInfo를 countNumInfo만큼 말록 종료 //countNumInfo 만큼 돌면서 kindOfnumber와 phoneNumber를 넣음 START for (j = 0; j < phoneInfoArr[0][i]->countNumInfo; j++) { strcpy(phoneInfoArr[0][i]->numberInfoArr[j]->kindOfNumber, strtok_s(context, &criteria, &context));//전화번호 이름 strcpy(phoneInfoArr[0][i]->numberInfoArr[j]->phoneNumber, strtok_s(context, &criteria, &context));//전화번호 } //countNumInfo 만큼 돌면서 kindOfnumber와 phoneNumber를 넣음 END i++; } fclose(inputPhoneInfo); //파일을 읽어서 정보를 입력 END //do-while 시작 do { viewPrintCommendNumber();//번호를 입력받는 텍스트를 출력하는 함수 while (scanf_s("%d", &chooseNum) != 1) { c = getchar(); system("cls");//이걸로 기존 문제 해결!!(반복 출력) printf("\n숫자가 아닙니다. 다시 입력해주세요.\n\n"); viewPrintCommendNumber(); } if (chooseNum == 1) { //PhoneInfoArr이 가득차면, 더 늘리는 코드 시작 if (arrCount == arrLen) { arrLen += 3; phoneInfoArr[0] = (PhoneInfo**)realloc(phoneInfoArr, sizeof(PhoneInfo*)*arrLen);//추가적으로 길이를 3늘려서 동적으로 재할당 if (phoneInfoArr == NULL) { exit(-1); } //개수만큼 돌면서 추가된 자리에 PhoneInfo가 들어갈 자리를 동적으로 다시 할당 시작 for (i = arrCount; i <= arrLen; i++) { phoneInfoArr[0][i] = (PhoneInfo*)malloc(sizeof(PhoneInfo)); memset(phoneInfoArr[0][i], 0, sizeof(PhoneInfo)); if (phoneInfoArr[0][i] == NULL) { for (j = 0; j < i; j++) { free(phoneInfoArr[0][j]); } free(phoneInfoArr[0]); exit(-1); } } //개수만큼 돌면서 추가된 자리에 PhoneInfo가 들어갈 자리를 동적으로 다시 할당 종료 } //PhoneInfoArr이 가득차면, 더 늘리는 코드 종료 insertInfo(arrCount, phoneInfoArr); viewPrintSuccessInsert(phoneInfoArr[0], arrCount);//insert가 성공했을때 출력 arrCount++; } else if (chooseNum == 2) { arrCount = deleteInfo(phoneInfoArr[0], arrLen, arrCount); } else if (chooseNum == 3) { searchInfo(phoneInfoArr[0], arrCount); viewPrintNextDoingText();//searching을 마치고 다음 행동하라는 부분을 프린트하는 함수 } else if (chooseNum == 4) { printAll(phoneInfoArr[0], arrCount); } else if (chooseNum == 5) { } else { system("cls"); printf("\n\n잘못된 번호를 입력하셨습니다. 다시 입력해주세요.\n\n"); } } while (chooseNum != 5); //do-while 종료 //총 몇 개의 전화부 정보가 저장되어 있는지를 저장 START fopen_s(&outputConfigInfo, "InformationOfPhoneBook.txt", "wt"); fprintf_s(outputConfigInfo, "%d", arrCount); fclose(outputConfigInfo); //총 몇 개의 전화부 정보가 저장되어 있는지를 저장 END //주소록 정보를 파일에 갱신해서 다시 담아줌 START fopen_s(&outputPhoneinfo, "PhoneBook.txt", "wt"); i = 0; while (i < arrCount) { fputs(phoneInfoArr[0][i]->name, outputConfigInfo); fprintf_s(outputPhoneinfo, "\t"); fputs(phoneInfoArr[0][i]->address, outputConfigInfo); fprintf_s(outputPhoneinfo, "\t"); fputs(phoneInfoArr[0][i]->birthday, outputConfigInfo); fprintf_s(outputPhoneinfo, "\t"); fputs(phoneInfoArr[0][i]->memo, outputConfigInfo); fprintf_s(outputPhoneinfo, "\t"); fprintf_s(outputConfigInfo, "%d", phoneInfoArr[0][i]->countNumInfo); for (j = 0; j < phoneInfoArr[0][i]->countNumInfo; j++) { fprintf_s(outputPhoneinfo, "\t"); fputs(phoneInfoArr[0][i]->numberInfoArr[j]->kindOfNumber, outputConfigInfo); fprintf_s(outputPhoneinfo, "\t"); fputs(phoneInfoArr[0][i]->numberInfoArr[j]->phoneNumber, outputConfigInfo); } fprintf_s(outputPhoneinfo, "\n"); i++; } fclose(outputPhoneinfo); //주소록 정보를 파일에 갱신해서 다시 담아줌 END //끝나서 모두 free 시작 for (i = 0; i < arrLen; i++) { for (j = 0; j < phoneInfoArr[0][i]->countNumInfo; j++) { free(phoneInfoArr[0][i]->numberInfoArr[j]); } free(phoneInfoArr[0][i]); } free(phoneInfoArr[0]); free(phoneInfoArr); //끝나서 모두 free 종료 return 0; }//Main 함수 종료