991 lines
103 KiB
HTML
Executable File
991 lines
103 KiB
HTML
Executable File
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="generator" content="TempleOS V5.03">
|
|
<meta name="viewport" content="width=device-width">
|
|
<link rel="stylesheet" href="/style/templeos.css">
|
|
<script src="/script/templeos.js"></script>
|
|
<style type="text/css">
|
|
.cF0{color:#000000;background-color:#ffffff;}
|
|
.cF1{color:#0000aa;background-color:#ffffff;}
|
|
.cF2{color:#00aa00;background-color:#ffffff;}
|
|
.cF3{color:#00aaaa;background-color:#ffffff;}
|
|
.cF4{color:#aa0000;background-color:#ffffff;}
|
|
.cF5{color:#aa00aa;background-color:#ffffff;}
|
|
.cF6{color:#aa5500;background-color:#ffffff;}
|
|
.cF7{color:#aaaaaa;background-color:#ffffff;}
|
|
.cF8{color:#555555;background-color:#ffffff;}
|
|
.cF9{color:#5555ff;background-color:#ffffff;}
|
|
.cFA{color:#55ff55;background-color:#ffffff;}
|
|
.cFB{color:#55ffff;background-color:#ffffff;}
|
|
.cFC{color:#ff5555;background-color:#ffffff;}
|
|
.cFD{color:#ff55ff;background-color:#ffffff;}
|
|
.cFE{color:#ffff55;background-color:#ffffff;}
|
|
.cFF{color:#ffffff;background-color:#ffffff;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pre id="content">
|
|
<a name="l1"></a><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>CDate2Dos</span><span class=cF0>(</span><span class=cF9>U16</span><span class=cF0> *t,</span><span class=cF9>U16</span><span class=cF0> *d,</span><span class=cF9>CDate</span><span class=cF0> cdt)
|
|
<a name="l2"></a>{
|
|
<a name="l3"></a> </span><span class=cF9>CDateStruct</span><span class=cF0> ds;
|
|
<a name="l4"></a> </span><span class=cF5>Date2Struct</span><span class=cF0>(&ds,cdt);
|
|
<a name="l5"></a> *d=ds.day_of_mon+(ds.mon+</span><span class=cF7>(</span><span class=cF0>ds.year-1980</span><span class=cF7>)</span><span class=cF0><<4)<<5;
|
|
<a name="l6"></a> *t=ds.sec>>1+(ds.min+ds.hour<<6)<<5;
|
|
<a name="l7"></a>}
|
|
<a name="l8"></a>
|
|
<a name="l9"></a></span><span class=cF9>CDate</span><span class=cF0> </span><span class=cFD>Dos2CDate</span><span class=cF0>(</span><span class=cF9>U16</span><span class=cF0> t,</span><span class=cF9>U16</span><span class=cF0> d)
|
|
<a name="l10"></a>{
|
|
<a name="l11"></a> </span><span class=cF9>CDateStruct</span><span class=cF0> ds;
|
|
<a name="l12"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&ds,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDateStruct</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l13"></a> ds.day_of_mon=d&0x1F; d=d>>5;
|
|
<a name="l14"></a> ds.mon=d&0xF;
|
|
<a name="l15"></a> ds.year=d>>4+1980;
|
|
<a name="l16"></a> ds.sec=(t&0x1F)*2; t=t>>5;
|
|
<a name="l17"></a> ds.min=t&0x3F;
|
|
<a name="l18"></a> ds.hour=t>>6;
|
|
<a name="l19"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>Struct2Date</span><span class=cF0>(&ds);
|
|
<a name="l20"></a>}
|
|
<a name="l21"></a>
|
|
<a name="l22"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>FAT32Init</span><span class=cF0>(</span><span class=cF9>CDrv</span><span class=cF0> *dv)
|
|
<a name="l23"></a>{
|
|
<a name="l24"></a> </span><span class=cF9>CFAT32Boot</span><span class=cF0> br32;
|
|
<a name="l25"></a> </span><span class=cF1>Bool</span><span class=cF0> unlock;
|
|
<a name="l26"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l27"></a> unlock=</span><span class=cF5>DrvLock</span><span class=cF0>(dv);
|
|
<a name="l28"></a> dv->fs_type=</span><span class=cF3>FSt_FAT32</span><span class=cF0>;
|
|
<a name="l29"></a> </span><span class=cF5>BlkRead</span><span class=cF0>(dv,&br32,dv->drv_offset,1);
|
|
<a name="l30"></a> dv->file_system_info_sect=dv->drv_offset+br32.file_system_info_sect;
|
|
<a name="l31"></a> dv->fat1=dv->drv_offset+br32.reserved_sects;
|
|
<a name="l32"></a> dv->fat2=dv->fat1+br32.sects_per_fat;
|
|
<a name="l33"></a> dv->data_area=dv->fat2+br32.sects_per_fat
|
|
<a name="l34"></a> -2*br32.sects_per_clus; </span><span class=cF2>//Starts at Clus 2</span><span class=cF0>
|
|
<a name="l35"></a> dv->spc=br32.sects_per_clus;
|
|
<a name="l36"></a> dv->root_clus=br32.root_clus;
|
|
<a name="l37"></a> </span><span class=cFD>DrvFATBlkAlloc</span><span class=cF0>(dv);
|
|
<a name="l38"></a> </span><span class=cF5>Free</span><span class=cF0>(dv->fis);
|
|
<a name="l39"></a> dv->fis=</span><span class=cF5>AMAlloc</span><span class=cF0>(</span><span class=cF3>BLK_SIZE</span><span class=cF0>);
|
|
<a name="l40"></a> </span><span class=cF5>BlkRead</span><span class=cF0>(dv,dv->fis,dv->file_system_info_sect,1);
|
|
<a name="l41"></a> </span><span class=cF1>if</span><span class=cF0> (unlock)
|
|
<a name="l42"></a> </span><span class=cF5>DrvUnlock</span><span class=cF0>(dv);
|
|
<a name="l43"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0>
|
|
<a name="l44"></a> </span><span class=cF1>if</span><span class=cF0> (unlock)
|
|
<a name="l45"></a> </span><span class=cF5>DrvUnlock</span><span class=cF0>(dv);
|
|
<a name="l46"></a>}
|
|
<a name="l47"></a>
|
|
<a name="l48"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>FAT32Fmt</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> drv_let,</span><span class=cF1>Bool</span><span class=cF0> quick=</span><span class=cF3>TRUE</span><span class=cF0>)
|
|
<a name="l49"></a>{
|
|
<a name="l50"></a> </span><span class=cF9>CFAT32Boot</span><span class=cF0> *br=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF3>BLK_SIZE</span><span class=cF0>);
|
|
<a name="l51"></a> </span><span class=cF9>CFAT32FileInfoSect</span><span class=cF0> *fis=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF3>BLK_SIZE</span><span class=cF0>);
|
|
<a name="l52"></a> </span><span class=cF9>CDrv</span><span class=cF0> *dv=</span><span class=cF5>Let2Drv</span><span class=cF0>(drv_let);
|
|
<a name="l53"></a> </span><span class=cF9>I64</span><span class=cF0> i,l;
|
|
<a name="l54"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l55"></a> </span><span class=cF5>DrvLock</span><span class=cF0>(dv);
|
|
<a name="l56"></a> </span><span class=cFD>DrvTypeSet</span><span class=cF0>(drv_let,</span><span class=cF3>FSt_FAT32</span><span class=cF0>);
|
|
<a name="l57"></a> dv->fs_type=</span><span class=cF3>FSt_FAT32</span><span class=cF0>;
|
|
<a name="l58"></a> br->jump_and_nop[0]=</span><span class=cF3>OC_JMP_REL8</span><span class=cF0>;
|
|
<a name="l59"></a> br->jump_and_nop[1]=</span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CFAT32Boot</span><span class=cF0>.code)-2;
|
|
<a name="l60"></a> br->jump_and_nop[2]=</span><span class=cF3>OC_NOP</span><span class=cF0>;
|
|
<a name="l61"></a> br->oem_name[0](</span><span class=cF9>I64</span><span class=cF0>)=</span><span class=cF6>'MSWIN4.1'</span><span class=cF0>;
|
|
<a name="l62"></a> br->bytes_per_sect=</span><span class=cF3>BLK_SIZE</span><span class=cF0>;
|
|
<a name="l63"></a> </span><span class=cF1>if</span><span class=cF0> (dv->size<= 500000)
|
|
<a name="l64"></a> br->sects_per_clus=1;
|
|
<a name="l65"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (dv->size<=2000000)
|
|
<a name="l66"></a> br->sects_per_clus=2;
|
|
<a name="l67"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (dv->size<=6000000)
|
|
<a name="l68"></a> br->sects_per_clus=4;
|
|
<a name="l69"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (dv->size<=12000000)
|
|
<a name="l70"></a> br->sects_per_clus=8;
|
|
<a name="l71"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (dv->size<=33000000)
|
|
<a name="l72"></a> br->sects_per_clus=16;
|
|
<a name="l73"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (dv->size<=67000000)
|
|
<a name="l74"></a> br->sects_per_clus=32;
|
|
<a name="l75"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l76"></a> br->sects_per_clus=64;
|
|
<a name="l77"></a>
|
|
<a name="l78"></a> br->reserved_sects=32;
|
|
<a name="l79"></a> br->copies_of_fat=2;
|
|
<a name="l80"></a> br->media_desc=0xF8;
|
|
<a name="l81"></a> br->sects=dv->size;
|
|
<a name="l82"></a> l=(br->sects/br->sects_per_clus)>>(</span><span class=cF3>BLK_SIZE_BITS</span><span class=cF0>-2)+1;
|
|
<a name="l83"></a> br->sects_per_fat=l;
|
|
<a name="l84"></a> br->root_clus=2;
|
|
<a name="l85"></a> br->file_system_info_sect=1;
|
|
<a name="l86"></a> br->log_drv_num=0x80;
|
|
<a name="l87"></a> br->ext_signature=0x29;
|
|
<a name="l88"></a> br->serial_num=</span><span class=cF5>RandU32</span><span class=cF0>;
|
|
<a name="l89"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(br->vol_name,</span><span class=cF6>"NO NAME "</span><span class=cF0>,11);
|
|
<a name="l90"></a> br->fat_name[0](</span><span class=cF9>I64</span><span class=cF0>)=</span><span class=cF6>'FAT32 '</span><span class=cF0>;
|
|
<a name="l91"></a> br->signature=0xAA55;
|
|
<a name="l92"></a> fis->signature1=</span><span class=cF6>'RRaA'</span><span class=cF0>;
|
|
<a name="l93"></a> fis->signature2=</span><span class=cF6>'rrAa'</span><span class=cF0>;
|
|
<a name="l94"></a> fis->free_clus=-1;
|
|
<a name="l95"></a> fis->most_recently_alloced=0;
|
|
<a name="l96"></a> fis->signature3=0xAA550000;
|
|
<a name="l97"></a>
|
|
<a name="l98"></a> </span><span class=cF1>if</span><span class=cF0> (quick)
|
|
<a name="l99"></a> i=br->reserved_sects+2*l+4*br->sects_per_clus;
|
|
<a name="l100"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l101"></a> i=dv->size;
|
|
<a name="l102"></a> </span><span class=cF5>BlkWriteZero</span><span class=cF0>(dv,dv->drv_offset,i);
|
|
<a name="l103"></a>
|
|
<a name="l104"></a> </span><span class=cF5>BlkWrite</span><span class=cF0>(dv,fis,dv->drv_offset+br->file_system_info_sect,1);
|
|
<a name="l105"></a> </span><span class=cF5>BlkWrite</span><span class=cF0>(dv,br,dv->drv_offset,1);
|
|
<a name="l106"></a> </span><span class=cFD>FAT32Init</span><span class=cF0>(dv);
|
|
<a name="l107"></a> </span><span class=cF5>ClusAlloc</span><span class=cF0>(dv,0,1,</span><span class=cF3>FALSE</span><span class=cF0>); </span><span class=cF2>//Alloc #1</span><span class=cF0>
|
|
<a name="l108"></a> br->root_clus=</span><span class=cF5>ClusAlloc</span><span class=cF0>(dv,0,1,</span><span class=cF3>FALSE</span><span class=cF0>);
|
|
<a name="l109"></a> </span><span class=cF5>BlkWrite</span><span class=cF0>(dv,br,dv->drv_offset,1);
|
|
<a name="l110"></a> </span><span class=cFD>FAT32Init</span><span class=cF0>(dv);
|
|
<a name="l111"></a> </span><span class=cF5>DrvUnlock</span><span class=cF0>(dv);
|
|
<a name="l112"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0>
|
|
<a name="l113"></a> </span><span class=cF5>DrvUnlock</span><span class=cF0>(dv);
|
|
<a name="l114"></a> </span><span class=cF5>Free</span><span class=cF0>(br);
|
|
<a name="l115"></a> </span><span class=cF5>Free</span><span class=cF0>(fis);
|
|
<a name="l116"></a>}
|
|
<a name="l117"></a>
|
|
<a name="l118"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cFD>FATNameTo</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="l119"></a>{
|
|
<a name="l120"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
|
<a name="l121"></a> </span><span class=cF5>MemSet</span><span class=cF0>(dst,</span><span class=cF3>CH_SPACE</span><span class=cF0>,11);
|
|
<a name="l122"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>FileNameChk</span><span class=cF7>(</span><span class=cF0>src</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l123"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l124"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>StrCmp</span><span class=cF7>(</span><span class=cF0>src,</span><span class=cF6>".."</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l125"></a> *dst=</span><span class=cF6>'.'</span><span class=cF0>;
|
|
<a name="l126"></a> dst[1]=</span><span class=cF6>'.'</span><span class=cF0>;
|
|
<a name="l127"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</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> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>StrCmp</span><span class=cF7>(</span><span class=cF0>src,</span><span class=cF6>"."</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l129"></a> *dst=</span><span class=cF6>'.'</span><span class=cF0>;
|
|
<a name="l130"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l131"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l132"></a> i=0;
|
|
<a name="l133"></a> </span><span class=cF1>while</span><span class=cF0> (i<8 && *src && *src!=</span><span class=cF6>'.'</span><span class=cF0>)
|
|
<a name="l134"></a> dst[i++]=</span><span class=cF5>ToUpper</span><span class=cF0>(*src++);
|
|
<a name="l135"></a> i=8;
|
|
<a name="l136"></a> </span><span class=cF1>if</span><span class=cF0> (*src==</span><span class=cF6>'.'</span><span class=cF0>) src++;
|
|
<a name="l137"></a> </span><span class=cF1>while</span><span class=cF0> (*src)
|
|
<a name="l138"></a> </span><span class=cF1>if</span><span class=cF0> (*src!=</span><span class=cF6>'.'</span><span class=cF0>)
|
|
<a name="l139"></a> dst[i++]=</span><span class=cF5>ToUpper</span><span class=cF0>(*src++);
|
|
<a name="l140"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l141"></a> src++;
|
|
<a name="l142"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l143"></a>}
|
|
<a name="l144"></a>
|
|
<a name="l145"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cFD>FATNameXSum</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *src)
|
|
<a name="l146"></a>{
|
|
<a name="l147"></a> </span><span class=cF9>I64</span><span class=cF0> i,res=0;
|
|
<a name="l148"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<11;i++)
|
|
<a name="l149"></a> </span><span class=cF1>if</span><span class=cF0> (res&1)
|
|
<a name="l150"></a> res.u8[0]=0x80+res>>1+*src++;
|
|
<a name="l151"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l152"></a> res.u8[0]=res>>1+*src++;
|
|
<a name="l153"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l154"></a>}
|
|
<a name="l155"></a>
|
|
<a name="l156"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cFD>FATFromName</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="l157"></a>{
|
|
<a name="l158"></a> </span><span class=cF9>I64</span><span class=cF0> i,j,k=0;
|
|
<a name="l159"></a> </span><span class=cF1>for</span><span class=cF0> (j=7;j>=0 && src[j]==</span><span class=cF3>CH_SPACE</span><span class=cF0>;j--);
|
|
<a name="l160"></a> </span><span class=cF1>for</span><span class=cF0>(i=0;i<=j;i++)
|
|
<a name="l161"></a> dst[k++]=src[i];
|
|
<a name="l162"></a> </span><span class=cF1>for</span><span class=cF0> (j=10;j>=8 && src[j]==</span><span class=cF3>CH_SPACE</span><span class=cF0>;j--);
|
|
<a name="l163"></a> </span><span class=cF1>if</span><span class=cF0> (*src!=</span><span class=cF6>'.'</span><span class=cF0> && j!=7)
|
|
<a name="l164"></a> dst[k++]=</span><span class=cF6>'.'</span><span class=cF0>;
|
|
<a name="l165"></a> </span><span class=cF1>for</span><span class=cF0>(i=8;i<=j;i++)
|
|
<a name="l166"></a> dst[k++]=src[i];
|
|
<a name="l167"></a> dst[k++]=0;
|
|
<a name="l168"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>FileNameChk</span><span class=cF0>(dst);
|
|
<a name="l169"></a>}
|
|
<a name="l170"></a>
|
|
<a name="l171"></a></span><span class=cF1>U8</span><span class=cF0> </span><span class=cFD>fat_long_name_map</span><span class=cF0>[13]={
|
|
<a name="l172"></a> </span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CFAT32DirEntryLong</span><span class=cF0>.name1),
|
|
<a name="l173"></a> </span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CFAT32DirEntryLong</span><span class=cF0>.name1)+2,
|
|
<a name="l174"></a> </span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CFAT32DirEntryLong</span><span class=cF0>.name1)+4,
|
|
<a name="l175"></a> </span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CFAT32DirEntryLong</span><span class=cF0>.name1)+6,
|
|
<a name="l176"></a> </span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CFAT32DirEntryLong</span><span class=cF0>.name1)+8,
|
|
<a name="l177"></a> </span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CFAT32DirEntryLong</span><span class=cF0>.name2),
|
|
<a name="l178"></a> </span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CFAT32DirEntryLong</span><span class=cF0>.name2)+2,
|
|
<a name="l179"></a> </span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CFAT32DirEntryLong</span><span class=cF0>.name2)+4,
|
|
<a name="l180"></a> </span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CFAT32DirEntryLong</span><span class=cF0>.name2)+6,
|
|
<a name="l181"></a> </span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CFAT32DirEntryLong</span><span class=cF0>.name2)+8,
|
|
<a name="l182"></a> </span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CFAT32DirEntryLong</span><span class=cF0>.name2)+10,
|
|
<a name="l183"></a> </span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CFAT32DirEntryLong</span><span class=cF0>.name3),
|
|
<a name="l184"></a> </span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CFAT32DirEntryLong</span><span class=cF0>.name3)+2
|
|
<a name="l185"></a>};
|
|
<a name="l186"></a>
|
|
<a name="l187"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cFD>DirLongNameFill</span><span class=cF0>(</span><span class=cF9>CDirEntry</span><span class=cF0> *tmpde,</span><span class=cF9>CFAT32DirEntryLong</span><span class=cF0> *de,</span><span class=cF9>I64</span><span class=cF0> *xsum)
|
|
<a name="l188"></a>{
|
|
<a name="l189"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
|
<a name="l190"></a> </span><span class=cF1>U8</span><span class=cF0> *ptr=de;
|
|
<a name="l191"></a> </span><span class=cF1>if</span><span class=cF0> (de->ord&0x40) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l192"></a> </span><span class=cF5>MemSet</span><span class=cF0>(tmpde,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l193"></a> *xsum=de->xsum;
|
|
<a name="l194"></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> (de->type || de->zero || de->xsum!=*xsum) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l195"></a> </span><span class=cF5>MemSet</span><span class=cF0>(tmpde,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l196"></a> *xsum=0;
|
|
<a name="l197"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l198"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l199"></a> </span><span class=cF1>switch</span><span class=cF0> (de->ord&0x3F) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l200"></a> </span><span class=cF1>case</span><span class=cF0> 1:
|
|
<a name="l201"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<13;i++)
|
|
<a name="l202"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>tmpde->name[i]=ptr[</span><span class=cFD>fat_long_name_map</span><span class=cF0>[i]]</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l203"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l204"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l205"></a> </span><span class=cF1>case</span><span class=cF0> 2:
|
|
<a name="l206"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<12;i++)
|
|
<a name="l207"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>tmpde->name[i+13]=ptr[</span><span class=cFD>fat_long_name_map</span><span class=cF0>[i]]</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l208"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l209"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l210"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l211"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l212"></a>}
|
|
<a name="l213"></a>
|
|
<a name="l214"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cFD>FAT32CDirFill</span><span class=cF0>(</span><span class=cF9>CDirEntry</span><span class=cF0> *tmpde,
|
|
<a name="l215"></a> </span><span class=cF9>CFAT32DirEntry</span><span class=cF0> *de,</span><span class=cF9>CDate</span><span class=cF0> _local_time_offset)
|
|
<a name="l216"></a>{
|
|
<a name="l217"></a> </span><span class=cF1>Bool</span><span class=cF0> res;
|
|
<a name="l218"></a> </span><span class=cF1>if</span><span class=cF0> (*tmpde->name)
|
|
<a name="l219"></a> res=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l220"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l221"></a> res=</span><span class=cFD>FATFromName</span><span class=cF0>(tmpde->name,de->name);
|
|
<a name="l222"></a> tmpde->clus=de->clus_lo+de->clus_hi<<16;
|
|
<a name="l223"></a> tmpde->size=de->size;
|
|
<a name="l224"></a> tmpde->attr=de->attr;
|
|
<a name="l225"></a> tmpde->datetime=</span><span class=cFD>Dos2CDate</span><span class=cF0>(de->WrtTime,de->WrtDate)-_local_time_offset;
|
|
<a name="l226"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l227"></a>}
|
|
<a name="l228"></a>
|
|
<a name="l229"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cFD>FAT32DirFill</span><span class=cF0>(</span><span class=cF9>CFAT32DirEntry</span><span class=cF0> *de,
|
|
<a name="l230"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> *tmpde,</span><span class=cF9>I64</span><span class=cF0> *_de_cnt,</span><span class=cF9>CDate</span><span class=cF0> _local_time_offset)
|
|
<a name="l231"></a>{</span><span class=cF2>//Fill up to 3 entries and store cnt of entries.</span><span class=cF0>
|
|
<a name="l232"></a> </span><span class=cF9>I64</span><span class=cF0> de_cnt=0,i,l,xsum,ord;
|
|
<a name="l233"></a> </span><span class=cF1>U8</span><span class=cF0> *ptr,dname[16];
|
|
<a name="l234"></a> </span><span class=cF9>CFAT32DirEntryLong</span><span class=cF0> *ld=de;
|
|
<a name="l235"></a> </span><span class=cF1>Bool</span><span class=cF0> res;
|
|
<a name="l236"></a>
|
|
<a name="l237"></a> </span><span class=cF5>MemSet</span><span class=cF0>(de,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CFAT32DirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l238"></a> res=</span><span class=cFD>FATNameTo</span><span class=cF0>(de->name,tmpde->name);
|
|
<a name="l239"></a> </span><span class=cFD>FATFromName</span><span class=cF0>(dname,de->name);
|
|
<a name="l240"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>StrCmp</span><span class=cF7>(</span><span class=cF0>dname,tmpde->name</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l241"></a> ord=0x41;
|
|
<a name="l242"></a> xsum=</span><span class=cFD>FATNameXSum</span><span class=cF0>(de->name);
|
|
<a name="l243"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>l=</span><span class=cF5>StrLen</span><span class=cF0>(tmpde->name)</span><span class=cF7>)</span><span class=cF0>>13) {
|
|
<a name="l244"></a> ptr=&ld[de_cnt];
|
|
<a name="l245"></a> </span><span class=cF5>MemSet</span><span class=cF0>(ptr,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CFAT32DirEntryLong</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l246"></a> ld[de_cnt].attr=</span><span class=cF3>RS_ATTR_LONG_NAME</span><span class=cF0>;
|
|
<a name="l247"></a> ld[de_cnt].xsum=xsum;
|
|
<a name="l248"></a> ld[de_cnt].ord=0x42;
|
|
<a name="l249"></a> </span><span class=cF1>for</span><span class=cF0> (i=13;i<l;i++)
|
|
<a name="l250"></a> ptr[</span><span class=cFD>fat_long_name_map</span><span class=cF0>[i-13]]=tmpde->name[i];
|
|
<a name="l251"></a> i++;
|
|
<a name="l252"></a> </span><span class=cF1>for</span><span class=cF0> (;i<26;i++)
|
|
<a name="l253"></a> ptr[</span><span class=cFD>fat_long_name_map</span><span class=cF0>[i-13]](</span><span class=cF9>U16</span><span class=cF0>)=0xFFFF;
|
|
<a name="l254"></a> ord=1;
|
|
<a name="l255"></a> l=13;
|
|
<a name="l256"></a> de_cnt++;
|
|
<a name="l257"></a> }
|
|
<a name="l258"></a> ptr=&de[de_cnt];
|
|
<a name="l259"></a> </span><span class=cF5>MemSet</span><span class=cF0>(ptr,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CFAT32DirEntryLong</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l260"></a> ld[de_cnt].attr=</span><span class=cF3>RS_ATTR_LONG_NAME</span><span class=cF0>;
|
|
<a name="l261"></a> ld[de_cnt].xsum=xsum;
|
|
<a name="l262"></a> ld[de_cnt].ord=ord;
|
|
<a name="l263"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<l;i++)
|
|
<a name="l264"></a> ptr[</span><span class=cFD>fat_long_name_map</span><span class=cF0>[i]]=tmpde->name[i];
|
|
<a name="l265"></a> i++;
|
|
<a name="l266"></a> </span><span class=cF1>for</span><span class=cF0> (;i<13;i++)
|
|
<a name="l267"></a> ptr[</span><span class=cFD>fat_long_name_map</span><span class=cF0>[i]](</span><span class=cF9>U16</span><span class=cF0>)=0xFFFF;
|
|
<a name="l268"></a> de_cnt++;
|
|
<a name="l269"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&de[de_cnt],0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CFAT32DirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l270"></a> res=</span><span class=cFD>FATNameTo</span><span class=cF0>(de[de_cnt].name,tmpde->name);
|
|
<a name="l271"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l272"></a> de[de_cnt].clus_lo=tmpde->clus.u16[0];
|
|
<a name="l273"></a> de[de_cnt].clus_hi=tmpde->clus.u16[1];
|
|
<a name="l274"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>tmpde->attr&</span><span class=cF3>RS_ATTR_DIR</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l275"></a> de[de_cnt].size=tmpde->size;
|
|
<a name="l276"></a> de[de_cnt].attr=tmpde->attr;
|
|
<a name="l277"></a> </span><span class=cF1>if</span><span class=cF0> (!tmpde->datetime)
|
|
<a name="l278"></a> tmpde->datetime=</span><span class=cF5>Now</span><span class=cF0>;
|
|
<a name="l279"></a> </span><span class=cFD>CDate2Dos</span><span class=cF0>(&de[de_cnt].WrtTime,&de[de_cnt].WrtDate,
|
|
<a name="l280"></a> tmpde->datetime+_local_time_offset);
|
|
<a name="l281"></a> </span><span class=cF1>if</span><span class=cF0> (_de_cnt)
|
|
<a name="l282"></a> *_de_cnt=de_cnt+1;
|
|
<a name="l283"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l284"></a>}
|
|
<a name="l285"></a>
|
|
<a name="l286"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cFD>FAT32FileFind</span><span class=cF0>(</span><span class=cF9>CDrv</span><span class=cF0> *dv,</span><span class=cF9>I64</span><span class=cF0> cur_dir_clus,
|
|
<a name="l287"></a> </span><span class=cF1>U8</span><span class=cF0> *name,</span><span class=cF9>CDirEntry</span><span class=cF0> *_res,</span><span class=cF9>I64</span><span class=cF0> fuf_flags=0)
|
|
<a name="l288"></a>{</span><span class=cF2>//</span><a href="/Wb/Kernel/KernelA.HH.HTML#l2577"><span class=cF4>FUF_JUST_DIRS</span></a><span class=cF2>, </span><a href="/Wb/Kernel/KernelA.HH.HTML#l2578"><span class=cF4>FUF_JUST_FILES</span></a><span class=cF0>
|
|
<a name="l289"></a> </span><span class=cF1>Bool</span><span class=cF0> res=</span><span class=cF3>FALSE</span><span class=cF0>,unlock;
|
|
<a name="l290"></a> </span><span class=cF9>CFAT32DirEntry</span><span class=cF0> *buf;
|
|
<a name="l291"></a> </span><span class=cF9>I64</span><span class=cF0> xsum=0,attr,cur_dir_entry,entries_per_clus;
|
|
<a name="l292"></a> </span><span class=cF1>U8</span><span class=cF0> dname[</span><span class=cF3>CDIR_FILENAME_LEN</span><span class=cF0>],ch;
|
|
<a name="l293"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> long_name;
|
|
<a name="l294"></a> </span><span class=cF1>if</span><span class=cF0> (fuf_flags&~</span><span class=cF3>FUG_FILE_FIND</span><span class=cF0>)
|
|
<a name="l295"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'FUF'</span><span class=cF0>);
|
|
<a name="l296"></a> </span><span class=cF5>MemSet</span><span class=cF0>(_res,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l297"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&long_name,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l298"></a> </span><span class=cF5>DrvChk</span><span class=cF0>(dv);
|
|
<a name="l299"></a> </span><span class=cF1>if</span><span class=cF0> (dv->fs_type!=</span><span class=cF3>FSt_FAT32</span><span class=cF0>)
|
|
<a name="l300"></a> </span><span class=cF5>PrintErr</span><span class=cF0>(</span><span class=cF6>"Not FAT32 Drv\n"</span><span class=cF0>);
|
|
<a name="l301"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cFD>CFileNameTo</span><span class=cF7>(</span><span class=cF0>dname,name</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l302"></a> </span><span class=cF5>PrintErr</span><span class=cF0>(</span><span class=cF6>"Invalid FileName: \"%s\".\n"</span><span class=cF0>,name);
|
|
<a name="l303"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l304"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l305"></a> unlock=</span><span class=cF5>DrvLock</span><span class=cF0>(dv);
|
|
<a name="l306"></a> buf=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF3>BLK_SIZE</span><span class=cF0>*dv->spc);
|
|
<a name="l307"></a> entries_per_clus=dv->spc<<</span><span class=cF3>FAT32_ENTRIES_BITS</span><span class=cF0>;
|
|
<a name="l308"></a> </span><span class=cF5>ClusRead</span><span class=cF0>(dv,buf,cur_dir_clus,1);
|
|
<a name="l309"></a> cur_dir_entry=0;
|
|
<a name="l310"></a> </span><span class=cF1>while</span><span class=cF0> (ch=*buf[cur_dir_entry].name) {
|
|
<a name="l311"></a> attr=buf[cur_dir_entry].attr;
|
|
<a name="l312"></a> </span><span class=cF1>if</span><span class=cF0> (ch!=0xE5) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l313"></a> </span><span class=cF1>if</span><span class=cF0> (attr&</span><span class=cF3>RS_ATTR_LONG_NAME_MASK</span><span class=cF0>==</span><span class=cF3>RS_ATTR_LONG_NAME</span><span class=cF0>)
|
|
<a name="l314"></a> </span><span class=cFD>DirLongNameFill</span><span class=cF0>(&long_name,&buf[cur_dir_entry],&xsum);
|
|
<a name="l315"></a> </span><span class=cF1>else</span><span class=cF0> {
|
|
<a name="l316"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>attr&</span><span class=cF3>RS_ATTR_VOL_ID</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l317"></a> </span><span class=cF1>if</span><span class=cF0> (xsum==</span><span class=cFD>FATNameXSum</span><span class=cF7>(</span><span class=cF0>buf[cur_dir_entry].name</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l318"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(_res,&long_name,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l319"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l320"></a> </span><span class=cF5>MemSet</span><span class=cF0>(_res,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l321"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>fuf_flags&</span><span class=cF3>FUF_JUST_DIRS</span><span class=cF0> && !(attr & </span><span class=cF3>RS_ATTR_DIR</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0> &&
|
|
<a name="l322"></a> !</span><span class=cF7>(</span><span class=cF0>fuf_flags&</span><span class=cF3>FUF_JUST_FILES</span><span class=cF0> && attr & </span><span class=cF3>RS_ATTR_DIR</span><span class=cF7>)</span><span class=cF0> &&
|
|
<a name="l323"></a> </span><span class=cFD>FAT32CDirFill</span><span class=cF7>(</span><span class=cF0>_res,&buf[cur_dir_entry],
|
|
<a name="l324"></a> dv->fat32_local_time_offset</span><span class=cF7>)</span><span class=cF0> &&
|
|
<a name="l325"></a> !</span><span class=cF5>StrCmp</span><span class=cF7>(</span><span class=cF0>dname,_res->name</span><span class=cF7>)</span><span class=cF0>) {
|
|
<a name="l326"></a> res=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l327"></a> </span><span class=cF1>goto</span><span class=cF0> fff_done;
|
|
<a name="l328"></a> }
|
|
<a name="l329"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l330"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&long_name,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l331"></a> }
|
|
<a name="l332"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l333"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&long_name,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l334"></a> </span><span class=cF1>if</span><span class=cF0> (++cur_dir_entry==entries_per_clus) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l335"></a> cur_dir_clus=</span><span class=cF5>ClusNumNext</span><span class=cF0>(dv,cur_dir_clus);
|
|
<a name="l336"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>0<cur_dir_clus<0x0FFFFFF8</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l337"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l338"></a> </span><span class=cF1>else</span><span class=cF0> {
|
|
<a name="l339"></a> </span><span class=cF5>ClusRead</span><span class=cF0>(dv,buf,cur_dir_clus,1);
|
|
<a name="l340"></a> cur_dir_entry=0;
|
|
<a name="l341"></a> }
|
|
<a name="l342"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l343"></a> }
|
|
<a name="l344"></a> </span><span class=cF5>MemSet</span><span class=cF0>(_res,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l345"></a>fff_done:
|
|
<a name="l346"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
|
|
<a name="l347"></a> </span><span class=cF1>if</span><span class=cF0> (unlock)
|
|
<a name="l348"></a> </span><span class=cF5>DrvUnlock</span><span class=cF0>(dv);
|
|
<a name="l349"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0>
|
|
<a name="l350"></a> </span><span class=cF1>if</span><span class=cF0> (unlock)
|
|
<a name="l351"></a> </span><span class=cF5>DrvUnlock</span><span class=cF0>(dv);
|
|
<a name="l352"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l353"></a>}
|
|
<a name="l354"></a>
|
|
<a name="l355"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cFD>FAT32FileRead</span><span class=cF0>(</span><span class=cF9>CDrv</span><span class=cF0> *dv,</span><span class=cF1>U8</span><span class=cF0> *cur_dir,</span><span class=cF1>U8</span><span class=cF0> *filename,</span><span class=cF9>I64</span><span class=cF0> *_size,</span><span class=cF9>I64</span><span class=cF0> *_attr)
|
|
<a name="l356"></a>{
|
|
<a name="l357"></a> </span><span class=cF1>U8</span><span class=cF0> *buf=</span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l358"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> de;
|
|
<a name="l359"></a> </span><span class=cF9>I64</span><span class=cF0> c,blk_cnt,cur_dir_clus;
|
|
<a name="l360"></a> </span><span class=cF5>DrvChk</span><span class=cF0>(dv);
|
|
<a name="l361"></a> *_size=0;
|
|
<a name="l362"></a> *_attr=0;
|
|
<a name="l363"></a> </span><span class=cF1>if</span><span class=cF0> (dv->fs_type!=</span><span class=cF3>FSt_FAT32</span><span class=cF0>)
|
|
<a name="l364"></a> </span><span class=cF5>PrintErr</span><span class=cF0>(</span><span class=cF6>"Not FAT32 Drv\n"</span><span class=cF0>);
|
|
<a name="l365"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l366"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l367"></a> </span><span class=cF5>DrvLock</span><span class=cF0>(dv);
|
|
<a name="l368"></a> cur_dir_clus=</span><span class=cF5>Name2DirClus</span><span class=cF0>(dv,cur_dir);
|
|
<a name="l369"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFD>FAT32FileFind</span><span class=cF7>(</span><span class=cF0>dv,cur_dir_clus,filename,&de,</span><span class=cF3>FUF_JUST_FILES</span><span class=cF7>)</span><span class=cF0>) {
|
|
<a name="l370"></a> blk_cnt=(de.size+</span><span class=cF3>BLK_SIZE</span><span class=cF0>-1)>></span><span class=cF3>BLK_SIZE_BITS</span><span class=cF0>;
|
|
<a name="l371"></a> buf=</span><span class=cF5>MAlloc</span><span class=cF0>(blk_cnt<<</span><span class=cF3>BLK_SIZE_BITS</span><span class=cF0>+1);
|
|
<a name="l372"></a> c=de.clus;
|
|
<a name="l373"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>0<c<0x0FFFFFF8</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l374"></a> c=0x0FFFFFFF;
|
|
<a name="l375"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l376"></a> c=</span><span class=cF5>ClusBlkRead</span><span class=cF0>(dv,buf,c,blk_cnt);
|
|
<a name="l377"></a> buf[de.size]=0; </span><span class=cF2>//Terminate</span><span class=cF0>
|
|
<a name="l378"></a> *_size=de.size;
|
|
<a name="l379"></a> *_attr=</span><span class=cF5>FileAttr</span><span class=cF0>(de.name,de.attr);
|
|
<a name="l380"></a> }
|
|
<a name="l381"></a> </span><span class=cF5>DrvUnlock</span><span class=cF0>(dv);
|
|
<a name="l382"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0>
|
|
<a name="l383"></a> </span><span class=cF5>DrvUnlock</span><span class=cF0>(dv);
|
|
<a name="l384"></a> </span><span class=cF1>return</span><span class=cF0> buf;
|
|
<a name="l385"></a>}
|
|
<a name="l386"></a>
|
|
<a name="l387"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cFD>FAT32Cd</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *name,</span><span class=cF9>I64</span><span class=cF0> cur_dir_clus)
|
|
<a name="l388"></a>{
|
|
<a name="l389"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> de;
|
|
<a name="l390"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Fs</span><span class=cF0>->cur_dv->fs_type!=</span><span class=cF3>FSt_FAT32</span><span class=cF0>)
|
|
<a name="l391"></a> </span><span class=cF5>PrintErr</span><span class=cF0>(</span><span class=cF6>"Not FAT32 Drv\n"</span><span class=cF0>);
|
|
<a name="l392"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFD>FAT32FileFind</span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>->cur_dv,cur_dir_clus,name,&de,</span><span class=cF3>FUF_JUST_DIRS</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l393"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l394"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l395"></a> </span><span class=cF5>PrintErr</span><span class=cF0>(</span><span class=cF6>"File not found: \"%s\".\n"</span><span class=cF0>,name);
|
|
<a name="l396"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l397"></a>}
|
|
<a name="l398"></a>
|
|
<a name="l399"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>FAT32FreeClus</span><span class=cF0>(</span><span class=cF9>CDrv</span><span class=cF0> *dv,</span><span class=cF9>I64</span><span class=cF0> c)
|
|
<a name="l400"></a>{
|
|
<a name="l401"></a> </span><span class=cF9>I64</span><span class=cF0> next,saved_c=c;
|
|
<a name="l402"></a> </span><span class=cF1>Bool</span><span class=cF0> unlock,unlock_break;
|
|
<a name="l403"></a> </span><span class=cF5>DrvChk</span><span class=cF0>(dv);
|
|
<a name="l404"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>0<c<0x0FFFFFF8</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF1>return</span><span class=cF0>;
|
|
<a name="l405"></a> </span><span class=cF1>if</span><span class=cF0> (dv->fs_type!=</span><span class=cF3>FSt_FAT32</span><span class=cF0>)
|
|
<a name="l406"></a> </span><span class=cF5>PrintErr</span><span class=cF0>(</span><span class=cF6>"Not FAT32 Drv\n"</span><span class=cF0>);
|
|
<a name="l407"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l408"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l409"></a> unlock_break=</span><span class=cF5>BreakLock</span><span class=cF0>;
|
|
<a name="l410"></a> unlock=</span><span class=cF5>DrvLock</span><span class=cF0>(dv);
|
|
<a name="l411"></a> </span><span class=cFD>DrvFATBlkClean</span><span class=cF0>(dv);
|
|
<a name="l412"></a> </span><span class=cF1>do</span><span class=cF0> {
|
|
<a name="l413"></a> </span><span class=cFD>DrvFATBlkSet</span><span class=cF0>(dv,c,0);
|
|
<a name="l414"></a> next=dv->cur_fat_blk[c&(</span><span class=cF3>BLK_SIZE</span><span class=cF0>/4-1)];
|
|
<a name="l415"></a> dv->cur_fat_blk[c&(</span><span class=cF3>BLK_SIZE</span><span class=cF0>/4-1)]=0;
|
|
<a name="l416"></a> </span><span class=cF5>LBts</span><span class=cF0>(&dv->fat_blk_dirty,0);
|
|
<a name="l417"></a> c=next;
|
|
<a name="l418"></a> } </span><span class=cF1>while</span><span class=cF0> (0<c<0x0FFFFFF8);
|
|
<a name="l419"></a> </span><span class=cFD>DrvFATBlkClean</span><span class=cF0>(dv,0);
|
|
<a name="l420"></a>
|
|
<a name="l421"></a> c=saved_c;
|
|
<a name="l422"></a> </span><span class=cF1>do</span><span class=cF0> {
|
|
<a name="l423"></a> </span><span class=cFD>DrvFATBlkSet</span><span class=cF0>(dv,c,1);
|
|
<a name="l424"></a> next=dv->cur_fat_blk[c&(</span><span class=cF3>BLK_SIZE</span><span class=cF0>/4-1)];
|
|
<a name="l425"></a> dv->cur_fat_blk[c&(</span><span class=cF3>BLK_SIZE</span><span class=cF0>/4-1)]=0;
|
|
<a name="l426"></a> </span><span class=cF5>LBts</span><span class=cF0>(&dv->fat_blk_dirty,0);
|
|
<a name="l427"></a> c=next;
|
|
<a name="l428"></a> } </span><span class=cF1>while</span><span class=cF0> (0<c<0x0FFFFFF8);
|
|
<a name="l429"></a> </span><span class=cFD>DrvFATBlkClean</span><span class=cF0>(dv,1);
|
|
<a name="l430"></a> </span><span class=cF1>if</span><span class=cF0> (unlock)
|
|
<a name="l431"></a> </span><span class=cF5>DrvUnlock</span><span class=cF0>(dv);
|
|
<a name="l432"></a> </span><span class=cF1>if</span><span class=cF0> (unlock_break)
|
|
<a name="l433"></a> </span><span class=cF5>BreakUnlock</span><span class=cF0>;
|
|
<a name="l434"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l435"></a> </span><span class=cF1>if</span><span class=cF0> (unlock)
|
|
<a name="l436"></a> </span><span class=cF5>DrvUnlock</span><span class=cF0>(dv);
|
|
<a name="l437"></a> </span><span class=cF1>if</span><span class=cF0> (unlock_break)
|
|
<a name="l438"></a> </span><span class=cF5>BreakUnlock</span><span class=cF0>;
|
|
<a name="l439"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l440"></a>}
|
|
<a name="l441"></a>
|
|
<a name="l442"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cFD>FAT32AllocClus</span><span class=cF0>(</span><span class=cF9>CDrv</span><span class=cF0> *dv,</span><span class=cF9>I64</span><span class=cF0> c,</span><span class=cF9>I64</span><span class=cF0> cnt)
|
|
<a name="l443"></a>{
|
|
<a name="l444"></a> </span><span class=cF1>Bool</span><span class=cF0> wrap_around=</span><span class=cF3>FALSE</span><span class=cF0>,unlock,unlock_break;
|
|
<a name="l445"></a> </span><span class=cF9>I64</span><span class=cF0> first=</span><span class=cF3>INVALID_CLUS</span><span class=cF0>,j,l;
|
|
<a name="l446"></a>
|
|
<a name="l447"></a> </span><span class=cF1>if</span><span class=cF0> (cnt<=0) </span><span class=cF1>return</span><span class=cF0> 0x0FFFFFFF;
|
|
<a name="l448"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l449"></a> unlock_break=</span><span class=cF5>BreakLock</span><span class=cF0>;
|
|
<a name="l450"></a> unlock=</span><span class=cF5>DrvLock</span><span class=cF0>(dv);
|
|
<a name="l451"></a> l=(dv->size+dv->drv_offset-dv->data_area)/dv->spc-1;
|
|
<a name="l452"></a> j=dv->fis->most_recently_alloced;
|
|
<a name="l453"></a> </span><span class=cF1>while</span><span class=cF0> (cnt-->0) {
|
|
<a name="l454"></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="l455"></a> j++;
|
|
<a name="l456"></a> </span><span class=cF1>if</span><span class=cF0> (j<1) j=1;
|
|
<a name="l457"></a> </span><span class=cF1>if</span><span class=cF0> (j>=l) {
|
|
<a name="l458"></a> </span><span class=cF1>if</span><span class=cF0> (wrap_around)
|
|
<a name="l459"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'Drv'</span><span class=cF0>);
|
|
<a name="l460"></a> j=1;
|
|
<a name="l461"></a> wrap_around=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l462"></a> }
|
|
<a name="l463"></a> </span><span class=cFD>DrvFATBlkSet</span><span class=cF0>(dv,j);
|
|
<a name="l464"></a> </span><span class=cF1>if</span><span class=cF0> (!dv->cur_fat_blk[j&</span><span class=cF7>(</span><span class=cF3>BLK_SIZE</span><span class=cF0>/4-1</span><span class=cF7>)</span><span class=cF0>])
|
|
<a name="l465"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l466"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l467"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>0<first<0x0FFFFFF8</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l468"></a> first=j;
|
|
<a name="l469"></a> </span><span class=cF1>if</span><span class=cF0> (0<c<l) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l470"></a> </span><span class=cFD>DrvFATBlkSet</span><span class=cF0>(dv,c);
|
|
<a name="l471"></a> dv->cur_fat_blk[c&(</span><span class=cF3>BLK_SIZE</span><span class=cF0>/4-1)]=j;
|
|
<a name="l472"></a> </span><span class=cF5>LBts</span><span class=cF0>(&dv->fat_blk_dirty,0);
|
|
<a name="l473"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l474"></a> c=j;
|
|
<a name="l475"></a> }
|
|
<a name="l476"></a>
|
|
<a name="l477"></a> </span><span class=cF1>if</span><span class=cF0> (0<c<l) {
|
|
<a name="l478"></a> </span><span class=cFD>DrvFATBlkSet</span><span class=cF0>(dv,c);
|
|
<a name="l479"></a> dv->cur_fat_blk[c&(</span><span class=cF3>BLK_SIZE</span><span class=cF0>/4-1)]=0x0FFFFFFF;
|
|
<a name="l480"></a> </span><span class=cF5>LBts</span><span class=cF0>(&dv->fat_blk_dirty,0);
|
|
<a name="l481"></a> }
|
|
<a name="l482"></a> </span><span class=cFD>DrvFATBlkClean</span><span class=cF0>(dv);
|
|
<a name="l483"></a>
|
|
<a name="l484"></a> dv->fis->most_recently_alloced=j;
|
|
<a name="l485"></a> dv->fis->free_clus=-1;
|
|
<a name="l486"></a> </span><span class=cF5>BlkWrite</span><span class=cF0>(dv,dv->fis,dv->file_system_info_sect,1);
|
|
<a name="l487"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l488"></a> </span><span class=cF1>if</span><span class=cF0> (unlock)
|
|
<a name="l489"></a> </span><span class=cF5>DrvUnlock</span><span class=cF0>(dv);
|
|
<a name="l490"></a> </span><span class=cF1>if</span><span class=cF0> (unlock_break)
|
|
<a name="l491"></a> </span><span class=cF5>BreakUnlock</span><span class=cF0>;
|
|
<a name="l492"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l493"></a> </span><span class=cF1>if</span><span class=cF0> (unlock)
|
|
<a name="l494"></a> </span><span class=cF5>DrvUnlock</span><span class=cF0>(dv);
|
|
<a name="l495"></a> </span><span class=cF1>if</span><span class=cF0> (unlock_break)
|
|
<a name="l496"></a> </span><span class=cF5>BreakUnlock</span><span class=cF0>;
|
|
<a name="l497"></a> </span><span class=cF1>return</span><span class=cF0> first;
|
|
<a name="l498"></a>}
|
|
<a name="l499"></a>
|
|
<a name="l500"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cFD>FAT32AllocContiguousClus</span><span class=cF0>(</span><span class=cF9>CDrv</span><span class=cF0> *dv,</span><span class=cF9>I64</span><span class=cF0> cnt)
|
|
<a name="l501"></a>{
|
|
<a name="l502"></a> </span><span class=cF9>I64</span><span class=cF0> i,first=1;
|
|
<a name="l503"></a> </span><span class=cF1>Bool</span><span class=cF0> cont,unlock,unlock_break;
|
|
<a name="l504"></a>
|
|
<a name="l505"></a> </span><span class=cF1>if</span><span class=cF0> (cnt<=0) </span><span class=cF1>return</span><span class=cF0> 0x0FFFFFFF;
|
|
<a name="l506"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l507"></a> unlock_break=</span><span class=cF5>BreakLock</span><span class=cF0>;
|
|
<a name="l508"></a> unlock=</span><span class=cF5>DrvLock</span><span class=cF0>(dv);
|
|
<a name="l509"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) {
|
|
<a name="l510"></a> first++;
|
|
<a name="l511"></a> i=0;
|
|
<a name="l512"></a> cont=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l513"></a> </span><span class=cF1>while</span><span class=cF0> (cont && i<cnt) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l514"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>first+i+1</span><span class=cF7>)</span><span class=cF0>*dv->spc+dv->data_area>dv->size+dv->drv_offset)
|
|
<a name="l515"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'Drv'</span><span class=cF0>);
|
|
<a name="l516"></a> </span><span class=cFD>DrvFATBlkSet</span><span class=cF0>(dv,first+i);
|
|
<a name="l517"></a> </span><span class=cF1>if</span><span class=cF0> (dv->cur_fat_blk[</span><span class=cF7>(</span><span class=cF0>first+i</span><span class=cF7>)</span><span class=cF0>&</span><span class=cF7>(</span><span class=cF3>BLK_SIZE</span><span class=cF0>/4-1</span><span class=cF7>)</span><span class=cF0>])
|
|
<a name="l518"></a> cont=</span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l519"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l520"></a> i++;
|
|
<a name="l521"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l522"></a> </span><span class=cF1>if</span><span class=cF0> (!cont)
|
|
<a name="l523"></a> first=first+i;
|
|
<a name="l524"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l525"></a> </span><span class=cFD>DrvFATBlkClean</span><span class=cF0>(dv);
|
|
<a name="l526"></a>
|
|
<a name="l527"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<cnt;i++) {
|
|
<a name="l528"></a> </span><span class=cFD>DrvFATBlkSet</span><span class=cF0>(dv,first+i,0);
|
|
<a name="l529"></a> </span><span class=cF1>if</span><span class=cF0> (i+1==cnt)
|
|
<a name="l530"></a> dv->cur_fat_blk[(first+i)&(</span><span class=cF3>BLK_SIZE</span><span class=cF0>/4-1)]=0x0FFFFFFF;
|
|
<a name="l531"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l532"></a> dv->cur_fat_blk[(first+i)&(</span><span class=cF3>BLK_SIZE</span><span class=cF0>/4-1)]=first+i+1;
|
|
<a name="l533"></a> </span><span class=cF5>LBts</span><span class=cF0>(&dv->fat_blk_dirty,0);
|
|
<a name="l534"></a> }
|
|
<a name="l535"></a> </span><span class=cFD>DrvFATBlkClean</span><span class=cF0>(dv,0);
|
|
<a name="l536"></a>
|
|
<a name="l537"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<cnt;i++) {
|
|
<a name="l538"></a> </span><span class=cFD>DrvFATBlkSet</span><span class=cF0>(dv,first+i,1);
|
|
<a name="l539"></a> </span><span class=cF1>if</span><span class=cF0> (i+1==cnt)
|
|
<a name="l540"></a> dv->cur_fat_blk[(first+i)&(</span><span class=cF3>BLK_SIZE</span><span class=cF0>/4-1)]=0x0FFFFFFF;
|
|
<a name="l541"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l542"></a> dv->cur_fat_blk[(first+i)&(</span><span class=cF3>BLK_SIZE</span><span class=cF0>/4-1)]=first+i+1;
|
|
<a name="l543"></a> </span><span class=cF5>LBts</span><span class=cF0>(&dv->fat_blk_dirty,0);
|
|
<a name="l544"></a> }
|
|
<a name="l545"></a> </span><span class=cFD>DrvFATBlkClean</span><span class=cF0>(dv,1);
|
|
<a name="l546"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l547"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l548"></a> }
|
|
<a name="l549"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l550"></a> </span><span class=cF1>if</span><span class=cF0> (unlock)
|
|
<a name="l551"></a> </span><span class=cF5>DrvUnlock</span><span class=cF0>(dv);
|
|
<a name="l552"></a> </span><span class=cF1>if</span><span class=cF0> (unlock_break)
|
|
<a name="l553"></a> </span><span class=cF5>BreakUnlock</span><span class=cF0>;
|
|
<a name="l554"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l555"></a> </span><span class=cF1>if</span><span class=cF0> (unlock)
|
|
<a name="l556"></a> </span><span class=cF5>DrvUnlock</span><span class=cF0>(dv);
|
|
<a name="l557"></a> </span><span class=cF1>if</span><span class=cF0> (unlock_break)
|
|
<a name="l558"></a> </span><span class=cF5>BreakUnlock</span><span class=cF0>;
|
|
<a name="l559"></a> </span><span class=cF1>return</span><span class=cF0> first;
|
|
<a name="l560"></a>}
|
|
<a name="l561"></a>
|
|
<a name="l562"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cFD>FAT32DirNew</span><span class=cF0>(</span><span class=cF9>CDrv</span><span class=cF0> *dv,</span><span class=cF1>U8</span><span class=cF0> *cur_dir,</span><span class=cF9>CDirEntry</span><span class=cF0> *tmpde,</span><span class=cF1>Bool</span><span class=cF0> free_old_chain)
|
|
<a name="l563"></a>{
|
|
<a name="l564"></a></span><span class=cF2>//See </span><a href="/Wb/Doc/CutCorners.DD.HTML#l1"><span class=cF4>::/Doc/CutCorners.DD</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l565"></a> </span><span class=cF9>CFAT32DirEntry</span><span class=cF0> *buf,*last_buf,*tmp_buf,de[3];
|
|
<a name="l566"></a> </span><span class=cF9>I64</span><span class=cF0> i,attr,avail_cnt,de_cnt,c,
|
|
<a name="l567"></a> cur_dir_entry,entries_per_clus,
|
|
<a name="l568"></a> cur_dir_clus,xsum=0,last_dir_clus=</span><span class=cF3>INVALID_CLUS</span><span class=cF0>;
|
|
<a name="l569"></a> </span><span class=cF1>U8</span><span class=cF0> ch;
|
|
<a name="l570"></a> </span><span class=cF1>Bool</span><span class=cF0> written=</span><span class=cF3>FALSE</span><span class=cF0>,unlock,unlock_break;
|
|
<a name="l571"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> long_name;
|
|
<a name="l572"></a> </span><span class=cFD>FAT32DirFill</span><span class=cF0>(&de,tmpde,&de_cnt,dv->fat32_local_time_offset);
|
|
<a name="l573"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&long_name,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l574"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l575"></a> unlock_break=</span><span class=cF5>BreakLock</span><span class=cF0>;
|
|
<a name="l576"></a> unlock=</span><span class=cF5>DrvLock</span><span class=cF0>(dv);
|
|
<a name="l577"></a> cur_dir_clus=</span><span class=cF5>Name2DirClus</span><span class=cF0>(dv,cur_dir);
|
|
<a name="l578"></a> buf =</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF3>BLK_SIZE</span><span class=cF0>*dv->spc);
|
|
<a name="l579"></a> last_buf=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF3>BLK_SIZE</span><span class=cF0>*dv->spc);
|
|
<a name="l580"></a> entries_per_clus=dv->spc<<</span><span class=cF3>FAT32_ENTRIES_BITS</span><span class=cF0>;
|
|
<a name="l581"></a> </span><span class=cF5>ClusRead</span><span class=cF0>(dv,buf,cur_dir_clus,1);
|
|
<a name="l582"></a> cur_dir_entry=0;
|
|
<a name="l583"></a> </span><span class=cF1>while</span><span class=cF0> (ch=*buf[cur_dir_entry].name) {
|
|
<a name="l584"></a> attr=buf[cur_dir_entry].attr;
|
|
<a name="l585"></a> </span><span class=cF1>if</span><span class=cF0> (ch!=0xE5 && attr&</span><span class=cF3>RS_ATTR_LONG_NAME_MASK</span><span class=cF0>==</span><span class=cF3>RS_ATTR_LONG_NAME</span><span class=cF0>)
|
|
<a name="l586"></a> </span><span class=cFD>DirLongNameFill</span><span class=cF0>(&long_name,&buf[cur_dir_entry],&xsum);
|
|
<a name="l587"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l588"></a> avail_cnt=</span><span class=cF3>FAT32_ENTRIES_PER_BLK</span><span class=cF0>-cur_dir_entry
|
|
<a name="l589"></a> &(</span><span class=cF3>FAT32_ENTRIES_PER_BLK</span><span class=cF0>-1);
|
|
<a name="l590"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<avail_cnt;i++)
|
|
<a name="l591"></a> </span><span class=cF1>if</span><span class=cF0> (*buf[cur_dir_entry+i].name!=0xE5) {
|
|
<a name="l592"></a> </span><span class=cF1>if</span><span class=cF0> (*buf[cur_dir_entry+i].name)
|
|
<a name="l593"></a> avail_cnt=i;
|
|
<a name="l594"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l595"></a> }
|
|
<a name="l596"></a> </span><span class=cF1>if</span><span class=cF0> (ch==0xE5 && !written && avail_cnt>=de_cnt) {
|
|
<a name="l597"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(&buf[cur_dir_entry],&de,de_cnt*</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CFAT32DirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l598"></a> </span><span class=cF5>BlkWrite</span><span class=cF0>(dv,&buf[cur_dir_entry & -</span><span class=cF3>FAT32_ENTRIES_PER_BLK</span><span class=cF0>],
|
|
<a name="l599"></a> dv->data_area+cur_dir_clus*dv->spc
|
|
<a name="l600"></a> +cur_dir_entry>></span><span class=cF3>FAT32_ENTRIES_BITS</span><span class=cF0>,1);
|
|
<a name="l601"></a> cur_dir_entry+=de_cnt-1; </span><span class=cF2>//gets inc'ed</span><span class=cF0>
|
|
<a name="l602"></a> written=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l603"></a> } </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (ch!=0xE5 && !</span><span class=cF7>(</span><span class=cF0>attr&</span><span class=cF3>RS_ATTR_VOL_ID</span><span class=cF7>)</span><span class=cF0>) {
|
|
<a name="l604"></a> </span><span class=cF1>if</span><span class=cF0> (xsum!=</span><span class=cFD>FATNameXSum</span><span class=cF7>(</span><span class=cF0>buf[cur_dir_entry].name</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l605"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&long_name,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l606"></a> </span><span class=cF1>if</span><span class=cF0> (!*long_name.name)
|
|
<a name="l607"></a> </span><span class=cFD>FATFromName</span><span class=cF0>(long_name.name,buf[cur_dir_entry].name);
|
|
<a name="l608"></a></span><span class=cF2>//Del old entry with same name</span><span class=cF0>
|
|
<a name="l609"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>StrCmp</span><span class=cF7>(</span><span class=cF0>long_name.name,tmpde->name</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l610"></a> </span><span class=cF1>if</span><span class=cF0> (free_old_chain)
|
|
<a name="l611"></a> </span><span class=cF5>FAT32FreeClus</span><span class=cF0>(dv,buf[cur_dir_entry].clus_lo+
|
|
<a name="l612"></a> buf[cur_dir_entry].clus_hi<<16);
|
|
<a name="l613"></a> </span><span class=cF1>if</span><span class=cF0> (!written) {
|
|
<a name="l614"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(&buf[cur_dir_entry],&de[de_cnt-1],</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CFAT32DirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l615"></a> </span><span class=cF5>BlkWrite</span><span class=cF0>(dv,&buf[cur_dir_entry & -</span><span class=cF3>FAT32_ENTRIES_PER_BLK</span><span class=cF0>],
|
|
<a name="l616"></a> dv->data_area+cur_dir_clus*dv->spc
|
|
<a name="l617"></a> +cur_dir_entry>></span><span class=cF3>FAT32_ENTRIES_BITS</span><span class=cF0>,1);
|
|
<a name="l618"></a> written=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l619"></a> } </span><span class=cF1>else</span><span class=cF0> {
|
|
<a name="l620"></a> *buf[cur_dir_entry].name=0xE5;
|
|
<a name="l621"></a> i=1;
|
|
<a name="l622"></a> </span><span class=cF1>while</span><span class=cF0> (i<=cur_dir_entry &&
|
|
<a name="l623"></a> buf[cur_dir_entry-i].attr&</span><span class=cF3>RS_ATTR_LONG_NAME_MASK</span><span class=cF0>
|
|
<a name="l624"></a> ==</span><span class=cF3>RS_ATTR_LONG_NAME</span><span class=cF0>)
|
|
<a name="l625"></a> *buf[cur_dir_entry-i++].name=0xE5;
|
|
<a name="l626"></a> i--;
|
|
<a name="l627"></a> </span><span class=cF5>BlkWrite</span><span class=cF0>(dv,&buf[</span><span class=cF7>(</span><span class=cF0>cur_dir_entry-i</span><span class=cF7>)</span><span class=cF0>&-</span><span class=cF3>FAT32_ENTRIES_PER_BLK</span><span class=cF0>],
|
|
<a name="l628"></a> dv->data_area+cur_dir_clus*dv->spc
|
|
<a name="l629"></a> +</span><span class=cF7>(</span><span class=cF0>cur_dir_entry-i</span><span class=cF7>)</span><span class=cF0>>></span><span class=cF3>FAT32_ENTRIES_BITS</span><span class=cF0>,
|
|
<a name="l630"></a> </span><span class=cF7>(</span><span class=cF0>i+</span><span class=cF3>FAT32_ENTRIES_PER_BLK</span><span class=cF7>)</span><span class=cF0>>></span><span class=cF3>FAT32_ENTRIES_BITS</span><span class=cF0>);
|
|
<a name="l631"></a> </span><span class=cF1>if</span><span class=cF0> (i==cur_dir_entry && 0<last_dir_clus<0x0FFFFFF8) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l632"></a> i=1;
|
|
<a name="l633"></a> </span><span class=cF1>while</span><span class=cF0> (i<=entries_per_clus &&
|
|
<a name="l634"></a> last_buf[entries_per_clus-i].attr
|
|
<a name="l635"></a> &</span><span class=cF3>RS_ATTR_LONG_NAME_MASK</span><span class=cF0>==</span><span class=cF3>RS_ATTR_LONG_NAME</span><span class=cF0>)
|
|
<a name="l636"></a> *last_buf[entries_per_clus-i++].name=0xE5;
|
|
<a name="l637"></a> </span><span class=cF1>if</span><span class=cF0> (--i>0)
|
|
<a name="l638"></a> </span><span class=cF5>BlkWrite</span><span class=cF0>(dv,&buf[</span><span class=cF7>(</span><span class=cF0>entries_per_clus-i</span><span class=cF7>)</span><span class=cF0>&-</span><span class=cF3>FAT32_ENTRIES_PER_BLK</span><span class=cF0>],
|
|
<a name="l639"></a> dv->data_area+last_dir_clus*dv->spc
|
|
<a name="l640"></a> +</span><span class=cF7>(</span><span class=cF0>entries_per_clus-i</span><span class=cF7>)</span><span class=cF0>>></span><span class=cF3>FAT32_ENTRIES_BITS</span><span class=cF0>,
|
|
<a name="l641"></a> </span><span class=cF7>(</span><span class=cF0>i+</span><span class=cF3>FAT32_ENTRIES_PER_BLK</span><span class=cF0>-1</span><span class=cF7>)</span><span class=cF0>>></span><span class=cF3>FAT32_ENTRIES_BITS</span><span class=cF0>);
|
|
<a name="l642"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l643"></a> }
|
|
<a name="l644"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l645"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l646"></a> }
|
|
<a name="l647"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&long_name,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l648"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l649"></a> </span><span class=cF1>if</span><span class=cF0> (++cur_dir_entry==entries_per_clus) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l650"></a> last_dir_clus=cur_dir_clus;
|
|
<a name="l651"></a> tmp_buf=buf; buf=last_buf; last_buf=tmp_buf;
|
|
<a name="l652"></a> c=</span><span class=cF5>ClusNumNext</span><span class=cF0>(dv,cur_dir_clus);
|
|
<a name="l653"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>0<c<0x0FFFFFF8</span><span class=cF7>)</span><span class=cF0>) {
|
|
<a name="l654"></a> c=</span><span class=cF5>ClusAlloc</span><span class=cF0>(dv,cur_dir_clus,1,</span><span class=cF3>FALSE</span><span class=cF0>);
|
|
<a name="l655"></a> </span><span class=cF5>MemSet</span><span class=cF0>(buf,0,</span><span class=cF3>BLK_SIZE</span><span class=cF0>*dv->spc);
|
|
<a name="l656"></a> </span><span class=cF5>ClusWrite</span><span class=cF0>(dv,buf,c,1);
|
|
<a name="l657"></a> } </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l658"></a> </span><span class=cF5>ClusRead</span><span class=cF0>(dv,buf,c,1);
|
|
<a name="l659"></a> cur_dir_clus=c;
|
|
<a name="l660"></a> cur_dir_entry=0;
|
|
<a name="l661"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l662"></a> }
|
|
<a name="l663"></a> </span><span class=cF1>if</span><span class=cF0> (!written) {
|
|
<a name="l664"></a> avail_cnt=</span><span class=cF3>FAT32_ENTRIES_PER_BLK</span><span class=cF0>-cur_dir_entry & (</span><span class=cF3>FAT32_ENTRIES_PER_BLK</span><span class=cF0>-1);
|
|
<a name="l665"></a> </span><span class=cF1>if</span><span class=cF0> (avail_cnt<de_cnt) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l666"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<avail_cnt;i++)
|
|
<a name="l667"></a> *buf[cur_dir_entry+i].name=0xE5;
|
|
<a name="l668"></a> </span><span class=cF5>BlkWrite</span><span class=cF0>(dv,&buf[cur_dir_entry &-</span><span class=cF3>FAT32_ENTRIES_PER_BLK</span><span class=cF0>],
|
|
<a name="l669"></a> dv->data_area+cur_dir_clus*dv->spc
|
|
<a name="l670"></a> +cur_dir_entry>></span><span class=cF3>FAT32_ENTRIES_BITS</span><span class=cF0>,1);
|
|
<a name="l671"></a> cur_dir_entry+=avail_cnt;
|
|
<a name="l672"></a> </span><span class=cF1>if</span><span class=cF0> (cur_dir_entry==entries_per_clus) {
|
|
<a name="l673"></a> last_dir_clus=cur_dir_clus;
|
|
<a name="l674"></a> tmp_buf=buf; buf=last_buf; last_buf=tmp_buf;
|
|
<a name="l675"></a> cur_dir_clus=</span><span class=cF5>ClusAlloc</span><span class=cF0>(dv,cur_dir_clus,1);
|
|
<a name="l676"></a> cur_dir_entry=0;
|
|
<a name="l677"></a> </span><span class=cF5>MemSet</span><span class=cF0>(buf,0,</span><span class=cF3>BLK_SIZE</span><span class=cF0>*dv->spc);
|
|
<a name="l678"></a> </span><span class=cF5>ClusWrite</span><span class=cF0>(dv,buf,cur_dir_clus,1);
|
|
<a name="l679"></a> }
|
|
<a name="l680"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l681"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(&buf[cur_dir_entry],&de,de_cnt*</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CFAT32DirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l682"></a> </span><span class=cF5>BlkWrite</span><span class=cF0>(dv,&buf[cur_dir_entry &-</span><span class=cF3>FAT32_ENTRIES_PER_BLK</span><span class=cF0>],
|
|
<a name="l683"></a> dv->data_area+cur_dir_clus*dv->spc+
|
|
<a name="l684"></a> cur_dir_entry>></span><span class=cF3>FAT32_ENTRIES_BITS</span><span class=cF0>,1);
|
|
<a name="l685"></a> cur_dir_entry+=de_cnt;
|
|
<a name="l686"></a> </span><span class=cF1>if</span><span class=cF0> (cur_dir_entry==entries_per_clus) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l687"></a> cur_dir_clus=</span><span class=cF5>ClusAlloc</span><span class=cF0>(dv,cur_dir_clus,1);
|
|
<a name="l688"></a> </span><span class=cF5>MemSet</span><span class=cF0>(buf,0,</span><span class=cF3>BLK_SIZE</span><span class=cF0>*dv->spc);
|
|
<a name="l689"></a> </span><span class=cF5>ClusWrite</span><span class=cF0>(dv,buf,cur_dir_clus,1);
|
|
<a name="l690"></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="l691"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&buf[cur_dir_entry],0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CFAT32DirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l692"></a> </span><span class=cF5>BlkWrite</span><span class=cF0>(dv,&buf[cur_dir_entry &-</span><span class=cF3>FAT32_ENTRIES_PER_BLK</span><span class=cF0>],
|
|
<a name="l693"></a> dv->data_area+cur_dir_clus*dv->spc
|
|
<a name="l694"></a> +cur_dir_entry>></span><span class=cF3>FAT32_ENTRIES_BITS</span><span class=cF0>,1);
|
|
<a name="l695"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l696"></a> }
|
|
<a name="l697"></a> </span><span class=cF5>Free</span><span class=cF0>(last_buf);
|
|
<a name="l698"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
|
|
<a name="l699"></a> </span><span class=cF1>if</span><span class=cF0> (unlock)
|
|
<a name="l700"></a> </span><span class=cF5>DrvUnlock</span><span class=cF0>(dv);
|
|
<a name="l701"></a> </span><span class=cF1>if</span><span class=cF0> (unlock_break)
|
|
<a name="l702"></a> </span><span class=cF5>BreakUnlock</span><span class=cF0>;
|
|
<a name="l703"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l704"></a> </span><span class=cF1>if</span><span class=cF0> (unlock)
|
|
<a name="l705"></a> </span><span class=cF5>DrvUnlock</span><span class=cF0>(dv);
|
|
<a name="l706"></a> </span><span class=cF1>if</span><span class=cF0> (unlock_break)
|
|
<a name="l707"></a> </span><span class=cF5>BreakUnlock</span><span class=cF0>;
|
|
<a name="l708"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l709"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l710"></a>}
|
|
<a name="l711"></a>
|
|
<a name="l712"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cFD>FAT32FilesDel</span><span class=cF0>(</span><span class=cF9>CDrv</span><span class=cF0> *dv,</span><span class=cF1>U8</span><span class=cF0> *cur_dir,</span><span class=cF1>U8</span><span class=cF0> *files_find_mask,</span><span class=cF9>I64</span><span class=cF0> fuf_flags,
|
|
<a name="l713"></a> </span><span class=cF1>Bool</span><span class=cF0> del_dir,</span><span class=cF1>Bool</span><span class=cF0> print_msg)
|
|
<a name="l714"></a>{
|
|
<a name="l715"></a> </span><span class=cF9>CFAT32DirEntry</span><span class=cF0> *buf,*last_buf,*tmp_buf;
|
|
<a name="l716"></a> </span><span class=cF9>I64</span><span class=cF0> i,res=0,attr,xsum=0,last_dir_clus=</span><span class=cF3>INVALID_CLUS</span><span class=cF0>,
|
|
<a name="l717"></a> cur_dir_entry,entries_per_clus,cur_dir_clus;
|
|
<a name="l718"></a> </span><span class=cF1>U8</span><span class=cF0> ch;
|
|
<a name="l719"></a> </span><span class=cF1>Bool</span><span class=cF0> unlock_break;
|
|
<a name="l720"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> long_name;
|
|
<a name="l721"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&long_name,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l722"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l723"></a> unlock_break=</span><span class=cF5>BreakLock</span><span class=cF0>;
|
|
<a name="l724"></a> </span><span class=cF5>DrvLock</span><span class=cF0>(dv);
|
|
<a name="l725"></a> cur_dir_clus=</span><span class=cF5>Name2DirClus</span><span class=cF0>(dv,cur_dir);
|
|
<a name="l726"></a> buf =</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF3>BLK_SIZE</span><span class=cF0>*dv->spc);
|
|
<a name="l727"></a> last_buf=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF3>BLK_SIZE</span><span class=cF0>*dv->spc);
|
|
<a name="l728"></a> entries_per_clus=dv->spc<<</span><span class=cF3>FAT32_ENTRIES_BITS</span><span class=cF0>;
|
|
<a name="l729"></a> </span><span class=cF5>ClusRead</span><span class=cF0>(dv,buf,cur_dir_clus,1);
|
|
<a name="l730"></a> cur_dir_entry=0;
|
|
<a name="l731"></a> </span><span class=cF1>while</span><span class=cF0> (ch=*buf[cur_dir_entry].name) {
|
|
<a name="l732"></a> attr=buf[cur_dir_entry].attr;
|
|
<a name="l733"></a> </span><span class=cF1>if</span><span class=cF0> (ch!=0xE5 && ch!=</span><span class=cF6>'.'</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l734"></a> </span><span class=cF1>if</span><span class=cF0> (attr&</span><span class=cF3>RS_ATTR_LONG_NAME_MASK</span><span class=cF0>==</span><span class=cF3>RS_ATTR_LONG_NAME</span><span class=cF0>)
|
|
<a name="l735"></a> </span><span class=cFD>DirLongNameFill</span><span class=cF0>(&long_name,&buf[cur_dir_entry],&xsum);
|
|
<a name="l736"></a> </span><span class=cF1>else</span><span class=cF0> {
|
|
<a name="l737"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>attr & </span><span class=cF3>RS_ATTR_VOL_ID</span><span class=cF7>)</span><span class=cF0> &&
|
|
<a name="l738"></a> </span><span class=cF7>(</span><span class=cF0>del_dir || !(attr & </span><span class=cF3>RS_ATTR_DIR</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l739"></a> </span><span class=cF1>if</span><span class=cF0> (xsum!=</span><span class=cFD>FATNameXSum</span><span class=cF7>(</span><span class=cF0>buf[cur_dir_entry].name</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l740"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&long_name,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l741"></a> </span><span class=cF1>if</span><span class=cF0> (!*long_name.name)
|
|
<a name="l742"></a> </span><span class=cFD>FATFromName</span><span class=cF0>(long_name.name,buf[cur_dir_entry].name);
|
|
<a name="l743"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>FilesFindMatch</span><span class=cF7>(</span><span class=cF0>long_name.name,files_find_mask,fuf_flags</span><span class=cF7>)</span><span class=cF0>) {
|
|
<a name="l744"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>attr & </span><span class=cF3>RS_ATTR_DIR</span><span class=cF7>)</span><span class=cF0>) res++;
|
|
<a name="l745"></a> </span><span class=cF1>if</span><span class=cF0> (print_msg)
|
|
<a name="l746"></a> </span><span class=cF6>"Del %s\n"</span><span class=cF0>,long_name.name;
|
|
<a name="l747"></a> *buf[cur_dir_entry].name=0xE5;
|
|
<a name="l748"></a> i=1;
|
|
<a name="l749"></a> </span><span class=cF1>while</span><span class=cF0> (i<=cur_dir_entry &&
|
|
<a name="l750"></a> buf[cur_dir_entry-i].attr&</span><span class=cF3>RS_ATTR_LONG_NAME_MASK</span><span class=cF0>
|
|
<a name="l751"></a> ==</span><span class=cF3>RS_ATTR_LONG_NAME</span><span class=cF0>)
|
|
<a name="l752"></a> *buf[cur_dir_entry-i++].name=0xE5;
|
|
<a name="l753"></a> i--;
|
|
<a name="l754"></a> </span><span class=cF5>BlkWrite</span><span class=cF0>(dv,&buf[</span><span class=cF7>(</span><span class=cF0>cur_dir_entry-i</span><span class=cF7>)</span><span class=cF0>&-</span><span class=cF3>FAT32_ENTRIES_PER_BLK</span><span class=cF0>],
|
|
<a name="l755"></a> dv->data_area+cur_dir_clus*dv->spc
|
|
<a name="l756"></a> +</span><span class=cF7>(</span><span class=cF0>cur_dir_entry-i</span><span class=cF7>)</span><span class=cF0>>></span><span class=cF3>FAT32_ENTRIES_BITS</span><span class=cF0>,
|
|
<a name="l757"></a> </span><span class=cF7>(</span><span class=cF0>i+</span><span class=cF3>FAT32_ENTRIES_PER_BLK</span><span class=cF7>)</span><span class=cF0>>></span><span class=cF3>FAT32_ENTRIES_BITS</span><span class=cF0>);
|
|
<a name="l758"></a> </span><span class=cF1>if</span><span class=cF0> (i==cur_dir_entry && last_dir_clus!=</span><span class=cF3>INVALID_CLUS</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l759"></a> i=1;
|
|
<a name="l760"></a> </span><span class=cF1>while</span><span class=cF0> (i<=entries_per_clus &&
|
|
<a name="l761"></a> last_buf[entries_per_clus-i].attr
|
|
<a name="l762"></a> &</span><span class=cF3>RS_ATTR_LONG_NAME_MASK</span><span class=cF0>==</span><span class=cF3>RS_ATTR_LONG_NAME</span><span class=cF0>)
|
|
<a name="l763"></a> *last_buf[entries_per_clus-i++].name=0xE5;
|
|
<a name="l764"></a> </span><span class=cF1>if</span><span class=cF0> (--i>0)
|
|
<a name="l765"></a> </span><span class=cF5>BlkWrite</span><span class=cF0>(dv,&buf[</span><span class=cF7>(</span><span class=cF0>entries_per_clus-i</span><span class=cF7>)</span><span class=cF0>&-</span><span class=cF3>FAT32_ENTRIES_PER_BLK</span><span class=cF0>],
|
|
<a name="l766"></a> dv->data_area+last_dir_clus*dv->spc
|
|
<a name="l767"></a> +</span><span class=cF7>(</span><span class=cF0>entries_per_clus-i</span><span class=cF7>)</span><span class=cF0>>></span><span class=cF3>FAT32_ENTRIES_BITS</span><span class=cF0>,
|
|
<a name="l768"></a> </span><span class=cF7>(</span><span class=cF0>i+</span><span class=cF3>FAT32_ENTRIES_PER_BLK</span><span class=cF0>-1</span><span class=cF7>)</span><span class=cF0>>></span><span class=cF3>FAT32_ENTRIES_BITS</span><span class=cF0>);
|
|
<a name="l769"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l770"></a> </span><span class=cF5>FAT32FreeClus</span><span class=cF0>(dv,buf[cur_dir_entry].clus_lo+
|
|
<a name="l771"></a> buf[cur_dir_entry].clus_hi<<16);
|
|
<a name="l772"></a> }
|
|
<a name="l773"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l774"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&long_name,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l775"></a> }
|
|
<a name="l776"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l777"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&long_name,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l778"></a> </span><span class=cF1>if</span><span class=cF0> (++cur_dir_entry==entries_per_clus) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l779"></a> last_dir_clus=cur_dir_clus;
|
|
<a name="l780"></a> cur_dir_clus=</span><span class=cF5>ClusNumNext</span><span class=cF0>(dv,cur_dir_clus,1);
|
|
<a name="l781"></a> tmp_buf=buf; buf=last_buf; last_buf=tmp_buf;
|
|
<a name="l782"></a> </span><span class=cF5>ClusRead</span><span class=cF0>(dv,buf,cur_dir_clus,1);
|
|
<a name="l783"></a> cur_dir_entry=0;
|
|
<a name="l784"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l785"></a> }
|
|
<a name="l786"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
|
|
<a name="l787"></a> </span><span class=cF5>Free</span><span class=cF0>(last_buf);
|
|
<a name="l788"></a> </span><span class=cF5>DrvUnlock</span><span class=cF0>(dv);
|
|
<a name="l789"></a> </span><span class=cF1>if</span><span class=cF0> (unlock_break)
|
|
<a name="l790"></a> </span><span class=cF5>BreakUnlock</span><span class=cF0>;
|
|
<a name="l791"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l792"></a> </span><span class=cF5>DrvUnlock</span><span class=cF0>(dv);
|
|
<a name="l793"></a> </span><span class=cF1>if</span><span class=cF0> (unlock_break)
|
|
<a name="l794"></a> </span><span class=cF5>BreakUnlock</span><span class=cF0>;
|
|
<a name="l795"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l796"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l797"></a>}
|
|
<a name="l798"></a>
|
|
<a name="l799"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cFD>FAT32FileWrite</span><span class=cF0>(</span><span class=cF9>CDrv</span><span class=cF0> *dv,</span><span class=cF1>U8</span><span class=cF0> *cur_dir,</span><span class=cF1>U8</span><span class=cF0> *name,</span><span class=cF1>U8</span><span class=cF0> *buf,</span><span class=cF9>I64</span><span class=cF0> size,
|
|
<a name="l800"></a> </span><span class=cF9>CDate</span><span class=cF0> cdt,</span><span class=cF9>I64</span><span class=cF0> attr)
|
|
<a name="l801"></a>{
|
|
<a name="l802"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> de;
|
|
<a name="l803"></a> </span><span class=cF9>I64</span><span class=cF0> c=0,blk_cnt;
|
|
<a name="l804"></a> </span><span class=cF1>Bool</span><span class=cF0> contiguous;
|
|
<a name="l805"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&de,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l806"></a> </span><span class=cF1>if</span><span class=cF0> (size<0) size=0;
|
|
<a name="l807"></a> </span><span class=cF1>if</span><span class=cF0> (dv->fs_type!=</span><span class=cF3>FSt_FAT32</span><span class=cF0>)
|
|
<a name="l808"></a> </span><span class=cF5>PrintErr</span><span class=cF0>(</span><span class=cF6>"Not FAT32 Drv\n"</span><span class=cF0>);
|
|
<a name="l809"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cFD>CFileNameTo</span><span class=cF7>(</span><span class=cF0>de.name,name</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l810"></a> </span><span class=cF5>PrintErr</span><span class=cF0>(</span><span class=cF6>"Invalid FileName: \"%s\".\n"</span><span class=cF0>,name);
|
|
<a name="l811"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l812"></a> </span><span class=cFD>FAT32FilesDel</span><span class=cF0>(dv,cur_dir,de.name,0,</span><span class=cF3>FALSE</span><span class=cF0>,</span><span class=cF3>FALSE</span><span class=cF0>);
|
|
<a name="l813"></a> </span><span class=cF1>if</span><span class=cF0> (attr & </span><span class=cF3>RS_ATTR_CONTIGUOUS</span><span class=cF0>)
|
|
<a name="l814"></a> contiguous=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l815"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l816"></a> contiguous=</span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l817"></a> de.size=size;
|
|
<a name="l818"></a> </span><span class=cF1>if</span><span class=cF0> (blk_cnt=</span><span class=cF7>(</span><span class=cF0>size+</span><span class=cF3>BLK_SIZE</span><span class=cF0>-1</span><span class=cF7>)</span><span class=cF0>>></span><span class=cF3>BLK_SIZE_BITS</span><span class=cF0>)
|
|
<a name="l819"></a> c=</span><span class=cF5>ClusAlloc</span><span class=cF0>(dv,0,</span><span class=cF7>(</span><span class=cF0>blk_cnt+dv->spc-1</span><span class=cF7>)</span><span class=cF0>/dv->spc,contiguous);
|
|
<a name="l820"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l821"></a> c=0x0FFFFFFF;
|
|
<a name="l822"></a> de.clus=c;
|
|
<a name="l823"></a> de.attr=attr;
|
|
<a name="l824"></a> de.datetime=cdt;
|
|
<a name="l825"></a> </span><span class=cF1>if</span><span class=cF0> (blk_cnt)
|
|
<a name="l826"></a> </span><span class=cF5>ClusBlkWrite</span><span class=cF0>(dv,buf,c,blk_cnt);
|
|
<a name="l827"></a> </span><span class=cFD>FAT32DirNew</span><span class=cF0>(dv,cur_dir,&de,</span><span class=cF3>TRUE</span><span class=cF0>);
|
|
<a name="l828"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l829"></a> </span><span class=cF1>return</span><span class=cF0> c;
|
|
<a name="l830"></a>}
|
|
<a name="l831"></a>
|
|
<a name="l832"></a></span><span class=cF9>CDirEntry</span><span class=cF0> *</span><span class=cFD>FAT32FilesFind</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *files_find_mask,
|
|
<a name="l833"></a> </span><span class=cF9>I64</span><span class=cF0> fuf_flags,</span><span class=cF9>CDirEntry</span><span class=cF0> *parent=</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF9>I64</span><span class=cF0> *_dir_size=</span><span class=cF3>NULL</span><span class=cF0>)
|
|
<a name="l834"></a>{
|
|
<a name="l835"></a> </span><span class=cF9>CDrv</span><span class=cF0> *dv=</span><span class=cF5>Fs</span><span class=cF0>->cur_dv;
|
|
<a name="l836"></a> </span><span class=cF9>CFAT32DirEntry</span><span class=cF0> *buf;
|
|
<a name="l837"></a> </span><span class=cF9>I64</span><span class=cF0> attr,xsum=0,dir_size=0,sub_dir_size,
|
|
<a name="l838"></a> cur_dir_clus,cur_dir_entry,entries_per_clus;
|
|
<a name="l839"></a> </span><span class=cF1>U8</span><span class=cF0> ch;
|
|
<a name="l840"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> *res=</span><span class=cF3>NULL</span><span class=cF0>,*tmpde,long_name;
|
|
<a name="l841"></a> </span><span class=cF1>if</span><span class=cF0> (fuf_flags&~</span><span class=cF3>FUG_FILES_FIND</span><span class=cF0>)
|
|
<a name="l842"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'FUF'</span><span class=cF0>);
|
|
<a name="l843"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l844"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&long_name,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l845"></a> </span><span class=cF5>DrvLock</span><span class=cF0>(dv);
|
|
<a name="l846"></a> cur_dir_clus=</span><span class=cF5>Name2DirClus</span><span class=cF0>(dv,</span><span class=cF5>Fs</span><span class=cF0>->cur_dir);
|
|
<a name="l847"></a> buf=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF3>BLK_SIZE</span><span class=cF0>*dv->spc);
|
|
<a name="l848"></a> entries_per_clus=dv->spc<<</span><span class=cF3>FAT32_ENTRIES_BITS</span><span class=cF0>;
|
|
<a name="l849"></a> </span><span class=cF5>ClusRead</span><span class=cF0>(dv,buf,cur_dir_clus,1);
|
|
<a name="l850"></a> dir_size+=dv->spc*</span><span class=cF3>BLK_SIZE</span><span class=cF0>;
|
|
<a name="l851"></a> cur_dir_entry=0;
|
|
<a name="l852"></a> </span><span class=cF1>while</span><span class=cF0> (ch=*buf[cur_dir_entry].name) {
|
|
<a name="l853"></a> attr=buf[cur_dir_entry].attr;
|
|
<a name="l854"></a> </span><span class=cF1>if</span><span class=cF0> (ch!=0xE5) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l855"></a> </span><span class=cF1>if</span><span class=cF0> (attr&</span><span class=cF3>RS_ATTR_LONG_NAME_MASK</span><span class=cF0>==</span><span class=cF3>RS_ATTR_LONG_NAME</span><span class=cF0>)
|
|
<a name="l856"></a> </span><span class=cFD>DirLongNameFill</span><span class=cF0>(&long_name,&buf[cur_dir_entry],&xsum);
|
|
<a name="l857"></a> </span><span class=cF1>else</span><span class=cF0> {
|
|
<a name="l858"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>attr&</span><span class=cF3>RS_ATTR_VOL_ID</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l859"></a> tmpde=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l860"></a> </span><span class=cF1>if</span><span class=cF0> (xsum==</span><span class=cFD>FATNameXSum</span><span class=cF7>(</span><span class=cF0>buf[cur_dir_entry].name</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l861"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(tmpde,&long_name,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l862"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l863"></a> </span><span class=cF5>MemSet</span><span class=cF0>(tmpde,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l864"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFD>FAT32CDirFill</span><span class=cF7>(</span><span class=cF0>tmpde,&buf[cur_dir_entry],
|
|
<a name="l865"></a> dv->fat32_local_time_offset</span><span class=cF7>)</span><span class=cF0>) {
|
|
<a name="l866"></a> tmpde->parent=parent;
|
|
<a name="l867"></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_RECURSE</span><span class=cF7>)</span><span class=cF0> && attr&</span><span class=cF3>RS_ATTR_DIR</span><span class=cF0> &&
|
|
<a name="l868"></a> *tmpde->name!=</span><span class=cF6>'.'</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l869"></a> tmpde->next=res;
|
|
<a name="l870"></a> res=tmpde;
|
|
<a name="l871"></a> tmpde->full_name=</span><span class=cF5>DirNameAbs</span><span class=cF0>(tmpde->name);
|
|
<a name="l872"></a> </span><span class=cF5>DrvUnlock</span><span class=cF0>(dv);
|
|
<a name="l873"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Cd</span><span class=cF7>(</span><span class=cF0>tmpde->name</span><span class=cF7>)</span><span class=cF0>) {
|
|
<a name="l874"></a> tmpde->sub=</span><span class=cFD>FAT32FilesFind</span><span class=cF0>(files_find_mask,fuf_flags,
|
|
<a name="l875"></a> tmpde,&sub_dir_size);
|
|
<a name="l876"></a> tmpde->size=sub_dir_size;
|
|
<a name="l877"></a> </span><span class=cF5>Cd</span><span class=cF0>(</span><span class=cF6>".."</span><span class=cF0>);
|
|
<a name="l878"></a> }
|
|
<a name="l879"></a> </span><span class=cF5>DrvLock</span><span class=cF0>(dv);
|
|
<a name="l880"></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="l881"></a> tmpde->full_name=</span><span class=cF5>FileNameAbs</span><span class=cF0>(tmpde->name);
|
|
<a name="l882"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>attr&</span><span class=cF3>RS_ATTR_DIR</span><span class=cF0> || !</span><span class=cF5>Bt</span><span class=cF0>(&fuf_flags,</span><span class=cF3>FUf_JUST_DIRS</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0> &&
|
|
<a name="l883"></a> !</span><span class=cF7>(</span><span class=cF5>Bt</span><span class=cF0>(&fuf_flags,</span><span class=cF3>FUf_RECURSE</span><span class=cF0>) &&
|
|
<a name="l884"></a> *tmpde->name==</span><span class=cF6>'.'</span><span class=cF0> && attr&</span><span class=cF3>RS_ATTR_DIR</span><span class=cF7>)</span><span class=cF0> &&
|
|
<a name="l885"></a> </span><span class=cF5>FilesFindMatch</span><span class=cF7>(</span><span class=cF0>tmpde->full_name,files_find_mask,
|
|
<a name="l886"></a> fuf_flags</span><span class=cF7>)</span><span class=cF0>) {
|
|
<a name="l887"></a> tmpde->next=res;
|
|
<a name="l888"></a> res=tmpde;
|
|
<a name="l889"></a> } </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l890"></a> </span><span class=cF5>DirEntryDel</span><span class=cF0>(tmpde);
|
|
<a name="l891"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l892"></a> } </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l893"></a> </span><span class=cF5>DirEntryDel</span><span class=cF0>(tmpde);
|
|
<a name="l894"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l895"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&long_name,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l896"></a> }
|
|
<a name="l897"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l898"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&long_name,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l899"></a> </span><span class=cF1>if</span><span class=cF0> (++cur_dir_entry==entries_per_clus) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l900"></a> cur_dir_clus=</span><span class=cF5>ClusNumNext</span><span class=cF0>(dv,cur_dir_clus);
|
|
<a name="l901"></a> </span><span class=cF1>if</span><span class=cF0> (cur_dir_clus==</span><span class=cF3>INVALID_CLUS</span><span class=cF0>)
|
|
<a name="l902"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l903"></a> </span><span class=cF1>else</span><span class=cF0> {
|
|
<a name="l904"></a> </span><span class=cF5>ClusRead</span><span class=cF0>(dv,buf,cur_dir_clus,1);
|
|
<a name="l905"></a> dir_size+=dv->spc*</span><span class=cF3>BLK_SIZE</span><span class=cF0>;
|
|
<a name="l906"></a> cur_dir_entry=0;
|
|
<a name="l907"></a> }
|
|
<a name="l908"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l909"></a> }
|
|
<a name="l910"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
|
|
<a name="l911"></a> </span><span class=cF5>DrvUnlock</span><span class=cF0>(dv);
|
|
<a name="l912"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0>
|
|
<a name="l913"></a> </span><span class=cF5>DrvUnlock</span><span class=cF0>(dv);
|
|
<a name="l914"></a> </span><span class=cF1>if</span><span class=cF0> (_dir_size)
|
|
<a name="l915"></a> *_dir_size=dir_size;
|
|
<a name="l916"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l917"></a>}
|
|
<a name="l918"></a>
|
|
<a name="l919"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cFD>FAT32MkDir</span><span class=cF0>(</span><span class=cF9>CDrv</span><span class=cF0> *dv,</span><span class=cF1>U8</span><span class=cF0> *cur_dir,</span><span class=cF1>U8</span><span class=cF0> *name,</span><span class=cF9>I64</span><span class=cF0> entry_cnt)
|
|
<a name="l920"></a>{
|
|
<a name="l921"></a> </span><span class=cF9>I64</span><span class=cF0> c,cur_dir_clus=</span><span class=cF5>Name2DirClus</span><span class=cF0>(dv,cur_dir),
|
|
<a name="l922"></a></span><span class=cF2>//Rough estimate of size</span><span class=cF0>
|
|
<a name="l923"></a> size=</span><span class=cF5>CeilU64</span><span class=cF0>(</span><span class=cF7>(</span><span class=cF0>entry_cnt+2</span><span class=cF7>)</span><span class=cF0><<</span><span class=cF3>FAT32_ENTRIES_BITS</span><span class=cF0>,dv->spc<<</span><span class=cF3>BLK_SIZE_BITS</span><span class=cF0>);
|
|
<a name="l924"></a> </span><span class=cF1>U8</span><span class=cF0> *buf=</span><span class=cF5>CAlloc</span><span class=cF0>(size);
|
|
<a name="l925"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> d_native;
|
|
<a name="l926"></a> </span><span class=cF9>CFAT32DirEntry</span><span class=cF0> *dFAT=buf;
|
|
<a name="l927"></a> </span><span class=cF1>Bool</span><span class=cF0> unlock_break;
|
|
<a name="l928"></a>
|
|
<a name="l929"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l930"></a> unlock_break=</span><span class=cF5>BreakLock</span><span class=cF0>;
|
|
<a name="l931"></a> c=</span><span class=cF5>FileWrite</span><span class=cF0>(name,buf,size,0,</span><span class=cF3>RS_ATTR_DIR</span><span class=cF0>);
|
|
<a name="l932"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&d_native,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l933"></a> d_native.attr=</span><span class=cF3>RS_ATTR_DIR</span><span class=cF0>;
|
|
<a name="l934"></a> *d_native.name=</span><span class=cF6>'.'</span><span class=cF0>;
|
|
<a name="l935"></a> d_native.name[1]=0;
|
|
<a name="l936"></a> d_native.clus=c;
|
|
<a name="l937"></a> d_native.size=0;
|
|
<a name="l938"></a> d_native.datetime=</span><span class=cF5>Now</span><span class=cF0>;
|
|
<a name="l939"></a> </span><span class=cFD>FAT32DirFill</span><span class=cF0>(dFAT,&d_native,</span><span class=cF3>NULL</span><span class=cF0>,dv->fat32_local_time_offset);
|
|
<a name="l940"></a> dFAT++;
|
|
<a name="l941"></a>
|
|
<a name="l942"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&d_native,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDirEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l943"></a> d_native.attr=</span><span class=cF3>RS_ATTR_DIR</span><span class=cF0>;
|
|
<a name="l944"></a> *d_native.name=</span><span class=cF6>'.'</span><span class=cF0>;
|
|
<a name="l945"></a> d_native.name[1]=</span><span class=cF6>'.'</span><span class=cF0>;
|
|
<a name="l946"></a> d_native.name[2]=0;
|
|
<a name="l947"></a> d_native.clus=cur_dir_clus;
|
|
<a name="l948"></a> d_native.size=0;
|
|
<a name="l949"></a> d_native.datetime=</span><span class=cF5>Now</span><span class=cF0>;
|
|
<a name="l950"></a> </span><span class=cFD>FAT32DirFill</span><span class=cF0>(dFAT,&d_native,</span><span class=cF3>NULL</span><span class=cF0>,dv->fat32_local_time_offset);
|
|
<a name="l951"></a> </span><span class=cF5>ClusWrite</span><span class=cF0>(dv,buf,c,1);
|
|
<a name="l952"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
|
|
<a name="l953"></a> </span><span class=cF1>if</span><span class=cF0> (unlock_break)
|
|
<a name="l954"></a> </span><span class=cF5>BreakUnlock</span><span class=cF0>;
|
|
<a name="l955"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0>
|
|
<a name="l956"></a> </span><span class=cF1>if</span><span class=cF0> (unlock_break)
|
|
<a name="l957"></a> </span><span class=cF5>BreakUnlock</span><span class=cF0>;
|
|
<a name="l958"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l959"></a>}
|
|
</span></pre></body>
|
|
</html>
|