284 lines
31 KiB
HTML
Executable File
284 lines
31 KiB
HTML
Executable File
<!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>"File/Cmd Line (Typically);Cmd Line (Typically)"</span><span class=cF0>
|
|
<a name="l2"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>DBlk</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> blk,</span><span class=cF1>Bool</span><span class=cF0> write=</span><span class=cF3>FALSE</span><span class=cF0>)
|
|
<a name="l3"></a>{</span><span class=cF2>//Dump disk block. Optionally, write.</span><span class=cF0>
|
|
<a name="l4"></a></span><span class=cF2>//If you set write to TRUE, the block will</span><span class=cF0>
|
|
<a name="l5"></a> </span><span class=cF2>//be written when you press <ESC>.</span><span class=cF0>
|
|
<a name="l6"></a> </span><span class=cF2>//See </span><a href="/Wb/Demo/Dsk/DskRaw.HC.HTML#l1"><span class=cF4>::/Demo/Dsk/DskRaw.HC</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l7"></a> </span><span class=cF1>U8</span><span class=cF0> *buf=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF3>BLK_SIZE</span><span class=cF0>);
|
|
<a name="l8"></a>
|
|
<a name="l9"></a> </span><span class=cF5>BlkRead</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>->cur_dv,buf,blk,1);
|
|
<a name="l10"></a> </span><span class=cF5>DocD</span><span class=cF0>(buf,</span><span class=cF3>BLK_SIZE</span><span class=cF0>);
|
|
<a name="l11"></a> </span><span class=cF1>if</span><span class=cF0> (write) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l12"></a> </span><span class=cF6>"Edit and press <ESC> to write or <SHIFT-ESC>\n"</span><span class=cF0>;
|
|
<a name="l13"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>View</span><span class=cF0>) {
|
|
<a name="l14"></a> </span><span class=cF6>"Write\n"</span><span class=cF0>;
|
|
<a name="l15"></a> </span><span class=cF5>BlkWrite</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>->cur_dv,buf,blk,1);
|
|
<a name="l16"></a> }
|
|
<a name="l17"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l18"></a> </span><span class=cF1>return</span><span class=cF0> buf;
|
|
<a name="l19"></a>}
|
|
<a name="l20"></a>
|
|
<a name="l21"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>DClus</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> c,</span><span class=cF1>Bool</span><span class=cF0> write=</span><span class=cF3>FALSE</span><span class=cF0>,</span><span class=cF9>I64</span><span class=cF0> num=0)
|
|
<a name="l22"></a>{</span><span class=cF2>//Dump disk clus. Optionally, write.</span><span class=cF0>
|
|
<a name="l23"></a></span><span class=cF2>//If you set write to TRUE, the clus will</span><span class=cF0>
|
|
<a name="l24"></a> </span><span class=cF2>//be written when you press <ESC>.</span><span class=cF0>
|
|
<a name="l25"></a> </span><span class=cF2>//See </span><a href="/Wb/Demo/Dsk/DskRaw.HC.HTML#l1"><span class=cF4>::/Demo/Dsk/DskRaw.HC</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l26"></a> </span><span class=cF2>//Do </span><a href="/Wb/Kernel/BlkDev/DskDirB.HC.HTML#l102"><span class=cF4>Dir</span></a><span class=cF2>("*",TRUE); to get clus numbers of files.</span><span class=cF0>
|
|
<a name="l27"></a> </span><span class=cF1>U8</span><span class=cF0> *buf=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>->cur_dv->spc<<</span><span class=cF3>BLK_SIZE_BITS</span><span class=cF0>);
|
|
<a name="l28"></a> c=</span><span class=cF5>ClusNumNext</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>->cur_dv,c,num);
|
|
<a name="l29"></a> </span><span class=cF5>ClusRead</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>->cur_dv,buf,c,1);
|
|
<a name="l30"></a> </span><span class=cF6>"Clus:%X\n"</span><span class=cF0>,c;
|
|
<a name="l31"></a> </span><span class=cF5>DocD</span><span class=cF0>(buf,</span><span class=cF5>Fs</span><span class=cF0>->cur_dv->spc<<</span><span class=cF3>BLK_SIZE_BITS</span><span class=cF0>);
|
|
<a name="l32"></a> </span><span class=cF1>if</span><span class=cF0> (write) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l33"></a> </span><span class=cF6>"Edit and press <ESC> to write or <SHIFT-ESC>\n"</span><span class=cF0>;
|
|
<a name="l34"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>View</span><span class=cF0>) {
|
|
<a name="l35"></a> </span><span class=cF6>"Write\n"</span><span class=cF0>;
|
|
<a name="l36"></a> </span><span class=cF5>ClusWrite</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>->cur_dv,buf,c,1);
|
|
<a name="l37"></a> }
|
|
<a name="l38"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l39"></a> </span><span class=cF1>return</span><span class=cF0> buf;
|
|
<a name="l40"></a>}
|
|
<a name="l41"></a>
|
|
<a name="l42"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>Dump</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *filename,</span><span class=cF1>Bool</span><span class=cF0> write=</span><span class=cF3>FALSE</span><span class=cF0>)
|
|
<a name="l43"></a>{</span><span class=cF2>//Dump file. Optionally, write.</span><span class=cF0>
|
|
<a name="l44"></a></span><span class=cF2>//If you set write to TRUE, the file will</span><span class=cF0>
|
|
<a name="l45"></a> </span><span class=cF2>//be written when you press <ESC>.</span><span class=cF0>
|
|
<a name="l46"></a> </span><span class=cF1>U8</span><span class=cF0> *buf;
|
|
<a name="l47"></a> </span><span class=cF9>I64</span><span class=cF0> size;
|
|
<a name="l48"></a> </span><span class=cF1>if</span><span class=cF0> (buf=</span><span class=cF5>FileRead</span><span class=cF7>(</span><span class=cF0>filename,&size</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l49"></a> </span><span class=cF5>DocD</span><span class=cF0>(buf,size);
|
|
<a name="l50"></a> </span><span class=cF1>if</span><span class=cF0> (write) {
|
|
<a name="l51"></a> </span><span class=cF6>"Edit and press <ESC> to write or <SHIFT-ESC>\n"</span><span class=cF0>;
|
|
<a name="l52"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>View</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l53"></a> </span><span class=cF6>"Write\n"</span><span class=cF0>;
|
|
<a name="l54"></a> </span><span class=cF5>FileWrite</span><span class=cF0>(filename,buf,size);
|
|
<a name="l55"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l56"></a> }
|
|
<a name="l57"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l58"></a> </span><span class=cF1>return</span><span class=cF0> buf;
|
|
<a name="l59"></a>}
|
|
<a name="l60"></a>
|
|
<a name="l61"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>Copy</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *src_files_find_mask,</span><span class=cF1>U8</span><span class=cF0> *dst_files_find_mask=</span><span class=cF6>"."</span><span class=cF0>)
|
|
<a name="l62"></a>{</span><span class=cF2>//Copy files.</span><span class=cF0>
|
|
<a name="l63"></a></span><span class=cF2>//If the name ends in ".Z", it will</span><span class=cF0>
|
|
<a name="l64"></a> </span><span class=cF2>//be stored compressed. If not ".Z"</span><span class=cF0>
|
|
<a name="l65"></a> </span><span class=cF2>//it will be stored uncompressed.</span><span class=cF0>
|
|
<a name="l66"></a> </span><span class=cF1>Bool</span><span class=cF0> res=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l67"></a> </span><span class=cF9>CDirContext</span><span class=cF0> *dirc;
|
|
<a name="l68"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> *tmpde,*tmpde1;
|
|
<a name="l69"></a> </span><span class=cF1>U8</span><span class=cF0> *st;
|
|
<a name="l70"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>tmpde1=</span><span class=cF5>FilesFind</span><span class=cF0>(src_files_find_mask,</span><span class=cF3>FUF_CLUS_ORDER</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l71"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l72"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>IsDir</span><span class=cF7>(</span><span class=cF0>dst_files_find_mask</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l73"></a> </span><span class=cF1>if</span><span class=cF0> (dirc=</span><span class=cF5>DirContextNew</span><span class=cF7>(</span><span class=cF0>dst_files_find_mask,</span><span class=cF3>TRUE</span><span class=cF7>)</span><span class=cF0>) {
|
|
<a name="l74"></a> tmpde=tmpde1;
|
|
<a name="l75"></a> </span><span class=cF1>while</span><span class=cF0> (tmpde) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l76"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>tmpde->attr & </span><span class=cF3>RS_ATTR_DIR</span><span class=cF7>)</span><span class=cF0>) {
|
|
<a name="l77"></a> st=</span><span class=cF5>FileNameAbs</span><span class=cF0>(tmpde->name);
|
|
<a name="l78"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>CopySingle</span><span class=cF7>(</span><span class=cF0>tmpde->full_name,st</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l79"></a> res=</span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l80"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
|
|
<a name="l81"></a> }
|
|
<a name="l82"></a> tmpde=tmpde->next;
|
|
<a name="l83"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l84"></a> </span><span class=cF5>DirContextDel</span><span class=cF0>(dirc);
|
|
<a name="l85"></a> }
|
|
<a name="l86"></a> </span><span class=cF5>DirTreeDel</span><span class=cF0>(tmpde1);
|
|
<a name="l87"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l88"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l89"></a> </span><span class=cF5>DirTreeDel</span><span class=cF0>(tmpde1);
|
|
<a name="l90"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>CopySingle</span><span class=cF0>(src_files_find_mask,dst_files_find_mask);
|
|
<a name="l91"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l92"></a>}
|
|
<a name="l93"></a>
|
|
<a name="l94"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>Move</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *f1,</span><span class=cF1>U8</span><span class=cF0> *f2)
|
|
<a name="l95"></a>{</span><span class=cF2>//Move files from one location to another or rename.</span><span class=cF0>
|
|
<a name="l96"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Copy</span><span class=cF7>(</span><span class=cF0>f1,f2</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l97"></a> </span><span class=cF5>Del</span><span class=cF0>(f1);
|
|
<a name="l98"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l99"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l100"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l101"></a>}
|
|
<a name="l102"></a>
|
|
<a name="l103"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>CopyTree2</span><span class=cF0>(</span><span class=cF9>CDirEntry</span><span class=cF0> *tmpde,</span><span class=cF9>I64</span><span class=cF0> src_dir_len,</span><span class=cF9>I64</span><span class=cF0> dst_dir_len,</span><span class=cF1>U8</span><span class=cF0> *dst_dir)
|
|
<a name="l104"></a>{
|
|
<a name="l105"></a> </span><span class=cF1>U8</span><span class=cF0> *st;
|
|
<a name="l106"></a> </span><span class=cF9>I64</span><span class=cF0> res=1;
|
|
<a name="l107"></a> </span><span class=cF1>while</span><span class=cF0> (tmpde) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l108"></a> st=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>tmpde->full_name</span><span class=cF7>)</span><span class=cF0>+dst_dir_len+2);
|
|
<a name="l109"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(st,dst_dir,dst_dir_len);
|
|
<a name="l110"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(st+dst_dir_len,tmpde->full_name+src_dir_len);
|
|
<a name="l111"></a> </span><span class=cF1>if</span><span class=cF0> (tmpde->attr & </span><span class=cF3>RS_ATTR_DIR</span><span class=cF0>) {
|
|
<a name="l112"></a> </span><span class=cF5>DirMk</span><span class=cF0>(st,</span><span class=cF5>LinkedLstCnt</span><span class=cF7>(</span><span class=cF0>tmpde->sub</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l113"></a> res+=</span><span class=cF5>CopyTree2</span><span class=cF0>(tmpde->sub,src_dir_len,dst_dir_len,dst_dir);
|
|
<a name="l114"></a> } </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l115"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>CopySingle</span><span class=cF7>(</span><span class=cF0>tmpde->full_name,st</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l116"></a> res++;
|
|
<a name="l117"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
|
|
<a name="l118"></a> tmpde=tmpde->next;
|
|
<a name="l119"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l120"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l121"></a>}
|
|
<a name="l122"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>CopyTree</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *src_files_find_mask,</span><span class=cF1>U8</span><span class=cF0> *dst_files_find_mask,
|
|
<a name="l123"></a> </span><span class=cF1>Bool</span><span class=cF0> no_mask=</span><span class=cF3>TRUE</span><span class=cF0>)
|
|
<a name="l124"></a>{</span><span class=cF2>//Copy directory tree.</span><span class=cF0>
|
|
<a name="l125"></a></span><span class=cF2>//Returns the count of copied files (not dirs).</span><span class=cF0>
|
|
<a name="l126"></a> </span><span class=cF9>CDirContext</span><span class=cF0> *dirc;
|
|
<a name="l127"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> *tmpde=</span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l128"></a> </span><span class=cF9>I64</span><span class=cF0> res=0,i1,i2;
|
|
<a name="l129"></a> </span><span class=cF1>U8</span><span class=cF0> *st1,*st2;
|
|
<a name="l130"></a>
|
|
<a name="l131"></a> st1=</span><span class=cF5>DirNameAbs</span><span class=cF0>(src_files_find_mask);
|
|
<a name="l132"></a> st2=</span><span class=cF5>DirNameAbs</span><span class=cF0>(dst_files_find_mask);
|
|
<a name="l133"></a> i1=</span><span class=cF5>StrLen</span><span class=cF0>(st1);
|
|
<a name="l134"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>StrNCmp</span><span class=cF7>(</span><span class=cF0>st1,st2,i1</span><span class=cF7>)</span><span class=cF0> && </span><span class=cF7>(</span><span class=cF0>st2[i1]==</span><span class=cF6>'/'</span><span class=cF0> || !st2[i1]</span><span class=cF7>)</span><span class=cF0> ) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l135"></a> </span><span class=cF5>Free</span><span class=cF0>(st1);
|
|
<a name="l136"></a> </span><span class=cF5>Free</span><span class=cF0>(st2);
|
|
<a name="l137"></a> </span><span class=cF1>return</span><span class=cF0> 0;
|
|
<a name="l138"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l139"></a> </span><span class=cF5>Free</span><span class=cF0>(st1);
|
|
<a name="l140"></a> </span><span class=cF5>Free</span><span class=cF0>(st2);
|
|
<a name="l141"></a> </span><span class=cF1>if</span><span class=cF0> (dirc=</span><span class=cF5>DirContextNew</span><span class=cF7>(</span><span class=cF0>src_files_find_mask,</span><span class=cF3>TRUE</span><span class=cF0>,,no_mask</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l142"></a> tmpde=</span><span class=cF5>FilesFind</span><span class=cF0>(dirc->mask,</span><span class=cF3>FUF_RECURSE</span><span class=cF0>);
|
|
<a name="l143"></a> st1=</span><span class=cF5>DirCur</span><span class=cF0>;
|
|
<a name="l144"></a> </span><span class=cF5>DirContextDel</span><span class=cF0>(dirc);
|
|
<a name="l145"></a> i1=</span><span class=cF5>StrLen</span><span class=cF0>(st1);
|
|
<a name="l146"></a> </span><span class=cF1>if</span><span class=cF0> (i1==3) i1--;
|
|
<a name="l147"></a> </span><span class=cF1>if</span><span class=cF0> (dirc=</span><span class=cF5>DirContextNew</span><span class=cF7>(</span><span class=cF0>dst_files_find_mask,</span><span class=cF3>TRUE</span><span class=cF0>,</span><span class=cF3>TRUE</span><span class=cF7>)</span><span class=cF0>) {
|
|
<a name="l148"></a> st2=</span><span class=cF5>DirCur</span><span class=cF0>;
|
|
<a name="l149"></a> i2=</span><span class=cF5>StrLen</span><span class=cF0>(st2);
|
|
<a name="l150"></a> </span><span class=cF1>if</span><span class=cF0> (i2==3) i2--;
|
|
<a name="l151"></a> res=</span><span class=cF5>CopyTree2</span><span class=cF0>(tmpde,i1,i2,st2);
|
|
<a name="l152"></a> </span><span class=cF5>DirContextDel</span><span class=cF0>(dirc);
|
|
<a name="l153"></a> </span><span class=cF5>Free</span><span class=cF0>(st2);
|
|
<a name="l154"></a> }
|
|
<a name="l155"></a> </span><span class=cF5>DirTreeDel</span><span class=cF0>(tmpde);
|
|
<a name="l156"></a> </span><span class=cF5>Free</span><span class=cF0>(st1);
|
|
<a name="l157"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l158"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l159"></a>}
|
|
<a name="l160"></a>
|
|
<a name="l161"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>DelTreeDirs</span><span class=cF0>(</span><span class=cF9>CDirEntry</span><span class=cF0> *tmpde1)
|
|
<a name="l162"></a>{
|
|
<a name="l163"></a> </span><span class=cF9>I64</span><span class=cF0> res=0;
|
|
<a name="l164"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> *tmpde2;
|
|
<a name="l165"></a> </span><span class=cF1>while</span><span class=cF0> (tmpde1) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l166"></a> tmpde2=tmpde1->next;
|
|
<a name="l167"></a> </span><span class=cF1>if</span><span class=cF0> (tmpde1->attr & </span><span class=cF3>RS_ATTR_DIR</span><span class=cF0>) {
|
|
<a name="l168"></a> </span><span class=cF1>if</span><span class=cF0> (tmpde1->sub)
|
|
<a name="l169"></a> res+=</span><span class=cF5>DelTreeDirs</span><span class=cF0>(tmpde1->sub);
|
|
<a name="l170"></a> res+=</span><span class=cF5>Del</span><span class=cF0>(tmpde1->full_name,</span><span class=cF3>TRUE</span><span class=cF0>,</span><span class=cF3>TRUE</span><span class=cF0>);
|
|
<a name="l171"></a> }
|
|
<a name="l172"></a> </span><span class=cF5>DirEntryDel</span><span class=cF0>(tmpde1);
|
|
<a name="l173"></a> tmpde1=tmpde2;
|
|
<a name="l174"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l175"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l176"></a>}
|
|
<a name="l177"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>DelTreeFiles</span><span class=cF0>(</span><span class=cF9>CDirEntry</span><span class=cF0> *tmpde1)
|
|
<a name="l178"></a>{
|
|
<a name="l179"></a> </span><span class=cF9>I64</span><span class=cF0> res=0;
|
|
<a name="l180"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> *tmpde2;
|
|
<a name="l181"></a> </span><span class=cF1>while</span><span class=cF0> (tmpde1) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l182"></a> tmpde2=tmpde1->next;
|
|
<a name="l183"></a> </span><span class=cF1>if</span><span class=cF0> (tmpde1->attr & </span><span class=cF3>RS_ATTR_DIR</span><span class=cF0>) {
|
|
<a name="l184"></a> </span><span class=cF1>if</span><span class=cF0> (tmpde1->sub)
|
|
<a name="l185"></a> res+=</span><span class=cF5>DelTreeFiles</span><span class=cF0>(tmpde1->sub);
|
|
<a name="l186"></a> } </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l187"></a> res+=</span><span class=cF5>Del</span><span class=cF0>(tmpde1->full_name,</span><span class=cF3>FALSE</span><span class=cF0>,</span><span class=cF3>TRUE</span><span class=cF0>);
|
|
<a name="l188"></a> </span><span class=cF5>DirEntryDel</span><span class=cF0>(tmpde1);
|
|
<a name="l189"></a> tmpde1=tmpde2;
|
|
<a name="l190"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l191"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l192"></a>}
|
|
<a name="l193"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>DelTree</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *files_find_mask,</span><span class=cF1>U8</span><span class=cF0> *fu_flags=</span><span class=cF3>NULL</span><span class=cF0>)
|
|
<a name="l194"></a>{</span><span class=cF2>//Delete directory tree.</span><span class=cF0>
|
|
<a name="l195"></a> </span><span class=cF9>I64</span><span class=cF0> res=0,fuf_flags=0;
|
|
<a name="l196"></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"</span><span class=cF0>);
|
|
<a name="l197"></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="l198"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>IsDir</span><span class=cF7>(</span><span class=cF0>files_find_mask</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l199"></a> res=</span><span class=cF5>DelTreeDirs</span><span class=cF0>(</span><span class=cF5>FilesFind</span><span class=cF7>(</span><span class=cF0>files_find_mask,fuf_flags</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l200"></a> res+=</span><span class=cF5>Del</span><span class=cF0>(files_find_mask,</span><span class=cF3>TRUE</span><span class=cF0>,</span><span class=cF3>TRUE</span><span class=cF0>);
|
|
<a name="l201"></a> res+=</span><span class=cF5>Del</span><span class=cF0>(files_find_mask,</span><span class=cF3>FALSE</span><span class=cF0>,</span><span class=cF3>TRUE</span><span class=cF0>);
|
|
<a name="l202"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l203"></a> res=</span><span class=cF5>DelTreeFiles</span><span class=cF0>(</span><span class=cF5>FilesFind</span><span class=cF7>(</span><span class=cF0>files_find_mask,fuf_flags</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l204"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l205"></a>}
|
|
<a name="l206"></a>
|
|
<a name="l207"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>TouchFile</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *filename,</span><span class=cF1>U8</span><span class=cF0> *attr,</span><span class=cF9>CDate</span><span class=cF0> cdt=</span><span class=cF3>I64_MIN</span><span class=cF0>)
|
|
<a name="l208"></a>{
|
|
<a name="l209"></a> </span><span class=cF9>CDrv</span><span class=cF0> *dv=</span><span class=cF5>Let2Drv</span><span class=cF0>(*filename);
|
|
<a name="l210"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> de;
|
|
<a name="l211"></a> </span><span class=cF1>U8</span><span class=cF0> *cur_dir=</span><span class=cF5>StrNew</span><span class=cF0>(filename),buf[</span><span class=cF3>STR_LEN</span><span class=cF0>];
|
|
<a name="l212"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>FileFind</span><span class=cF7>(</span><span class=cF0>filename,&de,</span><span class=cF3>FUF_JUST_FILES</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l213"></a> </span><span class=cF5>Free</span><span class=cF0>(de.full_name);
|
|
<a name="l214"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>StrCmp</span><span class=cF7>(</span><span class=cF0>attr,</span><span class=cF6>"+?"</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l215"></a> </span><span class=cF6>"%-48ts %s\n"</span><span class=cF0>,filename,</span><span class=cF5>StrPrintFlags</span><span class=cF0>(buf,</span><span class=cF5>Define</span><span class=cF7>(</span><span class=cF6>"ST_FILE_ATTRS"</span><span class=cF7>)</span><span class=cF0>,de.attr);
|
|
<a name="l216"></a> </span><span class=cF1>else</span><span class=cF0> {
|
|
<a name="l217"></a> </span><span class=cF5>StrFirstRem</span><span class=cF0>(cur_dir,</span><span class=cF6>":"</span><span class=cF0>);
|
|
<a name="l218"></a> </span><span class=cF5>StrLastRem</span><span class=cF0>(cur_dir,</span><span class=cF6>"/"</span><span class=cF0>);
|
|
<a name="l219"></a> </span><span class=cF1>if</span><span class=cF0> (!*cur_dir)
|
|
<a name="l220"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(cur_dir,</span><span class=cF6>"/"</span><span class=cF0>);
|
|
<a name="l221"></a> </span><span class=cF5>ScanFlags</span><span class=cF0>(&de.attr,</span><span class=cF5>Define</span><span class=cF7>(</span><span class=cF6>"ST_FILE_ATTRS"</span><span class=cF7>)</span><span class=cF0>,attr);
|
|
<a name="l222"></a> </span><span class=cF1>if</span><span class=cF0> (cdt==</span><span class=cF3>I64_MIN</span><span class=cF0>)
|
|
<a name="l223"></a> de.datetime=</span><span class=cF5>Now</span><span class=cF0>;
|
|
<a name="l224"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l225"></a> de.datetime=cdt;
|
|
<a name="l226"></a> </span><span class=cF5>DirNew</span><span class=cF0>(dv,cur_dir,&de,</span><span class=cF3>FALSE</span><span class=cF0>);
|
|
<a name="l227"></a> }
|
|
<a name="l228"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l229"></a> </span><span class=cF5>PrintErr</span><span class=cF0>(</span><span class=cF6>"File not found: \"%s\".\n"</span><span class=cF0>,filename);
|
|
<a name="l230"></a> </span><span class=cF5>Free</span><span class=cF0>(cur_dir);
|
|
<a name="l231"></a>}
|
|
<a name="l232"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>Touch</span><span class=cF0>(</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> *attr=</span><span class=cF6>"+?"</span><span class=cF0>,
|
|
<a name="l233"></a> </span><span class=cF1>U8</span><span class=cF0> *fu_flags=</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF9>CDate</span><span class=cF0> cdt=</span><span class=cF3>I64_MIN</span><span class=cF0>)
|
|
<a name="l234"></a>{</span><span class=cF2>/*Touch file attributes and DateTime.</span><span class=cF0>
|
|
<a name="l235"></a></span><span class=cF2>Default lists attributes.</span><span class=cF0>
|
|
<a name="l236"></a></span><span class=cF2>attr: "+?" =show current</span><span class=cF0>
|
|
<a name="l237"></a></span><span class=cF2>"+T" =resident</span><span class=cF4>
|
|
<a name="l238"></a></span><a href="/Wb/Kernel/KernelA.HH.HTML#l2497"><span class=cF4>RS_ATTR_READ_ONLY</span></a><span class=cF2> </span><a href="/Wb/Kernel/KDefine.HC.HTML#l109"><span class=cF4>ST_FILE_ATTRS</span></a><span class=cF0>
|
|
<a name="l239"></a></span><span class=cF2>To Set DateL:</span><span class=cF0>
|
|
<a name="l240"></a></span><span class=cF2>Touch(filename,"",,datetime);</span><span class=cF0>
|
|
<a name="l241"></a></span><span class=cF2>*/</span><span class=cF0>
|
|
<a name="l242"></a> </span><span class=cF9>I64</span><span class=cF0> fuf_flags=0;
|
|
<a name="l243"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> *tmpde,*tmpde1;
|
|
<a name="l244"></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>"+f+F"</span><span class=cF0>);
|
|
<a name="l245"></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="l246"></a> tmpde=tmpde1=</span><span class=cF5>FilesFind</span><span class=cF0>(files_find_mask,fuf_flags);
|
|
<a name="l247"></a> </span><span class=cF1>while</span><span class=cF0> (tmpde) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l248"></a> </span><span class=cF5>TouchFile</span><span class=cF0>(tmpde->full_name,attr,cdt);
|
|
<a name="l249"></a> tmpde=tmpde->next;
|
|
<a name="l250"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l251"></a> </span><span class=cF5>DirTreeDel</span><span class=cF0>(tmpde1);
|
|
<a name="l252"></a>}
|
|
</span></pre></body>
|
|
</html>
|