ZealOS/docs/Kernel/BlkDev/DiskStrB.CC.html
2021-07-25 04:07:40 -04:00

139 lines
11 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.10">
<style type="text/css">
body {background-color:#000000;}
.cF0{color:#ffffff;background-color:#000000;}
.cF1{color:#3465a4;background-color:#000000;}
.cF2{color:#4e9a06;background-color:#000000;}
.cF3{color:#06989a;background-color:#000000;}
.cF4{color:#a24444;background-color:#000000;}
.cF5{color:#75507b;background-color:#000000;}
.cF6{color:#ce982f;background-color:#000000;}
.cF7{color:#bcc0b9;background-color:#000000;}
.cF8{color:#555753;background-color:#000000;}
.cF9{color:#729fcf;background-color:#000000;}
.cFA{color:#82bc49;background-color:#000000;}
.cFB{color:#34e2e2;background-color:#000000;}
.cFC{color:#ac3535;background-color:#000000;}
.cFD{color:#ad7fa8;background-color:#000000;}
.cFE{color:#fce94f;background-color:#000000;}
.cFF{color:#000000;background-color:#000000;}
</style>
</head>
<body>
<pre style="font-family:monospace;font-size:12pt">
<a name="l1"></a><span class=cF1>Bool</span><span class=cF0> </span><span class=cFD>CFileNameTo</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *dst, </span><span class=cF1>U8</span><span class=cF0> *src)
<a name="l2"></a>{
<a name="l3"></a> </span><span class=cF5>MemSet</span><span class=cF0>(dst, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF3>CDIR_FILENAME_LEN</span><span class=cF0>);
<a name="l4"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>FileNameCheck</span><span class=cF7>(</span><span class=cF0>src</span><span class=cF7>)</span><span class=cF0>)
<a name="l5"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l6"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(dst, src);
<a name="l7"></a>
<a name="l8"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l9"></a>}
<a name="l10"></a>
<a name="l11"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>Name2DirClus</span><span class=cF0>(</span><span class=cF9>CDrive</span><span class=cF0> *drive, </span><span class=cF1>U8</span><span class=cF0> *dirname)
<a name="l12"></a>{
<a name="l13"></a> </span><span class=cF1>Bool</span><span class=cF0> cont = </span><span class=cF3>TRUE</span><span class=cF0>, unlock;
<a name="l14"></a> </span><span class=cF9>I64</span><span class=cF0> cur_dir_clus;
<a name="l15"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> de;
<a name="l16"></a> </span><span class=cF1>U8</span><span class=cF0> *buf = </span><span class=cF5>StrNew</span><span class=cF0>(dirname), *buf2 = </span><span class=cF5>StrNew</span><span class=cF0>(dirname);
<a name="l17"></a>
<a name="l18"></a> </span><span class=cF5>DriveCheck</span><span class=cF0>(drive);
<a name="l19"></a> </span><span class=cF1>try</span><span class=cF0>
<a name="l20"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l21"></a> unlock = </span><span class=cF5>DriveLock</span><span class=cF0>(drive);
<a name="l22"></a> cur_dir_clus = drive-&gt;root_clus;
<a name="l23"></a> </span><span class=cF1>while</span><span class=cF0> (*buf &amp;&amp; cont)
<a name="l24"></a> {
<a name="l25"></a> </span><span class=cF5>StrFirstRemove</span><span class=cF0>(buf, </span><span class=cF6>&quot;/&quot;</span><span class=cF0>, buf2);
<a name="l26"></a> </span><span class=cF1>if</span><span class=cF0> (*buf2)
<a name="l27"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l28"></a> </span><span class=cF1>switch</span><span class=cF0> (drive-&gt;fs_type)
<a name="l29"></a> {
<a name="l30"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>FSt_REDSEA</span><span class=cF0>:
<a name="l31"></a> cont = </span><span class=cFD>RedSeaFileFind</span><span class=cF0>(drive, cur_dir_clus, buf2, &amp;de, </span><span class=cF3>FUF_JUST_DIRS</span><span class=cF0>);
<a name="l32"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l33"></a>
<a name="l34"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>FSt_FAT32</span><span class=cF0>:
<a name="l35"></a> cont = </span><span class=cFD>FAT32FileFind</span><span class=cF0>(drive, cur_dir_clus, buf2, &amp;de, </span><span class=cF3>FUF_JUST_DIRS</span><span class=cF0>);
<a name="l36"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l37"></a>
<a name="l38"></a> </span><span class=cF1>default</span><span class=cF0>:
<a name="l39"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'Drive'</span><span class=cF0>);
<a name="l40"></a> }
<a name="l41"></a> cur_dir_clus = de.clus;
<a name="l42"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l43"></a> }
<a name="l44"></a> </span><span class=cF1>if</span><span class=cF0> (!cont)
<a name="l45"></a> {
<a name="l46"></a> </span><span class=cF5>PrintErr</span><span class=cF0>(</span><span class=cF6>&quot;File not found: \&quot;%s\&quot;.\n&quot;</span><span class=cF0>, dirname);
<a name="l47"></a> cur_dir_clus = </span><span class=cFE>0</span><span class=cF0>;
<a name="l48"></a> }
<a name="l49"></a> </span><span class=cF1>if</span><span class=cF0> (unlock)
<a name="l50"></a> </span><span class=cF5>DriveUnlock</span><span class=cF0>(drive);
<a name="l51"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l52"></a> </span><span class=cF1>catch</span><span class=cF0>
<a name="l53"></a> </span><span class=cF1>if</span><span class=cF0> (unlock)
<a name="l54"></a> </span><span class=cF5>DriveUnlock</span><span class=cF0>(drive);
<a name="l55"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
<a name="l56"></a> </span><span class=cF5>Free</span><span class=cF0>(buf2);
<a name="l57"></a>
<a name="l58"></a> </span><span class=cF1>return</span><span class=cF0> cur_dir_clus;
<a name="l59"></a>}
<a name="l60"></a>
<a name="l61"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>Name2ParentDirClus</span><span class=cF0>(</span><span class=cF9>CDrive</span><span class=cF0> *drive, </span><span class=cF1>U8</span><span class=cF0> *dirname)
<a name="l62"></a>{
<a name="l63"></a> </span><span class=cF1>Bool</span><span class=cF0> cont = </span><span class=cF3>TRUE</span><span class=cF0>, unlock;
<a name="l64"></a> </span><span class=cF9>I64</span><span class=cF0> cur_dir_clus, cur_dir_clus2;
<a name="l65"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> de;
<a name="l66"></a> </span><span class=cF1>U8</span><span class=cF0> *buf = </span><span class=cF5>StrNew</span><span class=cF0>(dirname), *buf2 = </span><span class=cF5>StrNew</span><span class=cF0>(dirname);
<a name="l67"></a>
<a name="l68"></a> </span><span class=cF5>DriveCheck</span><span class=cF0>(drive);
<a name="l69"></a> </span><span class=cF1>try</span><span class=cF0>
<a name="l70"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l71"></a> unlock = </span><span class=cF5>DriveLock</span><span class=cF0>(drive);
<a name="l72"></a> cur_dir_clus = cur_dir_clus2 = drive-&gt;root_clus;
<a name="l73"></a> </span><span class=cF1>while</span><span class=cF0> (*buf &amp;&amp; cont)
<a name="l74"></a> {
<a name="l75"></a> cur_dir_clus2 = cur_dir_clus;
<a name="l76"></a> </span><span class=cF5>StrFirstRemove</span><span class=cF0>(buf, </span><span class=cF6>&quot;/&quot;</span><span class=cF0>, buf2);
<a name="l77"></a> </span><span class=cF1>if</span><span class=cF0> (*buf2)
<a name="l78"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l79"></a> </span><span class=cF1>switch</span><span class=cF0> (drive-&gt;fs_type)
<a name="l80"></a> {
<a name="l81"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>FSt_REDSEA</span><span class=cF0>:
<a name="l82"></a> cont = </span><span class=cFD>RedSeaFileFind</span><span class=cF0>(drive, cur_dir_clus, buf2, &amp;de, </span><span class=cF3>FUF_JUST_DIRS</span><span class=cF0>);
<a name="l83"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l84"></a>
<a name="l85"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>FSt_FAT32</span><span class=cF0>:
<a name="l86"></a> cont = </span><span class=cFD>FAT32FileFind</span><span class=cF0>(drive, cur_dir_clus, buf2, &amp;de, </span><span class=cF3>FUF_JUST_DIRS</span><span class=cF0>);
<a name="l87"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l88"></a>
<a name="l89"></a> </span><span class=cF1>default</span><span class=cF0>:
<a name="l90"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'Drive'</span><span class=cF0>);
<a name="l91"></a> }
<a name="l92"></a> cur_dir_clus = de.clus;
<a name="l93"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l94"></a> }
<a name="l95"></a> </span><span class=cF1>if</span><span class=cF0> (!cont)
<a name="l96"></a> {
<a name="l97"></a> </span><span class=cF5>PrintErr</span><span class=cF0>(</span><span class=cF6>&quot;File not found: \&quot;%s\&quot;.\n&quot;</span><span class=cF0>, dirname);
<a name="l98"></a> cur_dir_clus2=</span><span class=cFE>0</span><span class=cF0>;
<a name="l99"></a> }
<a name="l100"></a> </span><span class=cF1>if</span><span class=cF0> (unlock)
<a name="l101"></a> </span><span class=cF5>DriveUnlock</span><span class=cF0>(drive);
<a name="l102"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l103"></a> </span><span class=cF1>catch</span><span class=cF0>
<a name="l104"></a> </span><span class=cF1>if</span><span class=cF0> (unlock)
<a name="l105"></a> </span><span class=cF5>DriveUnlock</span><span class=cF0>(drive);
<a name="l106"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
<a name="l107"></a> </span><span class=cF5>Free</span><span class=cF0>(buf2);
<a name="l108"></a>
<a name="l109"></a> </span><span class=cF1>return</span><span class=cF0> cur_dir_clus2;
<a name="l110"></a>}
</span></pre></body>
</html>