fn find(args : SplitWhitespace){
    let mut tmp_args = args.clone();
    let mut real_args = args.clone();
    if tmp_args.next() == None{
        println!("invalid command format");
        return;
    }
    else{
        real_args.next();
    }
    if tmp_args.next() == None{
        println!("invalid command format");
        return;
    }
    else{
        real_args.next();
    }

    if tmp_args.next() == None{
        println!("invalid command format");
        return;
    }
    let pattern = real_args.next().unwrap();
    
    let mut filestrs = Vec::new();

    let path = env::current_dir().unwrap();
    let path = path.to_str().unwrap();

    let dirs =  fs::read_dir(path).unwrap();
    for dir in dirs{
        if let Ok(dir) = dir{
            let filename = dir.file_name().into_string().unwrap();

            if pattern.contains("*."){
                let len = pattern.len();
                let new_pattern = &pattern[2 .. len];

                if filename.contains(new_pattern){
                    filestrs.push(filename);
                }

            }else{
                if filename == pattern{
                    filestrs.push(filename);
                }

            } 
        }
    }

    for file_name in filestrs{
        let mut full_path = String::from(path);
        full_path.push_str("/");
        full_path.push_str(&file_name);
        println!("{}",full_path);

    }
}
/***********************************************************
 * Function: find
 * Description: To Search in the current directory and its descendents.
 * ***********************************************************/
find
Description: To Search in the current directory and its descendents.
find Description : To Search in the current directory and its descendents .
fn find(args : SplitWhitespace){
    let mut tmp_args = args.clone();
    let mut real_args = args.clone();
    if tmp_args.next() == None{
        println!("invalid command format");
        return;
    }
    else{
        real_args.next();
    }
    if tmp_args.next() == None{
        println!("invalid command format");
        return;
    }
    else{
        real_args.next();
    }
    if tmp_args.next() == None{
        println!("invalid command format");
        return;
    }
    let pattern = real_args.next().unwrap();
    let mut filestrs = Vec::new();
    let path = env::current_dir().unwrap();
    let path = path.to_str().unwrap();
    let dirs =  fs::read_dir(path).unwrap();
    for dir in dirs{
        if let Ok(dir) = dir{
            let filename = dir.file_name().into_string().unwrap();
            if pattern.contains("*."){
                let len = pattern.len();
                let new_pattern = &pattern[2 .. len];
                if filename.contains(new_pattern){
                    filestrs.push(filename);
                }
            }else{
                if filename == pattern{
                    filestrs.push(filename);
                }
            } 
        }
    }
    for file_name in filestrs{
        let mut full_path = String::from(path);
        full_path.push_str("/");
        full_path.push_str(&file_name);
        println!("{}",full_path);
    }
}
fn find ( args : SplitWhitespace ) { let mut tmp_args = args . clone ( ) ; let mut real_args = args . clone ( ) ; if tmp_args . next ( ) == None { println ! ( " " ) ; return ; } else { real_args . next ( ) ; } if tmp_args . next ( ) == None { println ! ( " " ) ; return ; } else { real_args . next ( ) ; } if tmp_args . next ( ) == None { println ! ( " " ) ; return ; } let pattern = real_args . next ( ) . unwrap ( ) ; let mut filestrs = Vec :: new ( ) ; let path = env :: current_dir ( ) . unwrap ( ) ; let path = path . to_str ( ) . unwrap ( ) ; let dirs = fs :: read_dir ( path ) . unwrap ( ) ; for dir in dirs { if let Ok ( dir ) = dir { let filename = dir . file_name ( ) . into_string ( ) . unwrap ( ) ; if pattern . contains ( " " ) { let len = pattern . len ( ) ; let new_pattern = & pattern [ 2 .. len ] ; if filename . contains ( new_pattern ) { filestrs . push ( filename ) ; } } else { if filename == pattern { filestrs . push ( filename ) ; } } } } for file_name in filestrs { let mut full_path = String :: from ( path ) ; full_path . push_str ( " " ) ; full_path . push_str ( & file_name ) ; println ! ( " " full_path ) ; } }
Function: find
 Description: To Search in the current directory and its descendents.
Function : find Description : To Search in the current directory and its descendents .
args
SplitWhitespace