183 lines
19 KiB
HTML
Executable File
183 lines
19 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=cF9>CDirEntry</span><span class=cF0> *</span><span class=cFD>FilesFind2</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *files_find_mask,</span><span class=cF9>I64</span><span class=cF0> fuf_flags)
|
|
<a name="l2"></a>{
|
|
<a name="l3"></a> </span><span class=cF9>CDrv</span><span class=cF0> *dv=</span><span class=cF5>Fs</span><span class=cF0>->cur_dv;
|
|
<a name="l4"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> *res=</span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l5"></a> </span><span class=cF5>DrvChk</span><span class=cF0>(dv);
|
|
<a name="l6"></a> </span><span class=cF1>switch</span><span class=cF0> (dv->fs_type) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l7"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>FSt_REDSEA</span><span class=cF0>:
|
|
<a name="l8"></a> res=</span><span class=cFD>RedSeaFilesFind</span><span class=cF0>(files_find_mask,fuf_flags);
|
|
<a name="l9"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l10"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>FSt_FAT32</span><span class=cF0>:
|
|
<a name="l11"></a> res=</span><span class=cFD>FAT32FilesFind</span><span class=cF0>(files_find_mask,fuf_flags);
|
|
<a name="l12"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l13"></a> </span><span class=cF1>default</span><span class=cF0>:
|
|
<a name="l14"></a> </span><span class=cF5>PrintErr</span><span class=cF0>(</span><span class=cF6>"File System Not Supported\n"</span><span class=cF0>);
|
|
<a name="l15"></a> res=</span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l16"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l17"></a> </span><span class=cF1>if</span><span class=cF0> (res) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l18"></a> </span><span class=cFD>DirFilesSort</span><span class=cF0>(&res,SK_NAME);
|
|
<a name="l19"></a> </span><span class=cF1>if</span><span class=cF0> (fuf_flags&</span><span class=cF7>(</span><span class=cF3>FUF_FLATTEN_TREE</span><span class=cF0>|</span><span class=cF3>FUF_JUST_FILES</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l20"></a> </span><span class=cFD>DirFilesFlatten</span><span class=cF0>(res,&res,fuf_flags);
|
|
<a name="l21"></a> </span><span class=cF1>if</span><span class=cF0> (fuf_flags&</span><span class=cF3>FUF_CLUS_ORDER</span><span class=cF0>)
|
|
<a name="l22"></a> </span><span class=cFD>DirFilesSort</span><span class=cF0>(&res,SK_CLUS);
|
|
<a name="l23"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l24"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l25"></a>}
|
|
<a name="l26"></a>
|
|
<a name="l27"></a></span><span class=cF9>CDirEntry</span><span class=cF0> *</span><span class=cF5>FilesFind</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *files_find_mask,</span><span class=cF9>I64</span><span class=cF0> fuf_flags=0)
|
|
<a name="l28"></a>{</span><span class=cF2>/* See </span><a href="/Wb/Doc/FileUtils.DD.HTML#l1"><span class=cF4>::/Doc/FileUtils.DD</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l29"></a>
|
|
<a name="l30"></a></span><span class=cF2>Find files and make a directory tree in memory.</span><span class=cF0>
|
|
<a name="l31"></a>
|
|
<a name="l32"></a></span><span class=cF2>When done, you free with </span><a href="/Wb/Kernel/BlkDev/DskDirA.HC.HTML#l14"><span class=cF4>DirEntryDel</span></a><span class=cF2>(),</span><a href="/Wb/Kernel/BlkDev/DskDirA.HC.HTML#l23"><span class=cF4>DirEntryDel2</span></a><span class=cF2>(),</span><span class=cF4>
|
|
<a name="l33"></a></span><a href="/Wb/Kernel/BlkDev/DskDirA.HC.HTML#l33"><span class=cF4>DirTreeDel</span></a><span class=cF2>() or </span><a href="/Wb/Kernel/BlkDev/DskDirA.HC.HTML#l46"><span class=cF4>DirTreeDel2</span></a><span class=cF2>().</span><span class=cF0>
|
|
<a name="l34"></a>
|
|
<a name="l35"></a></span><span class=cF2>*/</span><span class=cF0>
|
|
<a name="l36"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> *res;
|
|
<a name="l37"></a> </span><span class=cF9>CDirContext</span><span class=cF0> *dirc;
|
|
<a name="l38"></a> </span><span class=cF1>if</span><span class=cF0> (fuf_flags&~</span><span class=cF3>FUG_FILES_FIND</span><span class=cF0>)
|
|
<a name="l39"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'FUF'</span><span class=cF0>);
|
|
<a name="l40"></a> </span><span class=cF1>if</span><span class=cF0> (fuf_flags&</span><span class=cF3>FUF_SINGLE</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l41"></a> res=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l42"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>FileFind</span><span class=cF7>(</span><span class=cF0>files_find_mask,res</span><span class=cF7>)</span><span class=cF0>) {
|
|
<a name="l43"></a> </span><span class=cF5>Free</span><span class=cF0>(res);
|
|
<a name="l44"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l45"></a> }
|
|
<a name="l46"></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> (dirc=</span><span class=cF5>DirContextNew</span><span class=cF7>(</span><span class=cF0>files_find_mask,</span><span class=cF3>TRUE</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l47"></a> res=</span><span class=cFD>FilesFind2</span><span class=cF0>(dirc->mask,fuf_flags);
|
|
<a name="l48"></a> </span><span class=cF5>DirContextDel</span><span class=cF0>(dirc);
|
|
<a name="l49"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l50"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l51"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l52"></a>}
|
|
<a name="l53"></a>
|
|
<a name="l54"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>FileFind</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *filename,</span><span class=cF9>CDirEntry</span><span class=cF0> *_de=</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF9>I64</span><span class=cF0> fuf_flags=0)
|
|
<a name="l55"></a>{</span><span class=cF2>//</span><a href="/Wb/Kernel/KernelA.HH.HTML#l2577"><span class=cF4>FUF_JUST_DIRS</span></a><span class=cF2>, </span><a href="/Wb/Kernel/KernelA.HH.HTML#l2578"><span class=cF4>FUF_JUST_FILES</span></a><span class=cF2>, </span><a href="/Wb/Kernel/KernelA.HH.HTML#l2585"><span class=cF4>FUF_Z_OR_NOT_Z</span></a><span class=cF2>, </span><a href="/Wb/Kernel/KernelA.HH.HTML#l2587"><span class=cF4>FUF_SCAN_PARENTS</span></a><span class=cF0>
|
|
<a name="l56"></a></span><span class=cF2>//If you pass _de, you must Free(_de->full_name);</span><span class=cF0>
|
|
<a name="l57"></a> </span><span class=cF9>I64</span><span class=cF0> i,j,cur_dir_clus;
|
|
<a name="l58"></a> </span><span class=cF1>U8</span><span class=cF0> *altname,*curname,*full_name=</span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l59"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> de;
|
|
<a name="l60"></a> </span><span class=cF9>CDirContext</span><span class=cF0> *dirc;
|
|
<a name="l61"></a> </span><span class=cF1>Bool</span><span class=cF0> res=</span><span class=cF3>FALSE</span><span class=cF0>,old_silent;
|
|
<a name="l62"></a> </span><span class=cF1>if</span><span class=cF0> (fuf_flags&~</span><span class=cF3>FUG_FILE_FIND</span><span class=cF0>)
|
|
<a name="l63"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'FUF'</span><span class=cF0>);
|
|
<a name="l64"></a> </span><span class=cF1>if</span><span class=cF0> (!filename || *filename && filename[1]==</span><span class=cF6>':'</span><span class=cF0> && !</span><span class=cF5>Let2Drv</span><span class=cF7>(</span><span class=cF0>*filename,</span><span class=cF3>FALSE</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l65"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l66"></a> altname=</span><span class=cF5>ToggleZorNotZ</span><span class=cF0>(filename);
|
|
<a name="l67"></a> </span><span class=cF1>if</span><span class=cF0> (fuf_flags&</span><span class=cF3>FUF_Z_OR_NOT_Z</span><span class=cF0>)
|
|
<a name="l68"></a> j=2;
|
|
<a name="l69"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l70"></a> j=1;
|
|
<a name="l71"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<j && !res;i++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l72"></a> </span><span class=cF1>if</span><span class=cF0> (!i)
|
|
<a name="l73"></a> curname=filename;
|
|
<a name="l74"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l75"></a> curname=altname;
|
|
<a name="l76"></a> old_silent=</span><span class=cF5>Silent</span><span class=cF0>;
|
|
<a name="l77"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>dirc=</span><span class=cF5>DirContextNew</span><span class=cF0>(curname)</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l78"></a> </span><span class=cF5>Silent</span><span class=cF0>(old_silent);
|
|
<a name="l79"></a> </span><span class=cF1>else</span><span class=cF0> {
|
|
<a name="l80"></a> </span><span class=cF5>Silent</span><span class=cF0>(old_silent);
|
|
<a name="l81"></a> cur_dir_clus=</span><span class=cF5>Name2DirClus</span><span class=cF0>(dirc->dv,</span><span class=cF5>Fs</span><span class=cF0>->cur_dir);
|
|
<a name="l82"></a> </span><span class=cF1>switch</span><span class=cF0> (dirc->dv->fs_type) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l83"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>FSt_REDSEA</span><span class=cF0>:
|
|
<a name="l84"></a> res=</span><span class=cFD>RedSeaFileFind</span><span class=cF0>(dirc->dv,cur_dir_clus,dirc->mask,
|
|
<a name="l85"></a> &de,fuf_flags);
|
|
<a name="l86"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l87"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>FSt_FAT32</span><span class=cF0>:
|
|
<a name="l88"></a> res=</span><span class=cFD>FAT32FileFind</span><span class=cF0>(dirc->dv,cur_dir_clus,dirc->mask,
|
|
<a name="l89"></a> &de,fuf_flags);
|
|
<a name="l90"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l91"></a> </span><span class=cF1>default</span><span class=cF0>:
|
|
<a name="l92"></a> </span><span class=cF5>PrintErr</span><span class=cF0>(</span><span class=cF6>"File System Not Supported\n"</span><span class=cF0>);
|
|
<a name="l93"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l94"></a> </span><span class=cF1>if</span><span class=cF0> (res && _de) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l95"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>StrCmp</span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>->cur_dir,</span><span class=cF6>"/"</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l96"></a> full_name=</span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>"%C:%s/%s"</span><span class=cF0>,
|
|
<a name="l97"></a> </span><span class=cF5>Drv2Let</span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>->cur_dv</span><span class=cF7>)</span><span class=cF0>,</span><span class=cF5>Fs</span><span class=cF0>->cur_dir,de.name);
|
|
<a name="l98"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l99"></a> full_name=</span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>"%C:/%s"</span><span class=cF0>,</span><span class=cF5>Drv2Let</span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>->cur_dv</span><span class=cF7>)</span><span class=cF0>,de.name);
|
|
<a name="l100"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l101"></a> </span><span class=cF5>DirContextDel</span><span class=cF0>(dirc);
|
|
<a name="l102"></a> }
|
|
<a name="l103"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l104"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<j && !res && fuf_flags&</span><span class=cF3>FUF_SCAN_PARENTS</span><span class=cF0>;i++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l105"></a> </span><span class=cF1>if</span><span class=cF0> (!i)
|
|
<a name="l106"></a> curname=filename;
|
|
<a name="l107"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l108"></a> curname=altname;
|
|
<a name="l109"></a> old_silent=</span><span class=cF5>Silent</span><span class=cF0>;
|
|
<a name="l110"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>dirc=</span><span class=cF5>DirContextNew</span><span class=cF0>(curname)</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l111"></a> </span><span class=cF5>Silent</span><span class=cF0>(old_silent);
|
|
<a name="l112"></a> </span><span class=cF1>else</span><span class=cF0> {
|
|
<a name="l113"></a> </span><span class=cF5>Silent</span><span class=cF0>(old_silent);
|
|
<a name="l114"></a> cur_dir_clus=</span><span class=cF5>Name2DirClus</span><span class=cF0>(dirc->dv,</span><span class=cF5>Fs</span><span class=cF0>->cur_dir);
|
|
<a name="l115"></a> </span><span class=cF1>while</span><span class=cF0> (!res && </span><span class=cF5>StrCmp</span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>->cur_dir,</span><span class=cF6>"/"</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l116"></a> </span><span class=cF5>Cd</span><span class=cF0>(</span><span class=cF6>".."</span><span class=cF0>);
|
|
<a name="l117"></a> cur_dir_clus=</span><span class=cF5>Name2DirClus</span><span class=cF0>(dirc->dv,</span><span class=cF5>Fs</span><span class=cF0>->cur_dir);
|
|
<a name="l118"></a> </span><span class=cF1>switch</span><span class=cF0> (dirc->dv->fs_type) {
|
|
<a name="l119"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>FSt_REDSEA</span><span class=cF0>:
|
|
<a name="l120"></a> res=</span><span class=cFD>RedSeaFileFind</span><span class=cF0>(dirc->dv,cur_dir_clus,
|
|
<a name="l121"></a> dirc->mask,&de,fuf_flags);
|
|
<a name="l122"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l123"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>FSt_FAT32</span><span class=cF0>:
|
|
<a name="l124"></a> res=</span><span class=cFD>FAT32FileFind</span><span class=cF0>(dirc->dv,cur_dir_clus,
|
|
<a name="l125"></a> dirc->mask,&de,fuf_flags);
|
|
<a name="l126"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l127"></a> </span><span class=cF1>default</span><span class=cF0>:
|
|
<a name="l128"></a> </span><span class=cF5>PrintErr</span><span class=cF0>(</span><span class=cF6>"File System Not Supported\n"</span><span class=cF0>);
|
|
<a name="l129"></a> }
|
|
<a name="l130"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l131"></a> </span><span class=cF1>if</span><span class=cF0> (res && _de) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l132"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>StrCmp</span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>->cur_dir,</span><span class=cF6>"/"</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l133"></a> full_name=</span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>"%C:%s/%s"</span><span class=cF0>,
|
|
<a name="l134"></a> </span><span class=cF5>Drv2Let</span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>->cur_dv</span><span class=cF7>)</span><span class=cF0>,</span><span class=cF5>Fs</span><span class=cF0>->cur_dir,de.name);
|
|
<a name="l135"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l136"></a> full_name=</span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>"%C:/%s"</span><span class=cF0>,
|
|
<a name="l137"></a> </span><span class=cF5>Drv2Let</span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>->cur_dv</span><span class=cF7>)</span><span class=cF0>,de.name);
|
|
<a name="l138"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l139"></a> </span><span class=cF5>DirContextDel</span><span class=cF0>(dirc);
|
|
<a name="l140"></a> }
|
|
<a name="l141"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l142"></a> </span><span class=cF1>if</span><span class=cF0> (_de) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l143"></a> </span><span class=cF1>if</span><span class=cF0> (res) {
|
|
<a name="l144"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(_de,&de,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l145"></a> _de->full_name=full_name;
|
|
<a name="l146"></a> } </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l147"></a> </span><span class=cF5>MemSet</span><span class=cF0>(_de,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l148"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l149"></a> </span><span class=cF5>Free</span><span class=cF0>(altname);
|
|
<a name="l150"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l151"></a>}
|
|
</span></pre></body>
|
|
</html>
|