コード例 #1
0
int main(void)
{
	int x;
	while(TRUE)
	{
	x=menu(x);
	switch(x)
	{
		case 0:
			return 0;
		case 1:
			create_dir();break;
		case 2:
			find_dir();break;
		case 3:
			del_dir();break;
		case 4:
			modify_dir();break;
		case 5:
			insert_dir();break;
		case 6:
			num();break;	
		case 7:
			all();break;	
		default:
			exit(-1);				
	}
	}
	return 0; 
} 
コード例 #2
0
ファイル: test_remove.c プロジェクト: zkf-qwj/rm-dir
void del_dir(char *path)
{
    DIR* dp = NULL;
    DIR* dpin = NULL;
    char *pathname = (char*)malloc(_MAXDIR_);
    struct dirent* dirp;
    dp = opendir(path);
    if(dp == NULL)
    {
        printf("%s\n", "your input directory is not exist!");
        return;
    }
         
    while((dirp = readdir(dp)) != NULL)
    {
        if(strcmp(dirp->d_name, "..") == 0 || strcmp(dirp->d_name, ".") == 0)
            continue;
        strcpy(pathname, path);
        strcat(pathname, "\\");
        strcat(pathname, dirp->d_name);
        dpin = opendir(pathname);
        if(dpin != NULL)
            del_dir(pathname);
        else
            remove(pathname);
        strcpy(pathname, "");
        closedir(dpin);
        dpin = NULL;
    }
    rmdir(path);
    closedir(dp);
    free(pathname);
    pathname = NULL;
    dirp = NULL;
}
コード例 #3
0
ファイル: main.c プロジェクト: stas/-junk
void
*do_search(void *thread_id)
{
    int tid;
    int cur_queue = count_dirlist();
    int position = -1;
    tid = *((int *) thread_id);
    printf("Thread %d started with %d dirs in queue...\n", tid, cur_queue);
    while(cur_queue != 0)
    {
        // Catch a lock
        do {
            position = read_dirlist();
        } while (position < 0 && count_dirlist() != 0);

        if(position < 0)
            break;

        char *path = dirlist[position];
        if(path != NULL)
        {
            build_dirlist(path);
            printf("do_search: Thread %d found a new path: %s\n", tid, path);
            find_in_dir(path);
            del_dir(path);
        }
        if(position >= 0)
            pthread_mutex_unlock(&dirlist_acc[position]); 
        cur_queue = count_dirlist();
    }
    printf("do_search: Directory list is empty. Thread %d terminates.\n", tid);
    return NULL;
}
コード例 #4
0
ファイル: test_remove.c プロジェクト: zkf-qwj/rm-dir
int main()
{
    printf("%s", "Please input directory:");
    scanf("%s", dirname);
    long initTime = currentTimeByMilles();
    del_dir(dirname);
    long currentTime = currentTimeByMilles();
    printf("Use time:%d\n", currentTime-initTime);
    return 0;
}
コード例 #5
0
int main(int argn ,char *argv[])
{	
	char in[100];
	while(1)
	{
		int n = strlen(para[0]);
		printf("%s->", para[0]);
		memset(in, 0, sizeof(in));
		gets(in);
		int choice = explain(in);
		//根据命令解释器的返回结果执行相对应的命令
		switch(choice)
		{
		case -1: printf("' %s '不是内部或外部命令,也不是可运行的程序\n或批处理文件。\n", in);break;
		case 0 : show_time();break; 
		case 1 : show_version();break;
		case 2 : show_date();break;
		case 3 : clrscr(0, 0);break;
		case 4 : show_directory();break;
		case 5 : help();break;
		case 6 : show_current_tree(para[0], 0);break;
		case 7 : return 0;
		case 8 : print_text(para[0]);break;	
		case 9 : if(del_dir(para[0]) == 0)	del_files(para[0]);break;//如果para[0]是文件夹,则执行删除文件夹函数,否则执行文件删除函数
		case 10 : creat_dir(para[0]);break;
		case 11 : rename_file(para[0], para[1]);break;
		case 12 : change_path(in);break;
		}//{"time", "version", "date", "cls", "dir", "help", "tree", "print", "del", "mkdir", "ren"};
		if(choice != 12)//如果没有改变路径,则每次都把当前工作目录下的以外的其它字符清除
		{
			memset(para[0] + n, 0, (100 - n) * sizeof(char));
			memset(para[1] + n, 0, (100 - n) * sizeof(char));
		}
	}
	return 0;
}