375 lines
44 KiB
Plaintext
375 lines
44 KiB
Plaintext
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<meta charset="UTF-8">
|
||
|
<meta name="generator" content="TempleOS V5.03">
|
||
|
<meta name="viewport" content="width=device-width">
|
||
|
<link rel="stylesheet" href="/style/templeos.css">
|
||
|
<script src="/script/templeos.js"></script>
|
||
|
<style type="text/css">
|
||
|
.cF0{color:#000000;background-color:#ffffff;}
|
||
|
.cF1{color:#0000aa;background-color:#ffffff;}
|
||
|
.cF2{color:#00aa00;background-color:#ffffff;}
|
||
|
.cF3{color:#00aaaa;background-color:#ffffff;}
|
||
|
.cF4{color:#aa0000;background-color:#ffffff;}
|
||
|
.cF5{color:#aa00aa;background-color:#ffffff;}
|
||
|
.cF6{color:#aa5500;background-color:#ffffff;}
|
||
|
.cF7{color:#aaaaaa;background-color:#ffffff;}
|
||
|
.cF8{color:#555555;background-color:#ffffff;}
|
||
|
.cF9{color:#5555ff;background-color:#ffffff;}
|
||
|
.cFA{color:#55ff55;background-color:#ffffff;}
|
||
|
.cFB{color:#55ffff;background-color:#ffffff;}
|
||
|
.cFC{color:#ff5555;background-color:#ffffff;}
|
||
|
.cFD{color:#ff55ff;background-color:#ffffff;}
|
||
|
.cFE{color:#ffff55;background-color:#ffffff;}
|
||
|
.cFF{color:#ffffff;background-color:#ffffff;}
|
||
|
</style>
|
||
|
</head>
|
||
|
<body>
|
||
|
<pre id="content">
|
||
|
<a name="l1"></a><span class=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> </span><span class=cF1>while</span><span class=cF0> (ch=*src++)
|
||
|
<a name="l5"></a> </span><span class=cF1>if</span><span class=cF0> (ch==</span><span class=cF6>'.'</span><span class=cF0> && *src!=</span><span class=cF6>'/'</span><span class=cF0> && *src!=</span><span class=cF6>'.'</span><span class=cF0>)
|
||
|
<a name="l6"></a> </span><span class=cF1>return</span><span class=cF0> src-1;
|
||
|
<a name="l7"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
|
||
|
<a name="l8"></a>}
|
||
|
<a name="l9"></a>
|
||
|
<a name="l10"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>FileExtRem</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="l11"></a>{</span><span class=cF2>//Remove filename extension from str.</span><span class=cF0>
|
||
|
<a name="l12"></a> </span><span class=cF1>U8</span><span class=cF0> *ptr;
|
||
|
<a name="l13"></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>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l14"></a> </span><span class=cF1>if</span><span class=cF0> (dst)
|
||
|
<a name="l15"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(dst,ptr+1);
|
||
|
<a name="l16"></a> *ptr=0;
|
||
|
<a name="l17"></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> (dst)
|
||
|
<a name="l18"></a> *dst=0;
|
||
|
<a name="l19"></a> </span><span class=cF1>return</span><span class=cF0> dst;
|
||
|
<a name="l20"></a>}
|
||
|
<a name="l21"></a>
|
||
|
<a name="l22"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>IsDotZ</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *filename)
|
||
|
<a name="l23"></a>{</span><span class=cF2>//Does name end in .Z?</span><span class=cF0>
|
||
|
<a name="l24"></a> </span><span class=cF9>I64</span><span class=cF0> i=</span><span class=cF5>StrLen</span><span class=cF0>(filename);
|
||
|
<a name="l25"></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>>1 && filename[i-1]==</span><span class=cF6>'Z'</span><span class=cF0> && filename[i-2]==</span><span class=cF6>'.'</span><span class=cF0>)
|
||
|
<a name="l26"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l27"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l28"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l29"></a>}
|
||
|
<a name="l30"></a>
|
||
|
<a name="l31"></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="l32"></a>{</span><span class=cF2>//Does name end in .C?</span><span class=cF0>
|
||
|
<a name="l33"></a> </span><span class=cF9>I64</span><span class=cF0> i=</span><span class=cF5>StrLen</span><span class=cF0>(filename);
|
||
|
<a name="l34"></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>>1 && filename[i-1]==</span><span class=cF6>'C'</span><span class=cF0> && filename[i-2]==</span><span class=cF6>'.'</span><span class=cF0>)
|
||
|
<a name="l35"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l36"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l37"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l38"></a>}
|
||
|
<a name="l39"></a>
|
||
|
<a name="l40"></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=0)
|
||
|
<a name="l41"></a>{</span><span class=cF2>//Does filename meet </span><a href="/Wb/Doc/FileUtils.DD.HTML#l1"><span class=cF4>Files Find</span></a><span class=cF2> mask?</span><span class=cF0>
|
||
|
<a name="l42"></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="l43"></a> </span><span class=cF1>U8</span><span class=cF0> *mask1=</span><span class=cF5>MAlloc</span><span class=cF0>(mask_len+1),*mask2=</span><span class=cF5>MAlloc</span><span class=cF0>(mask_len+1),
|
||
|
<a name="l44"></a> *ptr,*test_name1,*test_name2;
|
||
|
<a name="l45"></a> </span><span class=cF1>Bool</span><span class=cF0> res=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l46"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(mask1,files_find_mask);
|
||
|
<a name="l47"></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>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l48"></a> test_name1=</span><span class=cF5>MAlloc</span><span class=cF0>(tn_len+1);
|
||
|
<a name="l49"></a> test_name2=</span><span class=cF5>MAlloc</span><span class=cF0>(tn_len+1);
|
||
|
<a name="l50"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(test_name1,_test_name);
|
||
|
<a name="l51"></a> </span><span class=cF5>StrLastRem</span><span class=cF0>(test_name1,</span><span class=cF6>"/"</span><span class=cF0>,test_name2);
|
||
|
<a name="l52"></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="l53"></a> test_name1=</span><span class=cF3>NULL</span><span class=cF0>;
|
||
|
<a name="l54"></a> test_name2=</span><span class=cF3>NULL</span><span class=cF0>;
|
||
|
<a name="l55"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l56"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l57"></a> </span><span class=cF5>StrFirstRem</span><span class=cF0>(mask1,</span><span class=cF6>";"</span><span class=cF0>,mask2);
|
||
|
<a name="l58"></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="l59"></a> ptr=_test_name;
|
||
|
<a name="l60"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l61"></a> ptr=test_name2;
|
||
|
<a name="l62"></a> </span><span class=cF1>if</span><span class=cF0> (*mask2) {
|
||
|
<a name="l63"></a> </span><span class=cF1>if</span><span class=cF0> (*mask2==</span><span class=cF6>'!'</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l64"></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+1</span><span class=cF7>)</span><span class=cF0>) {
|
||
|
<a name="l65"></a> res=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l66"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l67"></a> }
|
||
|
<a name="l68"></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="l69"></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="l70"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&fuf_flags,</span><span class=cF3>FUf_JUST_TXT</span><span class=cF7>)</span><span class=cF0> &&
|
||
|
<a name="l71"></a> !</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="l72"></a> res=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l73"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l74"></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> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&fuf_flags,</span><span class=cF3>FUf_JUST_DD</span><span class=cF7>)</span><span class=cF0> &&
|
||
|
<a name="l75"></a> !</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="l76"></a> res=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l77"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l78"></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> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&fuf_flags,</span><span class=cF3>FUf_JUST_SRC</span><span class=cF7>)</span><span class=cF0> &&
|
||
|
<a name="l79"></a> !</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="l80"></a> res=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l81"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l82"></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> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&fuf_flags,</span><span class=cF3>FUf_JUST_AOT</span><span class=cF7>)</span><span class=cF0> &&
|
||
|
<a name="l83"></a> !</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="l84"></a> res=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l85"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l86"></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> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&fuf_flags,</span><span class=cF3>FUf_JUST_JIT</span><span class=cF7>)</span><span class=cF0> &&
|
||
|
<a name="l87"></a> !</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="l88"></a> res=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l89"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l90"></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> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&fuf_flags,</span><span class=cF3>FUf_JUST_GR</span><span class=cF7>)</span><span class=cF0> &&
|
||
|
<a name="l91"></a> !</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="l92"></a> res=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l93"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l94"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l95"></a> res=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l96"></a> }
|
||
|
<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>
|
||
|
<a name="l99"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l100"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l101"></a> </span><span class=cF5>Free</span><span class=cF0>(test_name1);
|
||
|
<a name="l102"></a> </span><span class=cF5>Free</span><span class=cF0>(test_name2);
|
||
|
<a name="l103"></a> </span><span class=cF5>Free</span><span class=cF0>(mask1);
|
||
|
<a name="l104"></a> </span><span class=cF5>Free</span><span class=cF0>(mask2);
|
||
|
<a name="l105"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
||
|
<a name="l106"></a>}
|
||
|
<a name="l107"></a>
|
||
|
<a name="l108"></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="l109"></a>{</span><span class=cF2>//MAlloc absolute dir string with drv letter.</span><span class=cF0>
|
||
|
<a name="l110"></a> </span><span class=cF9>I64</span><span class=cF0> maxlen;
|
||
|
<a name="l111"></a> </span><span class=cF1>U8</span><span class=cF0> drv[3],*res,*buf,*buf2,*buf3,*buf4,*dirname,*free_dirname;
|
||
|
<a name="l112"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>Fs</span><span class=cF0>->cur_dir || !*</span><span class=cF5>Fs</span><span class=cF0>->cur_dir)
|
||
|
<a name="l113"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>StrNew</span><span class=cF0>(_dirname);
|
||
|
<a name="l114"></a> free_dirname=dirname=</span><span class=cF5>MStrUtil</span><span class=cF0>(_dirname,
|
||
|
<a name="l115"></a> </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="l116"></a> *drv=</span><span class=cF5>Drv2Let</span><span class=cF0>;
|
||
|
<a name="l117"></a> drv[1]=</span><span class=cF6>':'</span><span class=cF0>;
|
||
|
<a name="l118"></a> drv[2]=0;
|
||
|
<a name="l119"></a> </span><span class=cF1>if</span><span class=cF0> (*dirname && dirname[1]==</span><span class=cF6>':'</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l120"></a> </span><span class=cF1>if</span><span class=cF0> (*dirname==</span><span class=cF6>':'</span><span class=cF0>)
|
||
|
<a name="l121"></a> *drv=</span><span class=cFB>blkdev</span><span class=cF0>.boot_drv_let;
|
||
|
<a name="l122"></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="l123"></a> *drv=*</span><span class=cFB>blkdev</span><span class=cF0>.home_dir;
|
||
|
<a name="l124"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l125"></a> *drv=*dirname;
|
||
|
<a name="l126"></a> dirname=dirname+2;
|
||
|
<a name="l127"></a> buf=</span><span class=cF5>StrNew</span><span class=cF0>(</span><span class=cF6>"/"</span><span class=cF0>);
|
||
|
<a name="l128"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l129"></a> buf=</span><span class=cF5>StrNew</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>->cur_dir);
|
||
|
<a name="l130"></a> </span><span class=cF1>if</span><span class=cF0> (*dirname==</span><span class=cF6>'/'</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l131"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
|
||
|
<a name="l132"></a> buf=</span><span class=cF5>StrNew</span><span class=cF0>(</span><span class=cF6>"/"</span><span class=cF0>);
|
||
|
<a name="l133"></a> dirname++;
|
||
|
<a name="l134"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l135"></a> buf2=</span><span class=cF5>StrNew</span><span class=cF0>(dirname);
|
||
|
<a name="l136"></a> maxlen=</span><span class=cF5>StrLen</span><span class=cF0>(buf)+1+</span><span class=cF5>StrLen</span><span class=cF0>(buf2)+1;
|
||
|
<a name="l137"></a> buf3=</span><span class=cF5>MAlloc</span><span class=cF0>(maxlen);
|
||
|
<a name="l138"></a> buf4=</span><span class=cF5>MAlloc</span><span class=cF0>(maxlen);
|
||
|
<a name="l139"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(buf3,buf);
|
||
|
<a name="l140"></a> </span><span class=cF1>while</span><span class=cF0> (*buf2) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l141"></a> </span><span class=cF5>StrFirstRem</span><span class=cF0>(buf2,</span><span class=cF6>"/"</span><span class=cF0>,buf4);
|
||
|
<a name="l142"></a> </span><span class=cF1>if</span><span class=cF0> (!*buf4)
|
||
|
<a name="l143"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(buf3,</span><span class=cF6>"/"</span><span class=cF0>);
|
||
|
<a name="l144"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>StrCmp</span><span class=cF7>(</span><span class=cF0>buf4,</span><span class=cF6>".."</span><span class=cF7>)</span><span class=cF0>) {
|
||
|
<a name="l145"></a> </span><span class=cF5>StrLastRem</span><span class=cF0>(buf3,</span><span class=cF6>"/"</span><span class=cF0>);
|
||
|
<a name="l146"></a> </span><span class=cF1>if</span><span class=cF0> (!*buf3)
|
||
|
<a name="l147"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(buf3,</span><span class=cF6>"/"</span><span class=cF0>);
|
||
|
<a name="l148"></a> } </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>StrCmp</span><span class=cF7>(</span><span class=cF0>buf4,</span><span class=cF6>"~"</span><span class=cF7>)</span><span class=cF0>) {
|
||
|
<a name="l149"></a> </span><span class=cF5>Free</span><span class=cF0>(buf3);
|
||
|
<a name="l150"></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+2</span><span class=cF7>)</span><span class=cF0>+1+</span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>buf2</span><span class=cF7>)</span><span class=cF0>+1);
|
||
|
<a name="l151"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(buf3,</span><span class=cFB>blkdev</span><span class=cF0>.home_dir+2);
|
||
|
<a name="l152"></a> *drv=*</span><span class=cFB>blkdev</span><span class=cF0>.home_dir;
|
||
|
<a name="l153"></a> } </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>StrCmp</span><span class=cF7>(</span><span class=cF0>buf4,</span><span class=cF6>"."</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l154"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (*buf4) {
|
||
|
<a name="l155"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>StrCmp</span><span class=cF7>(</span><span class=cF0>buf3,</span><span class=cF6>"/"</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l156"></a> </span><span class=cF5>CatPrint</span><span class=cF0>(buf3,</span><span class=cF6>"/"</span><span class=cF0>);
|
||
|
<a name="l157"></a> </span><span class=cF5>CatPrint</span><span class=cF0>(buf3,buf4);
|
||
|
<a name="l158"></a> }
|
||
|
<a name="l159"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l160"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
|
||
|
<a name="l161"></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>+3);
|
||
|
<a name="l162"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(res,drv);
|
||
|
<a name="l163"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(res+2,buf3);
|
||
|
<a name="l164"></a> </span><span class=cF5>Free</span><span class=cF0>(buf2);
|
||
|
<a name="l165"></a> </span><span class=cF5>Free</span><span class=cF0>(buf3);
|
||
|
<a name="l166"></a> </span><span class=cF5>Free</span><span class=cF0>(buf4);
|
||
|
<a name="l167"></a> </span><span class=cF5>Free</span><span class=cF0>(free_dirname);
|
||
|
<a name="l168"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
||
|
<a name="l169"></a>}
|
||
|
<a name="l170"></a>
|
||
|
<a name="l171"></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=0)
|
||
|
<a name="l172"></a>{</span><span class=cF2>//Absolute filename. Accepts </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=cF2>.</span><span class=cF0>
|
||
|
<a name="l173"></a> </span><span class=cF1>U8</span><span class=cF0> *res,*filename,*buf,*buf_file,*buf_dir,*free_filename,*free_buf;
|
||
|
<a name="l174"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> de;
|
||
|
<a name="l175"></a> free_filename=filename=</span><span class=cF5>MStrUtil</span><span class=cF0>(_filename,
|
||
|
<a name="l176"></a> </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="l177"></a> free_buf=buf=</span><span class=cF5>StrNew</span><span class=cF0>(filename);
|
||
|
<a name="l178"></a> </span><span class=cF1>if</span><span class=cF0> (*buf && buf[1]==</span><span class=cF6>':'</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l179"></a> buf+=2;
|
||
|
<a name="l180"></a> filename+=2;
|
||
|
<a name="l181"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l182"></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>+1);
|
||
|
<a name="l183"></a> </span><span class=cF5>StrLastRem</span><span class=cF0>(buf,</span><span class=cF6>"/"</span><span class=cF0>,buf_file);
|
||
|
<a name="l184"></a> </span><span class=cF1>if</span><span class=cF0> (*filename==</span><span class=cF6>'/'</span><span class=cF0> && !*buf)
|
||
|
<a name="l185"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(buf,</span><span class=cF6>"/"</span><span class=cF0>);
|
||
|
<a name="l186"></a> buf_dir=</span><span class=cF5>DirNameAbs</span><span class=cF0>(free_buf);
|
||
|
<a name="l187"></a> </span><span class=cF5>Free</span><span class=cF0>(free_buf);
|
||
|
<a name="l188"></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>+1+</span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>buf_file</span><span class=cF7>)</span><span class=cF0>+1);
|
||
|
<a name="l189"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(res,buf_dir);
|
||
|
<a name="l190"></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>-1]!=</span><span class=cF6>'/'</span><span class=cF0>)
|
||
|
<a name="l191"></a> </span><span class=cF5>CatPrint</span><span class=cF0>(res,</span><span class=cF6>"/"</span><span class=cF0>);
|
||
|
<a name="l192"></a> </span><span class=cF5>CatPrint</span><span class=cF0>(res,buf_file);
|
||
|
<a name="l193"></a> </span><span class=cF5>Free</span><span class=cF0>(buf_file);
|
||
|
<a name="l194"></a> </span><span class=cF5>Free</span><span class=cF0>(buf_dir);
|
||
|
<a name="l195"></a> </span><span class=cF5>Free</span><span class=cF0>(free_filename);
|
||
|
<a name="l196"></a> </span><span class=cF1>if</span><span class=cF0> (fuf_flags && </span><span class=cF5>FileFind</span><span class=cF7>(</span><span class=cF0>res,&de,fuf_flags|</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="l197"></a> </span><span class=cF5>Free</span><span class=cF0>(res);
|
||
|
<a name="l198"></a> res=de.full_name;
|
||
|
<a name="l199"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l200"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
||
|
<a name="l201"></a>}
|
||
|
<a name="l202"></a>
|
||
|
<a name="l203"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>ExtChg</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="l204"></a>{</span><span class=cF2>//Change filename extension.</span><span class=cF0>
|
||
|
<a name="l205"></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>+1+</span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>extension</span><span class=cF7>)</span><span class=cF0>+1);
|
||
|
<a name="l206"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(res,filename);
|
||
|
<a name="l207"></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="l208"></a> </span><span class=cF5>FileExtRem</span><span class=cF0>(res);
|
||
|
<a name="l209"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>CatPrint</span><span class=cF0>(res,</span><span class=cF6>".%s"</span><span class=cF0>,extension);
|
||
|
<a name="l210"></a>}
|
||
|
<a name="l211"></a>
|
||
|
<a name="l212"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>ExtDft</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="l213"></a>{</span><span class=cF2>//Give extension if has none.</span><span class=cF0>
|
||
|
<a name="l214"></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>+1+</span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>extension</span><span class=cF7>)</span><span class=cF0>+1);
|
||
|
<a name="l215"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(res,filename);
|
||
|
<a name="l216"></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="l217"></a> </span><span class=cF5>CatPrint</span><span class=cF0>(res,</span><span class=cF6>".%s"</span><span class=cF0>,extension);
|
||
|
<a name="l218"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
||
|
<a name="l219"></a>}
|
||
|
<a name="l220"></a>
|
||
|
<a name="l221"></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="l222"></a>{
|
||
|
<a name="l223"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
||
|
<a name="l224"></a> </span><span class=cF1>while</span><span class=cF0> (tmpde) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l225"></a> i=</span><span class=cF5>StrLen</span><span class=cF0>(tmpde->full_name);
|
||
|
<a name="l226"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>StrNCmp</span><span class=cF7>(</span><span class=cF0>tmpde->full_name,abs_name,i</span><span class=cF7>)</span><span class=cF0>||
|
||
|
<a name="l227"></a> i && tmpde->full_name[i-1]!=</span><span class=cF6>'/'</span><span class=cF0> && abs_name[i] && abs_name[i]!=</span><span class=cF6>'/'</span><span class=cF0>)
|
||
|
<a name="l228"></a> tmpde=tmpde->next;
|
||
|
<a name="l229"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l230"></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="l231"></a> </span><span class=cF1>return</span><span class=cF0> tmpde;
|
||
|
<a name="l232"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l233"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>Cd2DirEntry</span><span class=cF0>(tmpde->sub,abs_name);
|
||
|
<a name="l234"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l235"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
|
||
|
<a name="l236"></a>}
|
||
|
<a name="l237"></a>
|
||
|
<a name="l238"></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=0)
|
||
|
<a name="l239"></a>{
|
||
|
<a name="l240"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>IsDotZ</span><span class=cF7>(</span><span class=cF0>name</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l241"></a> attr|=</span><span class=cF3>RS_ATTR_COMPRESSED</span><span class=cF0>;
|
||
|
<a name="l242"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l243"></a> attr&=~</span><span class=cF3>RS_ATTR_COMPRESSED</span><span class=cF0>;
|
||
|
<a name="l244"></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="l245"></a> attr|=</span><span class=cF3>RS_ATTR_CONTIGUOUS</span><span class=cF0>;
|
||
|
<a name="l246"></a> </span><span class=cF1>return</span><span class=cF0> attr;
|
||
|
<a name="l247"></a>}
|
||
|
<a name="l248"></a>
|
||
|
<a name="l249"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>FileNameChk</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *filename)
|
||
|
<a name="l250"></a>{</span><span class=cF2>//Return check for valid filename, not checking existence.</span><span class=cF0>
|
||
|
<a name="l251"></a> </span><span class=cF1>U8</span><span class=cF0> *ptr=filename;
|
||
|
<a name="l252"></a> </span><span class=cF1>if</span><span class=cF0> (!filename) </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l253"></a> </span><span class=cF1>if</span><span class=cF0> (!*ptr) </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l254"></a> </span><span class=cF1>if</span><span class=cF0> (*ptr==</span><span class=cF6>'.'</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l255"></a> </span><span class=cF1>if</span><span class=cF0> (!ptr[1]) </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l256"></a> </span><span class=cF1>if</span><span class=cF0> (ptr[1]==</span><span class=cF6>'.'</span><span class=cF0> && !ptr[2]) </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l257"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l258"></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>>=</span><span class=cF3>CDIR_FILENAME_LEN</span><span class=cF0>) </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l259"></a> </span><span class=cF1>while</span><span class=cF0> (*ptr)
|
||
|
<a name="l260"></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="l261"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l262"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l263"></a>}
|
||
|
<a name="l264"></a>
|
||
|
<a name="l265"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>ToggleZorNotZ</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *name)
|
||
|
<a name="l266"></a>{</span><span class=cF2>//MAlloc name with Z if not Z or vice versa.</span><span class=cF0>
|
||
|
<a name="l267"></a> </span><span class=cF1>U8</span><span class=cF0> *res;
|
||
|
<a name="l268"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>IsDotZ</span><span class=cF7>(</span><span class=cF0>name</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l269"></a> res=</span><span class=cF5>StrNew</span><span class=cF0>(name);
|
||
|
<a name="l270"></a> res[</span><span class=cF5>StrLen</span><span class=cF0>(name)-2]=0;
|
||
|
<a name="l271"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l272"></a> res=</span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>"%s.Z"</span><span class=cF0>,name);
|
||
|
<a name="l273"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
||
|
<a name="l274"></a>}
|
||
|
<a name="l275"></a>
|
||
|
<a name="l276"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>FileNameTmpTxt</span><span class=cF0>()
|
||
|
<a name="l277"></a>{</span><span class=cF2>//Make pretty-safe tmp filename in home dir.</span><span class=cF0>
|
||
|
<a name="l278"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>"~/SysTmp%X.DD.Z"</span><span class=cF0>,</span><span class=cF5>GetTSC</span><span class=cF0>>>8&0xFFFFFFFF);
|
||
|
<a name="l279"></a>}
|
||
|
<a name="l280"></a>
|
||
|
<a name="l281"></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="l282"></a>{</span><span class=cF2>//MAlloc copy of cur dir with drv letter.</span><span class=cF0>
|
||
|
<a name="l283"></a> </span><span class=cF1>U8</span><span class=cF0> *st;
|
||
|
<a name="l284"></a> </span><span class=cF1>if</span><span class=cF0> (!task) task=</span><span class=cF5>Fs</span><span class=cF0>;
|
||
|
<a name="l285"></a> </span><span class=cF1>if</span><span class=cF0> (!task->cur_dir)
|
||
|
<a name="l286"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
|
||
|
<a name="l287"></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->cur_dir</span><span class=cF7>)</span><span class=cF0>+3,mem_task);
|
||
|
<a name="l288"></a> *st=</span><span class=cF5>Drv2Let</span><span class=cF0>(task->cur_dv);
|
||
|
<a name="l289"></a> st[1]=</span><span class=cF6>':'</span><span class=cF0>;
|
||
|
<a name="l290"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(st+2,task->cur_dir);
|
||
|
<a name="l291"></a> </span><span class=cF1>return</span><span class=cF0> st;
|
||
|
<a name="l292"></a>}
|
||
|
<a name="l293"></a>
|
||
|
<a name="l294"></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="l295"></a>{</span><span class=cF2>/*Strips file from dirname, scans for file upward until found or</span><span class=cF0>
|
||
|
<a name="l296"></a></span><span class=cF2>returns default.</span><span class=cF0>
|
||
|
<a name="l297"></a>
|
||
|
<a name="l298"></a></span><span class=cF2>("/Kernel/KHashA.HC.Z",NULL,NULL)</span><span class=cF0> </span><span class=cF2>returns "D:/Kernel"</span><span class=cF0>
|
||
|
<a name="l299"></a></span><span class=cF2>("/Kernel",NULL,"PRJ.Z")</span><span class=cF0> </span><span class=cF2>returns "D:/Kernel/Kernel.PRJ.Z"</span><span class=cF0>
|
||
|
<a name="l300"></a></span><span class=cF2>("/Kernel/BlkDev",NULL,"PRJ.Z")</span><span class=cF0> </span><span class=cF2>returns "D:/Kernel/Kernel.PRJ.Z"</span><span class=cF0>
|
||
|
<a name="l301"></a></span><span class=cF2>("/Apps/Psalmody","Load","HC.Z")</span><span class=cF0> </span><span class=cF2>returns "D:/Apps/Psalmody/Load.HC.Z"</span><span class=cF0>
|
||
|
<a name="l302"></a></span><span class=cF2>*/</span><span class=cF0>
|
||
|
<a name="l303"></a> </span><span class=cF1>U8</span><span class=cF0> *st=</span><span class=cF5>DirNameAbs</span><span class=cF0>(dirname),*st2,*st3,*res,*dft=</span><span class=cF3>NULL</span><span class=cF0>,*</span><span class=cFB>ext</span><span class=cF0>;
|
||
|
<a name="l304"></a> </span><span class=cF1>if</span><span class=cF0> (_extension && *_extension) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l305"></a> </span><span class=cF1>if</span><span class=cF0> (*_extension==</span><span class=cF6>'.'</span><span class=cF0>)
|
||
|
<a name="l306"></a> </span><span class=cFB>ext</span><span class=cF0>=</span><span class=cF5>StrNew</span><span class=cF0>(_extension);
|
||
|
<a name="l307"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l308"></a> </span><span class=cFB>ext</span><span class=cF0>=</span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>".%s"</span><span class=cF0>,_extension);
|
||
|
<a name="l309"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l310"></a> </span><span class=cFB>ext</span><span class=cF0>=</span><span class=cF5>StrNew</span><span class=cF0>(</span><span class=cF6>""</span><span class=cF0>);
|
||
|
<a name="l311"></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>&&!</span><span class=cF5>IsDir</span><span class=cF7>(</span><span class=cF0>st</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l312"></a> </span><span class=cF5>StrLastRem</span><span class=cF0>(st,</span><span class=cF6>"/"</span><span class=cF0>);
|
||
|
<a name="l313"></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>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l314"></a> st2=</span><span class=cF5>StrNew</span><span class=cF0>(st);
|
||
|
<a name="l315"></a> st3=</span><span class=cF5>StrNew</span><span class=cF0>(st);
|
||
|
<a name="l316"></a> </span><span class=cF5>StrLastRem</span><span class=cF0>(st2,</span><span class=cF6>"/"</span><span class=cF0>,st3);
|
||
|
<a name="l317"></a>
|
||
|
<a name="l318"></a> </span><span class=cF1>if</span><span class=cF0> (name)
|
||
|
<a name="l319"></a> res=</span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>"%s/%s%s"</span><span class=cF0>,st,name,</span><span class=cFB>ext</span><span class=cF0>);
|
||
|
<a name="l320"></a> </span><span class=cF1>else</span><span class=cF0> {
|
||
|
<a name="l321"></a> </span><span class=cF1>if</span><span class=cF0> (*</span><span class=cFB>ext</span><span class=cF0>)
|
||
|
<a name="l322"></a> res=</span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>"%s/%s%s"</span><span class=cF0>,st,st3,</span><span class=cFB>ext</span><span class=cF0>);
|
||
|
<a name="l323"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l324"></a> res=</span><span class=cF5>StrNew</span><span class=cF0>(st);
|
||
|
<a name="l325"></a> }
|
||
|
<a name="l326"></a> </span><span class=cF1>if</span><span class=cF0> (!dft)
|
||
|
<a name="l327"></a> dft=</span><span class=cF5>StrNew</span><span class=cF0>(res);
|
||
|
<a name="l328"></a> </span><span class=cF1>if</span><span class=cF0> (!*</span><span class=cFB>ext</span><span class=cF0> && </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="l329"></a> </span><span class=cF5>Free</span><span class=cF0>(st3);
|
||
|
<a name="l330"></a> </span><span class=cF5>Free</span><span class=cF0>(st2);
|
||
|
<a name="l331"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
|
||
|
<a name="l332"></a> </span><span class=cF5>Free</span><span class=cF0>(dft);
|
||
|
<a name="l333"></a> </span><span class=cF5>Free</span><span class=cF0>(</span><span class=cFB>ext</span><span class=cF0>);
|
||
|
<a name="l334"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
||
|
<a name="l335"></a> }
|
||
|
<a name="l336"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
|
||
|
<a name="l337"></a> st=st2;
|
||
|
<a name="l338"></a> </span><span class=cF5>Free</span><span class=cF0>(st3);
|
||
|
<a name="l339"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l340"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
|
||
|
<a name="l341"></a> </span><span class=cF5>Free</span><span class=cF0>(</span><span class=cFB>ext</span><span class=cF0>);
|
||
|
<a name="l342"></a> </span><span class=cF1>return</span><span class=cF0> dft;
|
||
|
<a name="l343"></a>}
|
||
|
</span></pre></body>
|
||
|
</html>
|