ZealOS/docs/Kernel/BlkDev/DiskStrA.CC.html
TomAwezome 1b75d91002 Fix Mount AHCI Port selection.
Add arg to SATARep to specify drive types to show.
Add checks in AHCIPortInit to verify port signatures, add helper method to get signatures from port.
2021-08-02 16:40:05 -04:00

408 lines
47 KiB
HTML
Executable file

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
<meta name="generator" content="ZealOS V0.13">
<style type="text/css">
body {background-color:#fef1f0;}
.cF0{color:#000000;background-color:#fef1f0;}
.cF1{color:#0148a4;background-color:#fef1f0;}
.cF2{color:#3b7901;background-color:#fef1f0;}
.cF3{color:#057c7e;background-color:#fef1f0;}
.cF4{color:#bb2020;background-color:#fef1f0;}
.cF5{color:#9e42ae;background-color:#fef1f0;}
.cF6{color:#b57901;background-color:#fef1f0;}
.cF7{color:#b2b6af;background-color:#fef1f0;}
.cF8{color:#555753;background-color:#fef1f0;}
.cF9{color:#678fbb;background-color:#fef1f0;}
.cFA{color:#82bc49;background-color:#fef1f0;}
.cFB{color:#0097a2;background-color:#fef1f0;}
.cFC{color:#e26a6a;background-color:#fef1f0;}
.cFD{color:#c671bc;background-color:#fef1f0;}
.cFE{color:#c7ab00;background-color:#fef1f0;}
.cFF{color:#fef1f0;background-color:#fef1f0;}
</style>
</head>
<body>
<pre style="font-family:monospace;font-size:12pt">
<a name="l1"></a><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>FileExtDot</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *src)
<a name="l2"></a>{</span><span class=cF2>//Find dot char in name.</span><span class=cF0>
<a name="l3"></a> </span><span class=cF9>I64</span><span class=cF0> ch;
<a name="l4"></a>
<a name="l5"></a> </span><span class=cF1>while</span><span class=cF0> (ch = *src++)
<a name="l6"></a> </span><span class=cF1>if</span><span class=cF0> (ch == </span><span class=cF6>'.'</span><span class=cF0> &amp;&amp; *src != </span><span class=cF6>'/'</span><span class=cF0> &amp;&amp; *src != </span><span class=cF6>'.'</span><span class=cF0>)
<a name="l7"></a> </span><span class=cF1>return</span><span class=cF0> src - </span><span class=cFE>1</span><span class=cF0>;
<a name="l8"></a>
<a name="l9"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l10"></a>}
<a name="l11"></a>
<a name="l12"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>FileExtRemove</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *src, </span><span class=cF1>U8</span><span class=cF0> *dst=</span><span class=cF3>NULL</span><span class=cF0>)
<a name="l13"></a>{</span><span class=cF2>//Remove filename extension from str.</span><span class=cF0>
<a name="l14"></a> </span><span class=cF1>U8</span><span class=cF0> *ptr;
<a name="l15"></a>
<a name="l16"></a> </span><span class=cF1>if</span><span class=cF0> (ptr = </span><span class=cF5>FileExtDot</span><span class=cF7>(</span><span class=cF0>src</span><span class=cF7>)</span><span class=cF0>)
<a name="l17"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l18"></a> </span><span class=cF1>if</span><span class=cF0> (dst)
<a name="l19"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(dst, ptr + </span><span class=cFE>1</span><span class=cF0>);
<a name="l20"></a> *ptr = </span><span class=cFE>0</span><span class=cF0>;
<a name="l21"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l22"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (dst)
<a name="l23"></a> *dst = </span><span class=cFE>0</span><span class=cF0>;
<a name="l24"></a>
<a name="l25"></a> </span><span class=cF1>return</span><span class=cF0> dst;
<a name="l26"></a>}
<a name="l27"></a>
<a name="l28"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>IsDotC</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *filename)
<a name="l29"></a>{</span><span class=cF2>//Does name end in .C?</span><span class=cF0>
<a name="l30"></a> </span><span class=cF9>I64</span><span class=cF0> i = </span><span class=cF5>StrLen</span><span class=cF0>(filename);
<a name="l31"></a>
<a name="l32"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>StrOcc</span><span class=cF7>(</span><span class=cF0>filename, </span><span class=cF6>'.'</span><span class=cF7>)</span><span class=cF0> &gt; </span><span class=cFE>1</span><span class=cF0> &amp;&amp; filename[i - </span><span class=cFE>1</span><span class=cF0>] == </span><span class=cF6>'C'</span><span class=cF0> &amp;&amp; filename[i - </span><span class=cFE>2</span><span class=cF0>] == </span><span class=cF6>'.'</span><span class=cF0>)
<a name="l33"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l34"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l35"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l36"></a>}
<a name="l37"></a>
<a name="l38"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>FilesFindMatch</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *_test_name,</span><span class=cF1>U8</span><span class=cF0> *files_find_mask,</span><span class=cF9>I64</span><span class=cF0> fuf_flags=</span><span class=cFE>0</span><span class=cF0>)
<a name="l39"></a>{</span><span class=cF2>//Does filename meet </span><a href="https://zeal-operating-system.github.io/ZealOS/Doc/FileUtils.DD.html#l1"><span class=cF4>Files Find</span></a><span class=cF2> mask?</span><span class=cF0>
<a name="l40"></a> </span><span class=cF9>I64</span><span class=cF0> tn_len = </span><span class=cF5>StrLen</span><span class=cF0>(_test_name), mask_len = </span><span class=cF5>StrLen</span><span class=cF0>(files_find_mask);
<a name="l41"></a> </span><span class=cF1>U8</span><span class=cF0> *mask1 = </span><span class=cF5>MAlloc</span><span class=cF0>(mask_len + </span><span class=cFE>1</span><span class=cF0>), *mask2 = </span><span class=cF5>MAlloc</span><span class=cF0>(mask_len + </span><span class=cFE>1</span><span class=cF0>), *ptr, *test_name1, *test_name2;
<a name="l42"></a> </span><span class=cF1>Bool</span><span class=cF0> res = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l43"></a>
<a name="l44"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(mask1,files_find_mask);
<a name="l45"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>StrOcc</span><span class=cF7>(</span><span class=cF0>_test_name, </span><span class=cF6>'/'</span><span class=cF7>)</span><span class=cF0>)
<a name="l46"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l47"></a> test_name1 = </span><span class=cF5>MAlloc</span><span class=cF0>(tn_len + </span><span class=cFE>1</span><span class=cF0>);
<a name="l48"></a> test_name2 = </span><span class=cF5>MAlloc</span><span class=cF0>(tn_len + </span><span class=cFE>1</span><span class=cF0>);
<a name="l49"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(test_name1, _test_name);
<a name="l50"></a> </span><span class=cF5>StrLastRemove</span><span class=cF0>(test_name1, </span><span class=cF6>&quot;/&quot;</span><span class=cF0>, test_name2);
<a name="l51"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l52"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l53"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l54"></a> test_name1 = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l55"></a> test_name2 = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l56"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l57"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l58"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l59"></a> </span><span class=cF5>StrFirstRemove</span><span class=cF0>(mask1, </span><span class=cF6>&quot;;&quot;</span><span class=cF0>, mask2);
<a name="l60"></a> </span><span class=cF1>if</span><span class=cF0> (!test_name2 || </span><span class=cF5>StrOcc</span><span class=cF7>(</span><span class=cF0>mask2, </span><span class=cF6>'/'</span><span class=cF7>)</span><span class=cF0>)
<a name="l61"></a> ptr = _test_name;
<a name="l62"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l63"></a> ptr = test_name2;
<a name="l64"></a> </span><span class=cF1>if</span><span class=cF0> (*mask2)
<a name="l65"></a> {
<a name="l66"></a> </span><span class=cF1>if</span><span class=cF0> (*mask2 == </span><span class=cF6>'!'</span><span class=cF0>)
<a name="l67"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l68"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>WildMatch</span><span class=cF7>(</span><span class=cF0>ptr, mask2 + </span><span class=cFE>1</span><span class=cF7>)</span><span class=cF0>)
<a name="l69"></a> {
<a name="l70"></a> res = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l71"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l72"></a> }
<a name="l73"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l74"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l75"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l76"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>WildMatch</span><span class=cF7>(</span><span class=cF0>ptr, mask2</span><span class=cF7>)</span><span class=cF0>)
<a name="l77"></a> {
<a name="l78"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;fuf_flags, </span><span class=cF3>FUf_JUST_TXT</span><span class=cF7>)</span><span class=cF0> &amp;&amp; !</span><span class=cF5>FilesFindMatch</span><span class=cF7>(</span><span class=cF0>_test_name, </span><span class=cF3>FILEMASK_TXT</span><span class=cF7>)</span><span class=cF0>) </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=cF1>break</span><span class=cF0>;
<a name="l81"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l82"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;fuf_flags, </span><span class=cF3>FUf_JUST_DD</span><span class=cF7>)</span><span class=cF0> &amp;&amp; !</span><span class=cF5>FilesFindMatch</span><span class=cF7>(</span><span class=cF0>_test_name, </span><span class=cF3>FILEMASK_DD</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l83"></a> res = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l84"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l85"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l86"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;fuf_flags, </span><span class=cF3>FUf_JUST_SRC</span><span class=cF7>)</span><span class=cF0> &amp;&amp; !</span><span class=cF5>FilesFindMatch</span><span class=cF7>(</span><span class=cF0>_test_name, </span><span class=cF3>FILEMASK_SRC</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l87"></a> res = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l88"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l89"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l90"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;fuf_flags, </span><span class=cF3>FUf_JUST_AOT</span><span class=cF7>)</span><span class=cF0> &amp;&amp; !</span><span class=cF5>FilesFindMatch</span><span class=cF7>(</span><span class=cF0>_test_name, </span><span class=cF3>FILEMASK_AOT</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l91"></a> res = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l92"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l93"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l94"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;fuf_flags, </span><span class=cF3>FUf_JUST_JIT</span><span class=cF7>)</span><span class=cF0> &amp;&amp; !</span><span class=cF5>FilesFindMatch</span><span class=cF7>(</span><span class=cF0>_test_name, </span><span class=cF3>FILEMASK_JIT</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l95"></a> res = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l96"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l97"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l98"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;fuf_flags, </span><span class=cF3>FUf_JUST_GR</span><span class=cF7>)</span><span class=cF0> &amp;&amp; !</span><span class=cF5>FilesFindMatch</span><span class=cF7>(</span><span class=cF0>_test_name, </span><span class=cF3>FILEMASK_GR</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l99"></a> res = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l100"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l101"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l102"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l103"></a> res = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l104"></a> }
<a name="l105"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l106"></a> }
<a name="l107"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l108"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l109"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l110"></a> </span><span class=cF5>Free</span><span class=cF0>(test_name1);
<a name="l111"></a> </span><span class=cF5>Free</span><span class=cF0>(test_name2);
<a name="l112"></a> </span><span class=cF5>Free</span><span class=cF0>(mask1);
<a name="l113"></a> </span><span class=cF5>Free</span><span class=cF0>(mask2);
<a name="l114"></a>
<a name="l115"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l116"></a>}
<a name="l117"></a>
<a name="l118"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>DirNameAbs</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *_dirname)
<a name="l119"></a>{</span><span class=cF2>//MAlloc absolute dir string with drv letter.</span><span class=cF0>
<a name="l120"></a> </span><span class=cF9>I64</span><span class=cF0> maxlen;
<a name="l121"></a> </span><span class=cF1>U8</span><span class=cF0> drv[</span><span class=cFE>3</span><span class=cF0>], *res, *buf, *buf2, *buf3, *buf4, *dirname, *free_dirname;
<a name="l122"></a>
<a name="l123"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>Fs</span><span class=cF0>-&gt;cur_dir || !*</span><span class=cF5>Fs</span><span class=cF0>-&gt;cur_dir)
<a name="l124"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>StrNew</span><span class=cF0>(_dirname);
<a name="l125"></a> free_dirname=dirname = </span><span class=cF5>MStrUtil</span><span class=cF0>(_dirname, </span><span class=cF3>SUF_REM_LEADING</span><span class=cF0> | </span><span class=cF3>SUF_REM_TRAILING</span><span class=cF0> | </span><span class=cF3>SUF_REM_CTRL_CHARS</span><span class=cF0>);
<a name="l126"></a> *drv = </span><span class=cF5>Drive2Letter</span><span class=cF0>;
<a name="l127"></a> drv[</span><span class=cFE>1</span><span class=cF0>] = </span><span class=cF6>':'</span><span class=cF0>;
<a name="l128"></a> drv[</span><span class=cFE>2</span><span class=cF0>] = </span><span class=cFE>0</span><span class=cF0>;
<a name="l129"></a> </span><span class=cF1>if</span><span class=cF0> (*dirname &amp;&amp; dirname[</span><span class=cFE>1</span><span class=cF0>] == </span><span class=cF6>':'</span><span class=cF0>)
<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> (*dirname == </span><span class=cF6>':'</span><span class=cF0>)
<a name="l132"></a> *drv = </span><span class=cFB>blkdev</span><span class=cF0>.boot_drive_let;
<a name="l133"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (*dirname == </span><span class=cF6>'~'</span><span class=cF0>)
<a name="l134"></a> *drv = *</span><span class=cFB>blkdev</span><span class=cF0>.home_dir;
<a name="l135"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l136"></a> *drv = *dirname;
<a name="l137"></a> dirname = dirname + </span><span class=cFE>2</span><span class=cF0>;
<a name="l138"></a> buf = </span><span class=cF5>StrNew</span><span class=cF0>(</span><span class=cF6>&quot;/&quot;</span><span class=cF0>);
<a name="l139"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l140"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l141"></a> buf = </span><span class=cF5>StrNew</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>-&gt;cur_dir);
<a name="l142"></a> </span><span class=cF1>if</span><span class=cF0> (*dirname == </span><span class=cF6>'/'</span><span class=cF0>)
<a name="l143"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l144"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
<a name="l145"></a> buf = </span><span class=cF5>StrNew</span><span class=cF0>(</span><span class=cF6>&quot;/&quot;</span><span class=cF0>);
<a name="l146"></a> dirname++;
<a name="l147"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l148"></a> buf2 = </span><span class=cF5>StrNew</span><span class=cF0>(dirname);
<a name="l149"></a> maxlen = </span><span class=cF5>StrLen</span><span class=cF0>(buf) + </span><span class=cFE>1</span><span class=cF0> + </span><span class=cF5>StrLen</span><span class=cF0>(buf2) + </span><span class=cFE>1</span><span class=cF0>;
<a name="l150"></a> buf3 = </span><span class=cF5>MAlloc</span><span class=cF0>(maxlen);
<a name="l151"></a> buf4 = </span><span class=cF5>MAlloc</span><span class=cF0>(maxlen);
<a name="l152"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(buf3, buf);
<a name="l153"></a> </span><span class=cF1>while</span><span class=cF0> (*buf2)
<a name="l154"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l155"></a> </span><span class=cF5>StrFirstRemove</span><span class=cF0>(buf2, </span><span class=cF6>&quot;/&quot;</span><span class=cF0>, buf4);
<a name="l156"></a> </span><span class=cF1>if</span><span class=cF0> (!*buf4)
<a name="l157"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(buf3, </span><span class=cF6>&quot;/&quot;</span><span class=cF0>);
<a name="l158"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>StrCompare</span><span class=cF7>(</span><span class=cF0>buf4, </span><span class=cF6>&quot;..&quot;</span><span class=cF7>)</span><span class=cF0>)
<a name="l159"></a> {
<a name="l160"></a> </span><span class=cF5>StrLastRemove</span><span class=cF0>(buf3, </span><span class=cF6>&quot;/&quot;</span><span class=cF0>);
<a name="l161"></a> </span><span class=cF1>if</span><span class=cF0> (!*buf3)
<a name="l162"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(buf3, </span><span class=cF6>&quot;/&quot;</span><span class=cF0>);
<a name="l163"></a> }
<a name="l164"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>StrCompare</span><span class=cF7>(</span><span class=cF0>buf4, </span><span class=cF6>&quot;~&quot;</span><span class=cF7>)</span><span class=cF0>)
<a name="l165"></a> {
<a name="l166"></a> </span><span class=cF5>Free</span><span class=cF0>(buf3);
<a name="l167"></a> buf3 = </span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cFB>blkdev</span><span class=cF0>.home_dir + </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0> + </span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>buf2</span><span class=cF7>)</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0>);
<a name="l168"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(buf3, </span><span class=cFB>blkdev</span><span class=cF0>.home_dir + </span><span class=cFE>2</span><span class=cF0>);
<a name="l169"></a> *drv = *</span><span class=cFB>blkdev</span><span class=cF0>.home_dir;
<a name="l170"></a> }
<a name="l171"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>StrCompare</span><span class=cF7>(</span><span class=cF0>buf4, </span><span class=cF6>&quot;.&quot;</span><span class=cF7>)</span><span class=cF0>);
<a name="l172"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (*buf4)
<a name="l173"></a> {
<a name="l174"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>StrCompare</span><span class=cF7>(</span><span class=cF0>buf3, </span><span class=cF6>&quot;/&quot;</span><span class=cF7>)</span><span class=cF0>)
<a name="l175"></a> </span><span class=cF5>CatPrint</span><span class=cF0>(buf3, </span><span class=cF6>&quot;/&quot;</span><span class=cF0>);
<a name="l176"></a> </span><span class=cF5>CatPrint</span><span class=cF0>(buf3, buf4);
<a name="l177"></a> }
<a name="l178"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l179"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
<a name="l180"></a> res = </span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>buf3</span><span class=cF7>)</span><span class=cF0> + </span><span class=cFE>3</span><span class=cF0>);
<a name="l181"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(res, drv);
<a name="l182"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(res + </span><span class=cFE>2</span><span class=cF0>, buf3);
<a name="l183"></a> </span><span class=cF5>Free</span><span class=cF0>(buf2);
<a name="l184"></a> </span><span class=cF5>Free</span><span class=cF0>(buf3);
<a name="l185"></a> </span><span class=cF5>Free</span><span class=cF0>(buf4);
<a name="l186"></a> </span><span class=cF5>Free</span><span class=cF0>(free_dirname);
<a name="l187"></a>
<a name="l188"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l189"></a>}
<a name="l190"></a>
<a name="l191"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>FileNameAbs</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *_filename, </span><span class=cF9>I64</span><span class=cF0> fuf_flags=</span><span class=cF3>NONE</span><span class=cF0>)
<a name="l192"></a>{</span><span class=cF2>//Absolute filename. Accepts </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l3270"><span class=cF4>FUF_SCAN_PARENTS</span></a><span class=cF2>.</span><span class=cF0>
<a name="l193"></a> </span><span class=cF1>U8</span><span class=cF0> *res, *filename, *buf, *buf_file, *buf_dir, *free_filename, *free_buf;
<a name="l194"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> de;
<a name="l195"></a>
<a name="l196"></a> free_filename = filename = </span><span class=cF5>MStrUtil</span><span class=cF0>(_filename, </span><span class=cF3>SUF_REM_LEADING</span><span class=cF0> | </span><span class=cF3>SUF_REM_TRAILING</span><span class=cF0> | </span><span class=cF3>SUF_REM_CTRL_CHARS</span><span class=cF0>);
<a name="l197"></a> free_buf = buf = </span><span class=cF5>StrNew</span><span class=cF0>(filename);
<a name="l198"></a> </span><span class=cF1>if</span><span class=cF0> (*buf &amp;&amp; buf[</span><span class=cFE>1</span><span class=cF0>] == </span><span class=cF6>':'</span><span class=cF0>)
<a name="l199"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l200"></a> buf += </span><span class=cFE>2</span><span class=cF0>;
<a name="l201"></a> filename += </span><span class=cFE>2</span><span class=cF0>;
<a name="l202"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l203"></a> buf_file = </span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>free_filename</span><span class=cF7>)</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0>);
<a name="l204"></a> </span><span class=cF5>StrLastRemove</span><span class=cF0>(buf, </span><span class=cF6>&quot;/&quot;</span><span class=cF0>, buf_file);
<a name="l205"></a> </span><span class=cF1>if</span><span class=cF0> (*filename == </span><span class=cF6>'/'</span><span class=cF0> &amp;&amp; !*buf)
<a name="l206"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(buf, </span><span class=cF6>&quot;/&quot;</span><span class=cF0>);
<a name="l207"></a> buf_dir = </span><span class=cF5>DirNameAbs</span><span class=cF0>(free_buf);
<a name="l208"></a> </span><span class=cF5>Free</span><span class=cF0>(free_buf);
<a name="l209"></a> res = </span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>buf_dir</span><span class=cF7>)</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0> + </span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>buf_file</span><span class=cF7>)</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0>);
<a name="l210"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(res, buf_dir);
<a name="l211"></a> </span><span class=cF1>if</span><span class=cF0> (res[</span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>res</span><span class=cF7>)</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>] != </span><span class=cF6>'/'</span><span class=cF0>)
<a name="l212"></a> </span><span class=cF5>CatPrint</span><span class=cF0>(res, </span><span class=cF6>&quot;/&quot;</span><span class=cF0>);
<a name="l213"></a> </span><span class=cF5>CatPrint</span><span class=cF0>(res, buf_file);
<a name="l214"></a> </span><span class=cF5>Free</span><span class=cF0>(buf_file);
<a name="l215"></a> </span><span class=cF5>Free</span><span class=cF0>(buf_dir);
<a name="l216"></a> </span><span class=cF5>Free</span><span class=cF0>(free_filename);
<a name="l217"></a> </span><span class=cF1>if</span><span class=cF0> (fuf_flags &amp;&amp; </span><span class=cF5>FileFind</span><span class=cF7>(</span><span class=cF0>res, &amp;de, fuf_flags | </span><span class=cF3>FUF_JUST_FILES</span><span class=cF7>)</span><span class=cF0>)
<a name="l218"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l219"></a> </span><span class=cF5>Free</span><span class=cF0>(res);
<a name="l220"></a> res = de.full_name;
<a name="l221"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l222"></a>
<a name="l223"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l224"></a>}
<a name="l225"></a>
<a name="l226"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>ExtChange</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *filename, </span><span class=cF1>U8</span><span class=cF0> *extension)
<a name="l227"></a>{</span><span class=cF2>//Change filename extension.</span><span class=cF0>
<a name="l228"></a> </span><span class=cF1>U8</span><span class=cF0> *res = </span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>filename</span><span class=cF7>)</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0> + </span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>extension</span><span class=cF7>)</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0>);
<a name="l229"></a>
<a name="l230"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(res, filename);
<a name="l231"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>FileExtDot</span><span class=cF7>(</span><span class=cF0>filename</span><span class=cF7>)</span><span class=cF0>)
<a name="l232"></a> </span><span class=cF5>FileExtRemove</span><span class=cF0>(res);
<a name="l233"></a>
<a name="l234"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>CatPrint</span><span class=cF0>(res, </span><span class=cF6>&quot;.%s&quot;</span><span class=cF0>, extension);
<a name="l235"></a>}
<a name="l236"></a>
<a name="l237"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>ExtDefault</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *filename, </span><span class=cF1>U8</span><span class=cF0> *extension)
<a name="l238"></a>{</span><span class=cF2>//Give extension if has none.</span><span class=cF0>
<a name="l239"></a> </span><span class=cF1>U8</span><span class=cF0> *res = </span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>filename</span><span class=cF7>)</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0> + </span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>extension</span><span class=cF7>)</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0>);
<a name="l240"></a>
<a name="l241"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(res, filename);
<a name="l242"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>FileExtDot</span><span class=cF7>(</span><span class=cF0>filename</span><span class=cF7>)</span><span class=cF0>)
<a name="l243"></a> </span><span class=cF5>CatPrint</span><span class=cF0>(res, </span><span class=cF6>&quot;.%s&quot;</span><span class=cF0>, extension);
<a name="l244"></a>
<a name="l245"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l246"></a>}
<a name="l247"></a>
<a name="l248"></a></span><span class=cF9>CDirEntry</span><span class=cF0> *</span><span class=cF5>Cd2DirEntry</span><span class=cF0>(</span><span class=cF9>CDirEntry</span><span class=cF0> *tmpde, </span><span class=cF1>U8</span><span class=cF0> *abs_name)
<a name="l249"></a>{
<a name="l250"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l251"></a>
<a name="l252"></a> </span><span class=cF1>while</span><span class=cF0> (tmpde)
<a name="l253"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l254"></a> i = </span><span class=cF5>StrLen</span><span class=cF0>(tmpde-&gt;full_name);
<a name="l255"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>StrNCompare</span><span class=cF7>(</span><span class=cF0>tmpde-&gt;full_name, abs_name, i</span><span class=cF7>)</span><span class=cF0> ||
<a name="l256"></a> i &amp;&amp; tmpde-&gt;full_name[i - </span><span class=cFE>1</span><span class=cF0>] != </span><span class=cF6>'/'</span><span class=cF0> &amp;&amp;
<a name="l257"></a> abs_name[i] &amp;&amp;
<a name="l258"></a> abs_name[i] != </span><span class=cF6>'/'</span><span class=cF0>)
<a name="l259"></a> tmpde = tmpde-&gt;next;
<a name="l260"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l261"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>abs_name</span><span class=cF7>)</span><span class=cF0> == i)
<a name="l262"></a> </span><span class=cF1>return</span><span class=cF0> tmpde;
<a name="l263"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l264"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>Cd2DirEntry</span><span class=cF0>(tmpde-&gt;sub, abs_name);
<a name="l265"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l266"></a>
<a name="l267"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l268"></a>}
<a name="l269"></a>
<a name="l270"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>FileAttr</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *name, </span><span class=cF9>I64</span><span class=cF0> attr=</span><span class=cFE>0</span><span class=cF0>)
<a name="l271"></a>{
<a name="l272"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>IsDotC</span><span class=cF7>(</span><span class=cF0>name</span><span class=cF7>)</span><span class=cF0>)
<a name="l273"></a> attr |= </span><span class=cF3>RS_ATTR_CONTIGUOUS</span><span class=cF0>;
<a name="l274"></a>
<a name="l275"></a> </span><span class=cF1>return</span><span class=cF0> attr;
<a name="l276"></a>}
<a name="l277"></a>
<a name="l278"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>FileNameCheck</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *filename)
<a name="l279"></a>{</span><span class=cF2>//Return check for valid filename, not checking existence.</span><span class=cF0>
<a name="l280"></a> </span><span class=cF1>U8</span><span class=cF0> *ptr = filename;
<a name="l281"></a>
<a name="l282"></a> </span><span class=cF1>if</span><span class=cF0> (!filename)
<a name="l283"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l284"></a> </span><span class=cF1>if</span><span class=cF0> (!*ptr)
<a name="l285"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l286"></a> </span><span class=cF1>if</span><span class=cF0> (*ptr == </span><span class=cF6>'.'</span><span class=cF0>)
<a name="l287"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l288"></a> </span><span class=cF1>if</span><span class=cF0> (!ptr[</span><span class=cFE>1</span><span class=cF0>])
<a name="l289"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l290"></a> </span><span class=cF1>if</span><span class=cF0> (ptr[</span><span class=cFE>1</span><span class=cF0>] == </span><span class=cF6>'.'</span><span class=cF0> &amp;&amp; !ptr[</span><span class=cFE>2</span><span class=cF0>])
<a name="l291"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l292"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l293"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>filename</span><span class=cF7>)</span><span class=cF0> &gt;= </span><span class=cF3>CDIR_FILENAME_LEN</span><span class=cF0>)
<a name="l294"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l295"></a> </span><span class=cF1>while</span><span class=cF0> (*ptr)
<a name="l296"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cFB>char_bmp_filename</span><span class=cF0>, *ptr++</span><span class=cF7>)</span><span class=cF0>)
<a name="l297"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l298"></a>
<a name="l299"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l300"></a>}
<a name="l301"></a>
<a name="l302"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>FileNameTmpTxt</span><span class=cF0>()
<a name="l303"></a>{</span><span class=cF2>//Make pretty-safe tmp filename in home dir.</span><span class=cF0>
<a name="l304"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>&quot;~/SysTmp%X.DD&quot;</span><span class=cF0>, </span><span class=cF5>TSCGet</span><span class=cF0> &gt;&gt; </span><span class=cFE>8</span><span class=cF0> &amp; </span><span class=cFE>0xFFFFFFFF</span><span class=cF0>);
<a name="l305"></a>}
<a name="l306"></a>
<a name="l307"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>DirCur</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task=</span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF9>CTask</span><span class=cF0> *mem_task=</span><span class=cF3>NULL</span><span class=cF0>)
<a name="l308"></a>{</span><span class=cF2>//MAlloc copy of cur dir with drv letter.</span><span class=cF0>
<a name="l309"></a> </span><span class=cF1>U8</span><span class=cF0> *st;
<a name="l310"></a>
<a name="l311"></a> </span><span class=cF1>if</span><span class=cF0> (!task)
<a name="l312"></a> task = </span><span class=cF5>Fs</span><span class=cF0>;
<a name="l313"></a> </span><span class=cF1>if</span><span class=cF0> (!task-&gt;cur_dir)
<a name="l314"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l315"></a> st = </span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>task-&gt;cur_dir</span><span class=cF7>)</span><span class=cF0> + </span><span class=cFE>3</span><span class=cF0>, mem_task);
<a name="l316"></a> *st = </span><span class=cF5>Drive2Letter</span><span class=cF0>(task-&gt;cur_dv);
<a name="l317"></a> st[</span><span class=cFE>1</span><span class=cF0>] = </span><span class=cF6>':'</span><span class=cF0>;
<a name="l318"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(st + </span><span class=cFE>2</span><span class=cF0>, task-&gt;cur_dir);
<a name="l319"></a>
<a name="l320"></a> </span><span class=cF1>return</span><span class=cF0> st;
<a name="l321"></a>}
<a name="l322"></a>
<a name="l323"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>DirFile</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *dirname, </span><span class=cF1>U8</span><span class=cF0> *name=</span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF1>U8</span><span class=cF0> *_extension=</span><span class=cF3>NULL</span><span class=cF0>)
<a name="l324"></a>{</span><span class=cF2>/*Strips file from dirname, scans for file upward until found or</span><span class=cF0>
<a name="l325"></a></span><span class=cF2>returns default.</span><span class=cF0>
<a name="l326"></a>
<a name="l327"></a></span><span class=cF2>(&quot;/Kernel/KHashA.CC&quot;,NULL,NULL) returns &quot;D:/Kernel&quot;</span><span class=cF0>
<a name="l328"></a></span><span class=cF2>(&quot;/Kernel&quot;,NULL,&quot;PRJ&quot;)</span><span class=cF0> </span><span class=cF2>returns &quot;D:/Kernel/Kernel.PRJ&quot;</span><span class=cF0>
<a name="l329"></a></span><span class=cF2>(&quot;/Kernel/BlkDev&quot;,NULL,&quot;PRJ&quot;) </span><span class=cF0> </span><span class=cF2>returns &quot;D:/Kernel/Kernel.PRJ&quot;</span><span class=cF0>
<a name="l330"></a></span><span class=cF2>(&quot;/Apps/Psalmody&quot;,&quot;Load&quot;,&quot;CC&quot;)</span><span class=cF0> </span><span class=cF2>returns &quot;D:/Apps/Psalmody/Load.CC&quot;</span><span class=cF0>
<a name="l331"></a></span><span class=cF2>*/</span><span class=cF0>
<a name="l332"></a> </span><span class=cF1>U8</span><span class=cF0> *st = </span><span class=cF5>DirNameAbs</span><span class=cF0>(dirname), *st2, *st3, *res, *</span><span class=cF1>default</span><span class=cF0> = </span><span class=cF3>NULL</span><span class=cF0>, *</span><span class=cFB>ext</span><span class=cF0>;
<a name="l333"></a>
<a name="l334"></a> </span><span class=cF1>if</span><span class=cF0> (_extension &amp;&amp; *_extension)
<a name="l335"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l336"></a> </span><span class=cF1>if</span><span class=cF0> (*_extension == </span><span class=cF6>'.'</span><span class=cF0>)
<a name="l337"></a> </span><span class=cFB>ext</span><span class=cF0> = </span><span class=cF5>StrNew</span><span class=cF0>(_extension);
<a name="l338"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l339"></a> </span><span class=cFB>ext</span><span class=cF0> = </span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>&quot;.%s&quot;</span><span class=cF0>, _extension);
<a name="l340"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l341"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l342"></a> </span><span class=cFB>ext</span><span class=cF0> = </span><span class=cF5>StrNew</span><span class=cF0>(</span><span class=cF6>&quot;&quot;</span><span class=cF0>);
<a name="l343"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>StrOcc</span><span class=cF7>(</span><span class=cF0>st, </span><span class=cF6>'/'</span><span class=cF7>)</span><span class=cF0> &amp;&amp; !</span><span class=cF5>IsDir</span><span class=cF7>(</span><span class=cF0>st</span><span class=cF7>)</span><span class=cF0>)
<a name="l344"></a> </span><span class=cF5>StrLastRemove</span><span class=cF0>(st, </span><span class=cF6>&quot;/&quot;</span><span class=cF0>);
<a name="l345"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>StrOcc</span><span class=cF7>(</span><span class=cF0>st, </span><span class=cF6>'/'</span><span class=cF7>)</span><span class=cF0>)
<a name="l346"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l347"></a> st2 = </span><span class=cF5>StrNew</span><span class=cF0>(st);
<a name="l348"></a> st3 = </span><span class=cF5>StrNew</span><span class=cF0>(st);
<a name="l349"></a> </span><span class=cF5>StrLastRemove</span><span class=cF0>(st2, </span><span class=cF6>&quot;/&quot;</span><span class=cF0>, st3);
<a name="l350"></a>
<a name="l351"></a> </span><span class=cF1>if</span><span class=cF0> (name)
<a name="l352"></a> res = </span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>&quot;%s/%s%s&quot;</span><span class=cF0>, st, name, </span><span class=cFB>ext</span><span class=cF0>);
<a name="l353"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l354"></a> {
<a name="l355"></a> </span><span class=cF1>if</span><span class=cF0> (*</span><span class=cFB>ext</span><span class=cF0>)
<a name="l356"></a> res = </span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>&quot;%s/%s%s&quot;</span><span class=cF0>, st, st3, </span><span class=cFB>ext</span><span class=cF0>);
<a name="l357"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l358"></a> res = </span><span class=cF5>StrNew</span><span class=cF0>(st);
<a name="l359"></a> }
<a name="l360"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF1>default</span><span class=cF0>)
<a name="l361"></a> </span><span class=cF1>default</span><span class=cF0> = </span><span class=cF5>StrNew</span><span class=cF0>(res);
<a name="l362"></a> </span><span class=cF1>if</span><span class=cF0> (!*</span><span class=cFB>ext</span><span class=cF0> &amp;&amp; </span><span class=cF7>(</span><span class=cF0>!name || !*name</span><span class=cF7>)</span><span class=cF0> || </span><span class=cF5>FileFind</span><span class=cF7>(</span><span class=cF0>res</span><span class=cF7>)</span><span class=cF0>)
<a name="l363"></a> {
<a name="l364"></a> </span><span class=cF5>Free</span><span class=cF0>(st3);
<a name="l365"></a> </span><span class=cF5>Free</span><span class=cF0>(st2);
<a name="l366"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
<a name="l367"></a> </span><span class=cF5>Free</span><span class=cF0>(</span><span class=cF1>default</span><span class=cF0>);
<a name="l368"></a> </span><span class=cF5>Free</span><span class=cF0>(</span><span class=cFB>ext</span><span class=cF0>);
<a name="l369"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l370"></a> }
<a name="l371"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
<a name="l372"></a> st = st2;
<a name="l373"></a> </span><span class=cF5>Free</span><span class=cF0>(st3);
<a name="l374"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l375"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
<a name="l376"></a> </span><span class=cF5>Free</span><span class=cF0>(</span><span class=cFB>ext</span><span class=cF0>);
<a name="l377"></a>
<a name="l378"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF1>default</span><span class=cF0>;
<a name="l379"></a>}
</span></pre></body>
</html>