// find string in file
// Created by Numa@Sj 2000.2.21
// Modified by Numa@Sj 2000.7

#include <ansi.h>
inherit F_CLEAN_UP;

int main(object me,string str)
{
        mixed *dir_info;
        string arg, file;
        int i, j = 0;
        
        if (!str)
                return notify_fail("硌鍔跡宒ㄩfstring <趼睫揹>\n"); 
        if (me->query("cwd") == 0 || me->query("cwd") == "/" )
                return notify_fail("涴爵拸楊脤梑﹝\n"); 
        dir_info = get_dir(me->query("cwd"),-1);
        arg = CYN"羲宎婓"RED+me->query("cwd")+CYN"醴翹狟脤梑漪衄趼睫揹\""GRN+str+CYN"\"腔恅璃ㄩ\n";
        arg += HIW"岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸\n"NOR;
        for (i=0;i<sizeof(dir_info);i++)
        {
                if (dir_info[i][1] == -2)
                        continue;
                if (file_size(me->query("cwd")+dir_info[i][0]) <= 0)
                        continue;
                file = read_file(me->query("cwd")+dir_info[i][0]);
                if (strsrch(file,str)>=0) {
                        arg += me->query("cwd")+dir_info[i][0] +"\n";
                        j += 1;
                }
        }
        arg += HIW"岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸岸 SJ 岸岸\n"NOR;
        if (j == 0)
                arg += RED"帤梑善睫磁刲坰沭璃腔恅璃﹝\n"NOR;
        else
                arg += CYN"僕梑善"RED+j+CYN"跺睫磁刲坰沭璃腔恅璃﹝\n"NOR;
        me->start_more(arg);
        return 1;
}

int help(object me)
{
        write(@HELP
硌鍔跡宒: fstring <趼睫揹>

涴跺硌鍔褫眕蚚懂脤梑掛醴翹狟闡虳恅璃婦漪議趼睫揹﹝

HELP
        );
        return 1;
}

