ZealOS/docs/Misc/OSMerge.html

117 lines
11 KiB
HTML
Raw Normal View History

2021-07-03 05:07:57 +01:00
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
<meta name="generator" content="ZealOS V0.05">
<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:courier;font-size:10pt">
<a name="l1"></a><span class=cF9>CDirEntry</span><span class=cF0> OSFilesMGFind(</span><span class=cF9>CDirEntry</span><span class=cF0> *needle_entry, </span><span class=cF9>CDirEntry</span><span class=cF0> *haystack_list)
<a name="l2"></a>{
<a name="l3"></a> </span><span class=cF1>while</span><span class=cF0> (haystack_list)
<a name="l4"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l5"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>StrCompare</span><span class=cF7>(</span><span class=cF0>needle_entry-&gt;name, haystack_list-&gt;name</span><span class=cF7>)</span><span class=cF0>)
<a name="l6"></a> </span><span class=cF1>return</span><span class=cF0> haystack_list;
<a name="l7"></a> haystack_list = haystack_list-&gt;next;
<a name="l8"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l9"></a>
<a name="l10"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l11"></a>}
<a name="l12"></a>
<a name="l13"></a></span><span class=cF1>U0</span><span class=cF0> OSFilesMergeInner(</span><span class=cF9>CDirEntry</span><span class=cF0> *tmpde1, </span><span class=cF9>CDirEntry</span><span class=cF0> *tmpde2, </span><span class=cF9>I64</span><span class=cF0> *_fuf_flags, </span><span class=cF9>I64</span><span class=cF0> *_df_flags)
<a name="l14"></a>{
<a name="l15"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> *tmpde;
<a name="l16"></a> </span><span class=cF1>U8</span><span class=cF0> *new;
<a name="l17"></a>
<a name="l18"></a> </span><span class=cF1>while</span><span class=cF0> (tmpde1 &amp;&amp; !</span><span class=cF7>(</span><span class=cF0>*_df_flags &amp; </span><span class=cF3>DF_ABORT_ALL_FILES</span><span class=cF7>)</span><span class=cF0>)
<a name="l19"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l20"></a> tmpde = OSFilesMGFind(tmpde1, tmpde2);
<a name="l21"></a> </span><span class=cF1>if</span><span class=cF0> (!tmpde)
<a name="l22"></a> {
<a name="l23"></a> </span><span class=cF6>&quot;$BROWN$Does Not Exist:%s$FG$\n&quot;</span><span class=cF0>, tmpde1-&gt;full_name;
<a name="l24"></a> new = </span><span class=cF5>StrNew</span><span class=cF0>(tmpde1-&gt;full_name);
<a name="l25"></a> new[</span><span class=cFE>0</span><span class=cF0>] = tmpde2-&gt;full_name[</span><span class=cFE>0</span><span class=cF0>]; </span><span class=cF2>// shortcut to quickly get drive letter</span><span class=cF0>
<a name="l26"></a> </span><span class=cF5>Copy</span><span class=cF0>(tmpde1-&gt;full_name, new);
<a name="l27"></a> </span><span class=cF5>Free</span><span class=cF0>(new);
<a name="l28"></a> }
<a name="l29"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l30"></a> {
<a name="l31"></a> </span><span class=cF1>if</span><span class=cF0> (tmpde1-&gt;attr &amp; </span><span class=cF3>RS_ATTR_DIR</span><span class=cF0>)
<a name="l32"></a> OSFilesMergeInner(tmpde1-&gt;sub, tmpde-&gt;sub, _fuf_flags, _df_flags);
<a name="l33"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l34"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l35"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>AbsI64</span><span class=cF7>(</span><span class=cF0>tmpde1-&gt;datetime - tmpde-&gt;datetime</span><span class=cF7>)</span><span class=cF0> &gt; </span><span class=cF3>CDATE_FREQ</span><span class=cF0> * </span><span class=cFE>2</span><span class=cF0>) {</span><span class=cF2>//slop</span><span class=cF0>
<a name="l36"></a> </span><span class=cF6>&quot;%s&quot;</span><span class=cF0>, tmpde1-&gt;full_name;
<a name="l37"></a> </span><span class=cF6>'\n'</span><span class=cF0>;
<a name="l38"></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_DIFF</span><span class=cF7>)</span><span class=cF0>)
<a name="l39"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l40"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>FilesFindMatch</span><span class=cF7>(</span><span class=cF0>tmpde1-&gt;full_name, </span><span class=cF3>FILEMASK_TXT</span><span class=cF7>)</span><span class=cF0>)
<a name="l41"></a> </span><span class=cF5>Diff</span><span class=cF0>(tmpde-&gt;full_name, tmpde1-&gt;full_name, _df_flags);
<a name="l42"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l43"></a> }
<a name="l44"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l45"></a> }
<a name="l46"></a> tmpde1 = tmpde1-&gt;next;
<a name="l47"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l48"></a>}
<a name="l49"></a>
<a name="l50"></a></span><span class=cF1>U0</span><span class=cF0> OSFilesMerge(</span><span class=cF1>U8</span><span class=cF0> *dst_files_find_mask=</span><span class=cF6>&quot;/*&quot;</span><span class=cF0>, </span><span class=cF1>U8</span><span class=cF0> *src_files_find_mask=</span><span class=cF6>&quot;/*&quot;</span><span class=cF0>, </span><span class=cF1>U8</span><span class=cF0> *fu_flags=</span><span class=cF3>NULL</span><span class=cF0>)
<a name="l51"></a>{ </span><span class=cF2>// See </span><a href="http://www.tomawezome.github.io/ZealOS/System/Utils/Merge.html#l44"><span class=cF4>Merge</span></a><span class=cF2>.</span><span class=cF0>
<a name="l52"></a> </span><span class=cF9>I64</span><span class=cF0> df_flags = </span><span class=cFE>0</span><span class=cF0>, fuf_flags = </span><span class=cFE>0</span><span class=cF0>;
<a name="l53"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> *tmpde1 = </span><span class=cF3>NULL</span><span class=cF0>, *tmpde2 = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l54"></a>
<a name="l55"></a> </span><span class=cF5>FlagsScan</span><span class=cF0>(&amp;fuf_flags, </span><span class=cF5>Define</span><span class=cF7>(</span><span class=cF6>&quot;ST_FILE_UTIL_FLAGS&quot;</span><span class=cF7>)</span><span class=cF0>, </span><span class=cF6>&quot;+r&quot;</span><span class=cF0>);
<a name="l56"></a> </span><span class=cF5>FlagsScan</span><span class=cF0>(&amp;fuf_flags, </span><span class=cF5>Define</span><span class=cF7>(</span><span class=cF6>&quot;ST_FILE_UTIL_FLAGS&quot;</span><span class=cF7>)</span><span class=cF0>, fu_flags);
<a name="l57"></a> </span><span class=cF1>if</span><span class=cF0> (fuf_flags &amp; ~</span><span class=cF7>(</span><span class=cF3>FUG_FILES_FIND</span><span class=cF0> | </span><span class=cF3>FUF_DIFF</span><span class=cF7>)</span><span class=cF0>)
<a name="l58"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'FUF'</span><span class=cF0>);
<a name="l59"></a> </span><span class=cF5>PrintWarn</span><span class=cF0>(</span><span class=cF6>&quot;This is based strictly on file dates.\n&quot;</span><span class=cF0>);
<a name="l60"></a> tmpde1 = </span><span class=cF5>FilesFind</span><span class=cF0>(src_files_find_mask, fuf_flags &amp; </span><span class=cF3>FUG_FILES_FIND</span><span class=cF0>);
<a name="l61"></a> tmpde2 = </span><span class=cF5>FilesFind</span><span class=cF0>(dst_files_find_mask, fuf_flags &amp; </span><span class=cF3>FUG_FILES_FIND</span><span class=cF0>);
<a name="l62"></a> fuf_flags &amp;= </span><span class=cF3>FUF_DIFF</span><span class=cF0>;
<a name="l63"></a> OSFilesMergeInner(tmpde1, tmpde2, &amp;fuf_flags, &amp;df_flags);
<a name="l64"></a> </span><span class=cF5>DirTreeDel</span><span class=cF0>(tmpde1);
<a name="l65"></a> </span><span class=cF5>DirTreeDel</span><span class=cF0>(tmpde2);
<a name="l66"></a>}
<a name="l67"></a>
<a name="l68"></a>
<a name="l69"></a></span><span class=cF1>U0</span><span class=cF0> OSMerge(</span><span class=cF1>U8</span><span class=cF0> dst_drv, </span><span class=cF1>U8</span><span class=cF0> src_drv=</span><span class=cF6>':'</span><span class=cF0>)
<a name="l70"></a>{
<a name="l71"></a> </span><span class=cF1>U8</span><span class=cF0> *dst = </span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>&quot;%C:/&quot;</span><span class=cF0>, dst_drv);
<a name="l72"></a> </span><span class=cF1>U8</span><span class=cF0> *src = </span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>&quot;%C:/&quot;</span><span class=cF0>, src_drv);
<a name="l73"></a>
<a name="l74"></a> </span><span class=cF5>CopyTree</span><span class=cF0>(src, </span><span class=cF6>&quot;B:/&quot;</span><span class=cF0>);
<a name="l75"></a> OSFilesMerge(</span><span class=cF6>&quot;B:/&quot;</span><span class=cF0>, dst, </span><span class=cF6>&quot;+d&quot;</span><span class=cF0>);
<a name="l76"></a> </span><span class=cF6>&quot;Format %C:/ ? &quot;</span><span class=cF0>, dst_drv;
<a name="l77"></a> </span><span class=cF5>Format</span><span class=cF0>(dst_drv);
<a name="l78"></a> </span><span class=cF5>CopyTree</span><span class=cF0>(</span><span class=cF6>&quot;B:/&quot;</span><span class=cF0>, dst);
<a name="l79"></a>
<a name="l80"></a> </span><span class=cF5>BootHDIns</span><span class=cF0>(dst_drv);
<a name="l81"></a>}
<a name="l82"></a>
<a name="l83"></a></span><span class=cF1>U0</span><span class=cF0> OSUpgrade()
<a name="l84"></a>{
<a name="l85"></a> </span><span class=cF6>&quot;\n\nTODO: OSUpgrade (base off OSInstall)\n\n&quot;</span><span class=cF0>;
<a name="l86"></a>}
<a name="l87"></a>
<a name="l88"></a>OSUpgrade;</span></pre></body>
</html>