289 lines
30 KiB
Plaintext
289 lines
30 KiB
Plaintext
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<meta charset="UTF-8">
|
||
|
<meta name="generator" content="TempleOS V5.03">
|
||
|
<meta name="viewport" content="width=device-width">
|
||
|
<link rel="stylesheet" href="/style/templeos.css">
|
||
|
<script src="/script/templeos.js"></script>
|
||
|
<style type="text/css">
|
||
|
.cF0{color:#000000;background-color:#ffffff;}
|
||
|
.cF1{color:#0000aa;background-color:#ffffff;}
|
||
|
.cF2{color:#00aa00;background-color:#ffffff;}
|
||
|
.cF3{color:#00aaaa;background-color:#ffffff;}
|
||
|
.cF4{color:#aa0000;background-color:#ffffff;}
|
||
|
.cF5{color:#aa00aa;background-color:#ffffff;}
|
||
|
.cF6{color:#aa5500;background-color:#ffffff;}
|
||
|
.cF7{color:#aaaaaa;background-color:#ffffff;}
|
||
|
.cF8{color:#555555;background-color:#ffffff;}
|
||
|
.cF9{color:#5555ff;background-color:#ffffff;}
|
||
|
.cFA{color:#55ff55;background-color:#ffffff;}
|
||
|
.cFB{color:#55ffff;background-color:#ffffff;}
|
||
|
.cFC{color:#ff5555;background-color:#ffffff;}
|
||
|
.cFD{color:#ff55ff;background-color:#ffffff;}
|
||
|
.cFE{color:#ffff55;background-color:#ffffff;}
|
||
|
.cFF{color:#ffffff;background-color:#ffffff;}
|
||
|
</style>
|
||
|
</head>
|
||
|
<body>
|
||
|
<pre id="content">
|
||
|
<a name="l1"></a><span class=cF0>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>"Cmd Line (Typically)"</span><span class=cF0>
|
||
|
<a name="l2"></a>
|
||
|
<a name="l3"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>FND_REPLACE</span><span class=cF0> 0
|
||
|
<a name="l4"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>FND_SKIP</span><span class=cF0> 1
|
||
|
<a name="l5"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>FND_ALL</span><span class=cF0> 2
|
||
|
<a name="l6"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>FND_ED</span><span class=cF0> 3
|
||
|
<a name="l7"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>FND_ABORT_FILE</span><span class=cF0> 4
|
||
|
<a name="l8"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>FND_SKIP_FILE</span><span class=cF0> 5
|
||
|
<a name="l9"></a>
|
||
|
<a name="l10"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>PopUpFindMenu</span><span class=cF0>()
|
||
|
<a name="l11"></a>{
|
||
|
<a name="l12"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
||
|
<a name="l13"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc=</span><span class=cF5>DocNew</span><span class=cF0>;
|
||
|
<a name="l14"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc,</span><span class=cF6>"$CM+LX,2,4$$BT,\"REPLACE\",LE=FND_REPLACE$"</span><span class=cF0>
|
||
|
<a name="l15"></a> </span><span class=cF6>"$CM+LX,22,0$$BT,\"SKIP\",LE=FND_SKIP$"</span><span class=cF0>
|
||
|
<a name="l16"></a> </span><span class=cF6>"$CM+LX,2,4$$BT,\"ALL\",LE=FND_ALL$"</span><span class=cF0>
|
||
|
<a name="l17"></a> </span><span class=cF6>"$CM+LX,22,0$$BT,\"ABORT ALL\",LE=DOCM_CANCEL$"</span><span class=cF0>
|
||
|
<a name="l18"></a> </span><span class=cF6>"$CM+LX,2,4$$BT,\"EDIT\",LE=FND_ED$"</span><span class=cF0>
|
||
|
<a name="l19"></a> </span><span class=cF6>"$CM+LX,22,0$$BT,\"ABORT FILE\",LE=FND_ABORT_FILE$"</span><span class=cF0>
|
||
|
<a name="l20"></a> </span><span class=cF6>"$CM+LX,2,4$$BT,\"SKIP FILE\",LE=FND_SKIP_FILE$\n"</span><span class=cF0>);
|
||
|
<a name="l21"></a> i=</span><span class=cF5>PopUpMenu</span><span class=cF0>(doc);
|
||
|
<a name="l22"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc);
|
||
|
<a name="l23"></a> </span><span class=cF1>return</span><span class=cF0> i;
|
||
|
<a name="l24"></a>}
|
||
|
<a name="l25"></a>
|
||
|
<a name="l26"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>FindFile</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *needle_str,</span><span class=cF1>U8</span><span class=cF0> *haystack_filename,
|
||
|
<a name="l27"></a> </span><span class=cF9>I64</span><span class=cF0> *_fuf_flags,</span><span class=cF1>U8</span><span class=cF0> *replace_text)
|
||
|
<a name="l28"></a>{</span><span class=cF2>//Have you confused with </span><a href="/Wb/Kernel/BlkDev/DskFind.HC.HTML#l54"><span class=cF4>FileFind</span></a><span class=cF2>()?</span><span class=cF0>
|
||
|
<a name="l29"></a> </span><span class=cF1>Bool</span><span class=cF0> first_on_line,write_this_file=</span><span class=cF3>FALSE</span><span class=cF0>,cont=!</span><span class=cF5>Bt</span><span class=cF0>(_fuf_flags,</span><span class=cF3>FUf_CANCEL</span><span class=cF0>);
|
||
|
<a name="l30"></a> </span><span class=cF1>U8</span><span class=cF0> *src,*dst,*dst2,*name_buf=</span><span class=cF3>NULL</span><span class=cF0>;
|
||
|
<a name="l31"></a> </span><span class=cF9>I64</span><span class=cF0> i,j,plen,rlen,dlen,cnt=0,old_flags,ss_flags;
|
||
|
<a name="l32"></a> </span><span class=cF9>CDoc</span><span class=cF0> *cur_l,*doc=</span><span class=cF5>DocRead</span><span class=cF0>(haystack_filename,
|
||
|
<a name="l33"></a> </span><span class=cF3>DOCF_PLAIN_TEXT_TABS</span><span class=cF0>|</span><span class=cF3>DOCF_NO_CURSOR</span><span class=cF0>);
|
||
|
<a name="l34"></a> </span><span class=cF9>CDocEntry</span><span class=cF0> *doc_e;
|
||
|
<a name="l35"></a>
|
||
|
<a name="l36"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>_fuf_flags,</span><span class=cF3>FUf_IGNORE</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l37"></a> ss_flags=</span><span class=cF3>SFF_IGNORE_CASE</span><span class=cF0>;
|
||
|
<a name="l38"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l39"></a> ss_flags=0;
|
||
|
<a name="l40"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>_fuf_flags,</span><span class=cF3>FUf_WHOLE_LABELS</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l41"></a> ss_flags|=</span><span class=cF3>SFG_WHOLE_LABELS</span><span class=cF0>;
|
||
|
<a name="l42"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>_fuf_flags,</span><span class=cF3>FUf_WHOLE_LABELS_BEFORE</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l43"></a> ss_flags|=</span><span class=cF3>SFF_WHOLE_LABELS_BEFORE</span><span class=cF0>;
|
||
|
<a name="l44"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>_fuf_flags,</span><span class=cF3>FUf_WHOLE_LABELS_AFTER</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l45"></a> ss_flags|=</span><span class=cF3>SFF_WHOLE_LABELS_AFTER</span><span class=cF0>;
|
||
|
<a name="l46"></a>
|
||
|
<a name="l47"></a> plen=</span><span class=cF5>StrLen</span><span class=cF0>(needle_str);
|
||
|
<a name="l48"></a> </span><span class=cF1>if</span><span class=cF0> (replace_text)
|
||
|
<a name="l49"></a> rlen=</span><span class=cF5>StrLen</span><span class=cF0>(replace_text);
|
||
|
<a name="l50"></a> doc_e=doc->head.next;
|
||
|
<a name="l51"></a> </span><span class=cF1>while</span><span class=cF0> (doc_e!=doc && cont) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l52"></a> </span><span class=cF1>if</span><span class=cF0> (doc_e->type_u8==</span><span class=cF3>DOCT_TEXT</span><span class=cF0>) {
|
||
|
<a name="l53"></a> src=doc_e->tag;
|
||
|
<a name="l54"></a> first_on_line=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l55"></a> </span><span class=cF1>while</span><span class=cF0> (src && cont) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l56"></a> </span><span class=cF1>if</span><span class=cF0> (src=</span><span class=cF5>StrFind</span><span class=cF7>(</span><span class=cF0>needle_str,src,ss_flags</span><span class=cF7>)</span><span class=cF0>) {
|
||
|
<a name="l57"></a> cnt++;
|
||
|
<a name="l58"></a> </span><span class=cF1>if</span><span class=cF0> (first_on_line || </span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>_fuf_flags,</span><span class=cF3>FUf_REPLACE</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l59"></a> first_on_line=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l60"></a> </span><span class=cF5>PutFileLink</span><span class=cF0>(haystack_filename,,doc_e->y+1,</span><span class=cF3>TRUE</span><span class=cF0>);
|
||
|
<a name="l61"></a> name_buf=</span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>"%s,%d"</span><span class=cF0>,haystack_filename,doc_e->y+1);
|
||
|
<a name="l62"></a> </span><span class=cF1>if</span><span class=cF0> (cur_l=</span><span class=cF5>DocPut</span><span class=cF0>) {
|
||
|
<a name="l63"></a> old_flags=cur_l->flags&</span><span class=cF3>DOCF_PLAIN_TEXT</span><span class=cF0>;
|
||
|
<a name="l64"></a> cur_l->flags|=</span><span class=cF3>DOCF_PLAIN_TEXT</span><span class=cF0>;
|
||
|
<a name="l65"></a> }
|
||
|
<a name="l66"></a> </span><span class=cF6>" %s\n"</span><span class=cF0>,doc_e->tag;
|
||
|
<a name="l67"></a> </span><span class=cF1>if</span><span class=cF0> (cur_l)
|
||
|
<a name="l68"></a> cur_l->flags= cur_l->flags&~</span><span class=cF3>DOCF_PLAIN_TEXT</span><span class=cF0> |old_flags;
|
||
|
<a name="l69"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l70"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>_fuf_flags,</span><span class=cF3>FUf_REPLACE</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l71"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>_fuf_flags,</span><span class=cF3>FUf_ALL</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l72"></a> i=</span><span class=cF3>FND_ALL</span><span class=cF0>;
|
||
|
<a name="l73"></a> </span><span class=cF1>else</span><span class=cF0> {
|
||
|
<a name="l74"></a> i=</span><span class=cF5>PopUpFindMenu</span><span class=cF0>;
|
||
|
<a name="l75"></a> </span><span class=cF1>if</span><span class=cF0> (i<0) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l76"></a> </span><span class=cF5>LBts</span><span class=cF0>(_fuf_flags,</span><span class=cF3>FUf_CANCEL</span><span class=cF0>);
|
||
|
<a name="l77"></a> cont=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l78"></a> write_this_file=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l79"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (i==</span><span class=cF3>FND_ALL</span><span class=cF0>)
|
||
|
<a name="l80"></a> </span><span class=cF5>LBts</span><span class=cF0>(_fuf_flags,</span><span class=cF3>FUf_ALL</span><span class=cF0>);
|
||
|
<a name="l81"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (i==</span><span class=cF3>FND_ABORT_FILE</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l82"></a> cont=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l83"></a> write_this_file=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l84"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (i==</span><span class=cF3>FND_SKIP_FILE</span><span class=cF0>)
|
||
|
<a name="l85"></a> cont=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l86"></a> }
|
||
|
<a name="l87"></a> </span><span class=cF1>if</span><span class=cF0> (i==</span><span class=cF3>FND_REPLACE</span><span class=cF0> || i==</span><span class=cF3>FND_ALL</span><span class=cF0>) {
|
||
|
<a name="l88"></a> dlen=</span><span class=cF5>StrLen</span><span class=cF0>(doc_e->tag);
|
||
|
<a name="l89"></a> dst=</span><span class=cF5>MAlloc</span><span class=cF0>(dlen+1+rlen-plen);
|
||
|
<a name="l90"></a> dst2=dst;
|
||
|
<a name="l91"></a> j=src-doc_e->tag;
|
||
|
<a name="l92"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<j;i++)
|
||
|
<a name="l93"></a> *dst++=doc_e->tag[i];
|
||
|
<a name="l94"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<rlen;i++)
|
||
|
<a name="l95"></a> *dst++=replace_text[i];
|
||
|
<a name="l96"></a> src=dst;
|
||
|
<a name="l97"></a> </span><span class=cF1>for</span><span class=cF0> (i=j+plen;i<=dlen;i++)
|
||
|
<a name="l98"></a> *dst++=doc_e->tag[i];
|
||
|
<a name="l99"></a> </span><span class=cF5>Free</span><span class=cF0>(doc_e->tag);
|
||
|
<a name="l100"></a> doc_e->tag=dst2;
|
||
|
<a name="l101"></a> </span><span class=cF1>if</span><span class=cF0> (cur_l=</span><span class=cF5>DocPut</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l102"></a> old_flags=cur_l->flags&</span><span class=cF3>DOCF_PLAIN_TEXT</span><span class=cF0>;
|
||
|
<a name="l103"></a> cur_l->flags|=</span><span class=cF3>DOCF_PLAIN_TEXT</span><span class=cF0>;
|
||
|
<a name="l104"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l105"></a> </span><span class=cF6>"%12s,%04d*%s\n"</span><span class=cF0>,haystack_filename,doc_e->y+1,dst2;
|
||
|
<a name="l106"></a> </span><span class=cF1>if</span><span class=cF0> (cur_l)
|
||
|
<a name="l107"></a> cur_l->flags= cur_l->flags&~</span><span class=cF3>DOCF_PLAIN_TEXT</span><span class=cF0> |old_flags;
|
||
|
<a name="l108"></a> write_this_file=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l109"></a> } </span><span class=cF1>else</span><span class=cF0> {
|
||
|
<a name="l110"></a> src++;
|
||
|
<a name="l111"></a> </span><span class=cF1>if</span><span class=cF0> (i==</span><span class=cF3>FND_ED</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l112"></a> </span><span class=cF5>Free</span><span class=cF0>(name_buf);
|
||
|
<a name="l113"></a> name_buf=</span><span class=cF5>StrNew</span><span class=cF0>(doc->filename.name);
|
||
|
<a name="l114"></a> doc->flags&=~</span><span class=cF3>DOCF_NO_CURSOR</span><span class=cF0>;
|
||
|
<a name="l115"></a> doc->cur_entry=doc_e;
|
||
|
<a name="l116"></a> doc->cur_col=doc_e->min_col;
|
||
|
<a name="l117"></a> </span><span class=cF5>DocWrite</span><span class=cF0>(doc);
|
||
|
<a name="l118"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc);
|
||
|
<a name="l119"></a> </span><span class=cF6>"Wrote:%s\n"</span><span class=cF0>,name_buf;
|
||
|
<a name="l120"></a> </span><span class=cF5>Ed</span><span class=cF0>(name_buf);
|
||
|
<a name="l121"></a> doc=</span><span class=cF5>DocRead</span><span class=cF0>(name_buf, </span><span class=cF3>DOCF_PLAIN_TEXT_TABS</span><span class=cF0>);
|
||
|
<a name="l122"></a> doc_e=doc->cur_entry;
|
||
|
<a name="l123"></a> </span><span class=cF1>if</span><span class=cF0> (doc_e->last!=doc) doc_e=doc_e->last;
|
||
|
<a name="l124"></a> src=</span><span class=cF3>NULL</span><span class=cF0>;
|
||
|
<a name="l125"></a> write_this_file=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l126"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l127"></a> }
|
||
|
<a name="l128"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l129"></a> src++;
|
||
|
<a name="l130"></a> </span><span class=cF5>Free</span><span class=cF0>(name_buf);
|
||
|
<a name="l131"></a> name_buf=</span><span class=cF3>NULL</span><span class=cF0>;
|
||
|
<a name="l132"></a> }
|
||
|
<a name="l133"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l134"></a> }
|
||
|
<a name="l135"></a> doc_e=doc_e->next;
|
||
|
<a name="l136"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l137"></a> </span><span class=cF1>if</span><span class=cF0> (write_this_file) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l138"></a> </span><span class=cF5>DocWrite</span><span class=cF0>(doc);
|
||
|
<a name="l139"></a> </span><span class=cF6>"Wrote:%s\n"</span><span class=cF0>,doc->filename.name;
|
||
|
<a name="l140"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l141"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc);
|
||
|
<a name="l142"></a> </span><span class=cF1>return</span><span class=cF0> cnt;
|
||
|
<a name="l143"></a>}
|
||
|
<a name="l144"></a>
|
||
|
<a name="l145"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>Find</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *needle_str,</span><span class=cF1>U8</span><span class=cF0> *files_find_mask=</span><span class=cF6>"*"</span><span class=cF0>,
|
||
|
<a name="l146"></a> </span><span class=cF1>U8</span><span class=cF0> *fu_flags=</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF1>U8</span><span class=cF0> *replace_text=</span><span class=cF3>NULL</span><span class=cF0>)
|
||
|
<a name="l147"></a>{</span><span class=cF2>/*Find occurrences of a string in files.</span><span class=cF0>
|
||
|
<a name="l148"></a></span><span class=cF2>This does not do regular expressions.</span><span class=cF0>
|
||
|
<a name="l149"></a></span><span class=cF2>Anyway, it's good for searching and replacing.</span><span class=cF0>
|
||
|
<a name="l150"></a></span><span class=cF2>Let's say it stands for global replace ;-)</span><span class=cF0>
|
||
|
<a name="l151"></a>
|
||
|
<a name="l152"></a></span><span class=cF2>"+r" =recurse</span><span class=cF0>
|
||
|
<a name="l153"></a></span><span class=cF2>"+i" =ignore case</span><span class=cF0>
|
||
|
<a name="l154"></a></span><span class=cF2>"+l" =whole labels only.</span><span class=cF0>
|
||
|
<a name="l155"></a></span><span class=cF2>This will check for a nonlabel character before</span><span class=cF0>
|
||
|
<a name="l156"></a></span><span class=cF2>and after. If you have a var, "dd" and don't</span><span class=cF0>
|
||
|
<a name="l157"></a></span><span class=cF2>want to match words like "Add", you</span><span class=cF0>
|
||
|
<a name="l158"></a></span><span class=cF2>set this flag and it will see that the characters</span><span class=cF0>
|
||
|
<a name="l159"></a></span><span class=cF2>before or after "dd" are label characters.</span><span class=cF0>
|
||
|
<a name="l160"></a></span><span class=cF2>"+lb"=only checks for label chars before.</span><span class=cF0>
|
||
|
<a name="l161"></a></span><span class=cF2>"+la"=only checks for label chars after.</span><span class=cF0>
|
||
|
<a name="l162"></a></span><span class=cF2>*/</span><span class=cF0>
|
||
|
<a name="l163"></a> </span><span class=cF9>I64</span><span class=cF0> cnt=0,fuf_flags=0;
|
||
|
<a name="l164"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> *tmpde,*tmpde1;
|
||
|
<a name="l165"></a> </span><span class=cF5>ScanFlags</span><span class=cF0>(&fuf_flags,</span><span class=cF5>Define</span><span class=cF7>(</span><span class=cF6>"ST_FILE_UTIL_FLAGS"</span><span class=cF7>)</span><span class=cF0>,</span><span class=cF6>"+r+i+f+F+T"</span><span class=cF0>);
|
||
|
<a name="l166"></a> </span><span class=cF5>ScanFlags</span><span class=cF0>(&fuf_flags,</span><span class=cF5>Define</span><span class=cF7>(</span><span class=cF6>"ST_FILE_UTIL_FLAGS"</span><span class=cF7>)</span><span class=cF0>,fu_flags);
|
||
|
<a name="l167"></a> </span><span class=cF1>if</span><span class=cF0> (fuf_flags&~</span><span class=cF7>(</span><span class=cF3>FUG_FILES_FIND</span><span class=cF0>|</span><span class=cF3>FUF_IGNORE</span><span class=cF0>|</span><span class=cF3>FUF_ALL</span><span class=cF0>|
|
||
|
<a name="l168"></a> </span><span class=cF3>FUF_WHOLE_LABELS</span><span class=cF0>|</span><span class=cF3>FUF_WHOLE_LABELS_BEFORE</span><span class=cF0>|</span><span class=cF3>FUF_WHOLE_LABELS_AFTER</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l169"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'FUF'</span><span class=cF0>);
|
||
|
<a name="l170"></a> </span><span class=cF5>LBEqu</span><span class=cF0>(&fuf_flags,</span><span class=cF3>FUf_REPLACE</span><span class=cF0>,replace_text);
|
||
|
<a name="l171"></a> tmpde=tmpde1=</span><span class=cF5>FilesFind</span><span class=cF0>(files_find_mask,fuf_flags&</span><span class=cF3>FUG_FILES_FIND</span><span class=cF0>);
|
||
|
<a name="l172"></a> fuf_flags&=</span><span class=cF3>FUF_ALL</span><span class=cF0>|</span><span class=cF3>FUF_REPLACE</span><span class=cF0>|</span><span class=cF3>FUF_IGNORE</span><span class=cF0>|</span><span class=cF3>FUF_WHOLE_LABELS</span><span class=cF0>|
|
||
|
<a name="l173"></a> </span><span class=cF3>FUF_WHOLE_LABELS_BEFORE</span><span class=cF0>|</span><span class=cF3>FUF_WHOLE_LABELS_AFTER</span><span class=cF0>;
|
||
|
<a name="l174"></a> </span><span class=cF1>while</span><span class=cF0> (tmpde && !</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&fuf_flags,</span><span class=cF3>FUf_CANCEL</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l175"></a> cnt+=</span><span class=cF5>FindFile</span><span class=cF0>(needle_str,tmpde->full_name,&fuf_flags,replace_text);
|
||
|
<a name="l176"></a> tmpde=tmpde->next;
|
||
|
<a name="l177"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l178"></a> </span><span class=cF5>DirTreeDel</span><span class=cF0>(tmpde1);
|
||
|
<a name="l179"></a> </span><span class=cF1>return</span><span class=cF0> cnt;
|
||
|
<a name="l180"></a>}
|
||
|
<a name="l181"></a>
|
||
|
<a name="l182"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>FileOcc</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *needle_str,
|
||
|
<a name="l183"></a> </span><span class=cF1>U8</span><span class=cF0> *files_find_mask=</span><span class=cF6>"*"</span><span class=cF0>,</span><span class=cF1>U8</span><span class=cF0> *fu_flags=</span><span class=cF6>"+r+i+l"</span><span class=cF0>)
|
||
|
<a name="l184"></a>{</span><span class=cF2>/*Silently return occurrences of a string in files.</span><span class=cF0>
|
||
|
<a name="l185"></a></span><span class=cF2>"+r"=recurse</span><span class=cF0>
|
||
|
<a name="l186"></a></span><span class=cF2>"+i"=ignore case</span><span class=cF0>
|
||
|
<a name="l187"></a></span><span class=cF2>"+l"=whole labels only.</span><span class=cF0>
|
||
|
<a name="l188"></a></span><span class=cF2>"+lb"=only checks for label chars before.</span><span class=cF0>
|
||
|
<a name="l189"></a></span><span class=cF2>"+la"=only checks for label chars after.</span><span class=cF0>
|
||
|
<a name="l190"></a></span><span class=cF2>*/</span><span class=cF0>
|
||
|
<a name="l191"></a> </span><span class=cF9>I64</span><span class=cF0> cnt=0;
|
||
|
<a name="l192"></a> </span><span class=cF1>Bool</span><span class=cF0> old_silent=</span><span class=cF5>Silent</span><span class=cF0>(</span><span class=cF3>TRUE</span><span class=cF0>);
|
||
|
<a name="l193"></a> cnt=</span><span class=cF5>Find</span><span class=cF0>(needle_str,files_find_mask,fu_flags);
|
||
|
<a name="l194"></a> </span><span class=cF5>Silent</span><span class=cF0>(old_silent);
|
||
|
<a name="l195"></a> </span><span class=cF1>return</span><span class=cF0> cnt;
|
||
|
<a name="l196"></a>}
|
||
|
<a name="l197"></a>
|
||
|
<a name="l198"></a></span><span class=cF1>class</span><span class=cF0> </span><span class=cF9>CFind</span><span class=cF0>
|
||
|
<a name="l199"></a>{
|
||
|
<a name="l200"></a> </span><span class=cF1>U8</span><span class=cF0> find_text[</span><span class=cF3>STR_LEN</span><span class=cF0>] format </span><span class=cF6>"$DA-P,"</span><span class=cF0>
|
||
|
<a name="l201"></a> </span><span class=cF6>"A=\"FIND :%s\"$\n"</span><span class=cF0>;
|
||
|
<a name="l202"></a> </span><span class=cF1>U8</span><span class=cF0> replace_text[</span><span class=cF3>STR_LEN</span><span class=cF0>] format </span><span class=cF6>"$DA-P,"</span><span class=cF0>
|
||
|
<a name="l203"></a> </span><span class=cF6>"A=\"REPLACE :%s\"$\n"</span><span class=cF0>;
|
||
|
<a name="l204"></a> </span><span class=cF1>Bool</span><span class=cF0> replace format </span><span class=cF6>"$CB,\"REPLACE\"$\n"</span><span class=cF0>;
|
||
|
<a name="l205"></a> </span><span class=cF1>Bool</span><span class=cF0> match_case format </span><span class=cF6>"$CB,\"MATCH CASE\"$\n"</span><span class=cF0>;
|
||
|
<a name="l206"></a> </span><span class=cF1>Bool</span><span class=cF0> whole_labels format </span><span class=cF6>"$CB,\"WHOLE LABELS\"$\n"</span><span class=cF0>;
|
||
|
<a name="l207"></a> </span><span class=cF1>U8</span><span class=cF0> filemask[</span><span class=cF3>STR_LEN</span><span class=cF0>] format </span><span class=cF6>"$DA-P,A=\"FILE MASK :%s\"$\n"</span><span class=cF0>;
|
||
|
<a name="l208"></a> </span><span class=cF1>Bool</span><span class=cF0> recurse format </span><span class=cF6>"$CB,\"RECURSE\"$\n"</span><span class=cF0>;
|
||
|
<a name="l209"></a>};
|
||
|
<a name="l210"></a>
|
||
|
<a name="l211"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>FindWiz</span><span class=cF0>()
|
||
|
<a name="l212"></a>{
|
||
|
<a name="l213"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc;
|
||
|
<a name="l214"></a> </span><span class=cF1>U8</span><span class=cF0> buf[32],*dir,*st;
|
||
|
<a name="l215"></a> </span><span class=cF9>CFind</span><span class=cF0> *g=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CFind</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l216"></a> </span><span class=cF9>I64</span><span class=cF0> res=0;
|
||
|
<a name="l217"></a> g->recurse=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l218"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(g->filemask,</span><span class=cF3>FILEMASK_TXT</span><span class=cF0>);
|
||
|
<a name="l219"></a> </span><span class=cF1>if</span><span class=cF0> (doc=</span><span class=cF5>DocPut</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l220"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(g->find_text,doc->find_replace->find_text);
|
||
|
<a name="l221"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(g->replace_text,doc->find_replace->replace_text);
|
||
|
<a name="l222"></a> g->replace=doc->find_replace->replace;
|
||
|
<a name="l223"></a> g->match_case=doc->find_replace->match_case;
|
||
|
<a name="l224"></a> g->whole_labels=doc->find_replace->whole_labels;
|
||
|
<a name="l225"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l226"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>DocForm</span><span class=cF7>(</span><span class=cF0>g,,0,</span><span class=cF6>"$PURPLE$$TX+CX,\"Find\"$\n$FG$"</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l227"></a> </span><span class=cF1>if</span><span class=cF0> (doc) {
|
||
|
<a name="l228"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(doc->find_replace->find_text,g->find_text);
|
||
|
<a name="l229"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(doc->find_replace->replace_text,g->replace_text);
|
||
|
<a name="l230"></a> doc->find_replace->replace=g->replace;
|
||
|
<a name="l231"></a> doc->find_replace->match_case=g->match_case;
|
||
|
<a name="l232"></a> doc->find_replace->whole_labels=g->whole_labels;
|
||
|
<a name="l233"></a> }
|
||
|
<a name="l234"></a> dir=</span><span class=cF5>PopUpPickDir</span><span class=cF0>;
|
||
|
<a name="l235"></a> </span><span class=cF1>if</span><span class=cF0> (*dir) {
|
||
|
<a name="l236"></a> *buf=0;
|
||
|
<a name="l237"></a> </span><span class=cF1>if</span><span class=cF0> (g->match_case)
|
||
|
<a name="l238"></a> </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>"-i"</span><span class=cF0>);
|
||
|
<a name="l239"></a> </span><span class=cF1>if</span><span class=cF0> (!g->recurse)
|
||
|
<a name="l240"></a> </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>"-r"</span><span class=cF0>);
|
||
|
<a name="l241"></a> </span><span class=cF1>if</span><span class=cF0> (g->whole_labels)
|
||
|
<a name="l242"></a> </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>"+l"</span><span class=cF0>);
|
||
|
<a name="l243"></a> </span><span class=cF1>if</span><span class=cF0> (g->replace)
|
||
|
<a name="l244"></a> st=</span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>"\"$$WW+H,1$$\";Cd(\"%s\");"</span><span class=cF0>
|
||
|
<a name="l245"></a> </span><span class=cF6>"Find(\"%Q\",\"%Q\",\"%Q\",\"%Q\");UserTaskCont;"</span><span class=cF0>,
|
||
|
<a name="l246"></a> dir,g->find_text,g->filemask,buf,g->replace_text);
|
||
|
<a name="l247"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l248"></a> st=</span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>"\"$$WW+H,1$$\";Cd(\"%s\");"</span><span class=cF0>
|
||
|
<a name="l249"></a> </span><span class=cF6>"Find(\"%Q\",\"%Q\",\"%Q\");UserTaskCont;"</span><span class=cF0>,
|
||
|
<a name="l250"></a> dir,g->find_text,g->filemask,buf);
|
||
|
<a name="l251"></a> res=</span><span class=cF5>PopUp</span><span class=cF0>(st);
|
||
|
<a name="l252"></a> }
|
||
|
<a name="l253"></a> </span><span class=cF5>Free</span><span class=cF0>(dir);
|
||
|
<a name="l254"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l255"></a> </span><span class=cF5>Free</span><span class=cF0>(g);
|
||
|
<a name="l256"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
||
|
<a name="l257"></a>}
|
||
|
</span></pre></body>
|
||
|
</html>
|