⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filesys_8c.html

📁 MP3 Player Source Code
💻 HTML
📖 第 1 页 / 共 5 页
字号:
00869   <span class="comment">/* OK, let's calculate */</span>00870   <span class="comment">/* First, let's get rid of the idea that we have byte addresses</span>00871 <span class="comment">     in the file system. Nope, let's only deal in physical disk</span>00872 <span class="comment">     sectors of 512 bytes. First we convert the FAT byter per sector</span>00873 <span class="comment">     value to "512B disk sectors per fat sector" value. */</span>00874 00875   <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o0">fat</a>.<a class="code" href="structDiskBlock_1_1Fat.html#o2">BPB_BytsPerSec</a> /= 512;00876 00877   <span class="comment">/* Then we adjust the Sector per Cluster to mean physical disk</span>00878 <span class="comment">     sectors. in 99% of the cases it is already so because bytes</span>00879 <span class="comment">     per sector almost always is 512 in FAT. Maximum cluster size</span>00880 <span class="comment">     is 65536 bytes (128 disk sectors). */</span>00881 00882   <a class="code" href="filesys_8c.html#a5">fatSectorsPerCluster</a> =00883     <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o0">fat</a>.<a class="code" href="structDiskBlock_1_1Fat.html#o3">BPB_SecPerClus</a> *= <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o0">fat</a>.<a class="code" href="structDiskBlock_1_1Fat.html#o2">BPB_BytsPerSec</a>;00884   <span class="comment">/* Note: BPB_BytsPerSec has already been divided by 512 */</span>  00885 00886   ConsoleWrite(<span class="stringliteral">"\rSectors per Cluster: "</span>);00887   ConsolePutUInt(fatSectorsPerCluster);00888   00889   <a class="code" href="filesys_8c.html#a2">fatStart</a> = (<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span>)<a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o0">l</a>00890     + (<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span>)<a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o0">fat</a>.<a class="code" href="structDiskBlock_1_1Fat.html#o4">BPB_RsvdSecCnt</a> 00891     * (<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span>)<a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o0">fat</a>.<a class="code" href="structDiskBlock_1_1Fat.html#o2">BPB_BytsPerSec</a>;00892 00893   ConsoleWrite(<span class="stringliteral">"\rFAT Start sector: "</span>);00894   ConsolePutUInt(fatStart);00895 00896   <a class="code" href="filesys_8c.html#a3">rootStart</a> = <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o0">fat</a>.<a class="code" href="structDiskBlock_1_1Fat.html#o9">BPB_FATSz16</a>;00897   <span class="keywordflow">if</span> (<a class="code" href="filesys_8c.html#a3">rootStart</a>==0){00898     <span class="keywordflow">if</span> (!<a class="code" href="filesys_8h.html#a0">IS_FAT_32</a>) 00899       <span class="keywordflow">return</span> 0x0b; <span class="comment">/* should be FAT32; can not find root directory */</span>00900     <a class="code" href="filesys_8c.html#a3">rootStart</a> = <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o0">fat</a>.<a class="code" href="structDiskBlock_1_1Fat.html#o14">ext</a>.<a class="code" href="unionDiskBlock_1_1Fat_1_1Extensions.html#o1">_32</a>.<a class="code" href="structDiskBlock_1_1Fat_1_1Extensions_1_1Fat32Specific.html#o0">BPB_FATSz32</a>;00901   }00902   <a class="code" href="filesys_8c.html#a3">rootStart</a> *= <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o0">fat</a>.<a class="code" href="structDiskBlock_1_1Fat.html#o5">BPB_NumFATs</a>;00903   <a class="code" href="filesys_8c.html#a3">rootStart</a> *= <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o0">fat</a>.<a class="code" href="structDiskBlock_1_1Fat.html#o2">BPB_BytsPerSec</a>; <span class="comment">/* ADJUSTED BytsPerSec! */</span>00904   <a class="code" href="filesys_8c.html#a3">rootStart</a> += <a class="code" href="filesys_8c.html#a2">fatStart</a>;00905 00906   ConsoleWrite(<span class="stringliteral">"\rRoot start sector: "</span>);00907   ConsolePutUInt(rootStart);00908 00909   <a class="code" href="filesys_8c.html#a4">dataStart</a> = <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o0">fat</a>.<a class="code" href="structDiskBlock_1_1Fat.html#o6">BPB_RootEntCnt</a> &gt;&gt; 4;00910   <a class="code" href="filesys_8c.html#a4">dataStart</a> += <a class="code" href="filesys_8c.html#a3">rootStart</a>;00911   <a class="code" href="filesys_8c.html#a4">dataStart</a> -= (<a class="code" href="filesys_8c.html#a5">fatSectorsPerCluster</a>*2); <span class="comment">/*first cluster is cluster 2*/</span>00912 00913   ConsoleWrite(<span class="stringliteral">"\rData start sector: "</span>);00914   ConsolePutUInt(dataStart);00915   ConsolePutChar(13);00916 00917   <span class="keywordflow">return</span> 0;00918 }</div></pre>    </td>  </tr></table><a class="anchor" name="a21" doxytag="filesys.c::FGetChar" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> Public unsigned char FGetChar           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="mdname1" valign="top" nowrap>          </td>          <td class="md" valign="top">&nbsp;)&nbsp;</td>          <td class="md" nowrap></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Read a character from current file. <p>This can be called after calling OpenFile. It is a slow method for reading character based file data. fileSize holds the number of characters still left in file to be read, check for fileSize=0 to detect end-of-file. If FGetChar is called after the end of file is reached, it does nothing and returns 0. <p>Definition at line <a class="el" href="filesys_8c-source.html#l00561">561</a> of file <a class="el" href="filesys_8c-source.html">filesys.c</a>.<p>References <a class="el" href="buffer_8h-source.html#l00107">DiskBlock::Raw::buf</a>, <a class="el" href="buffer_8c-source.html#l00013">dataBufPtr</a>, <a class="el" href="buffer_8c-source.html#l00010">diskSect</a>, <a class="el" href="filesys_8c-source.html#l00047">fileSize</a>, <a class="el" href="buffer_8h-source.html#l00129">Address::l</a>, <a class="el" href="filesys_8c-source.html#l00541">LoadNextSector()</a>, <a class="el" href="board_8h-source.html#l00262">Public</a>, <a class="el" href="unionDiskBlock.html#o1">DiskBlock::raw</a>, <a class="el" href="storage_8c-source.html#l00110">ReadDiskSector()</a>, and <a class="el" href="buffer_8c-source.html#l00015">sectorAddress</a>.<p>Referenced by <a class="el" href="aviplay_8c-source.html#l00015">GetAVIBlock()</a>.<p><pre class="fragment"><div>00561                                {00562 00563   <span class="keywordflow">if</span> (!<a class="code" href="filesys_8c.html#a7">fileSize</a>) <span class="keywordflow">return</span> 0; <span class="comment">//return 0 for end-of-file</span>00564 00565   <span class="keywordflow">if</span> (<a class="code" href="buffer_8c.html#a1">dataBufPtr</a>==0){00566     <span class="comment">/* A file has been opened but not read from yet, so read the first</span>00567 <span class="comment">       sector. */</span>00568     <a class="code" href="storage_8h.html#a2">ReadDiskSector</a>(<a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o0">l</a>);00569     <a class="code" href="buffer_8c.html#a1">dataBufPtr</a> = <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>;00570   }00571 00572   <span class="keywordflow">if</span> (<a class="code" href="buffer_8c.html#a1">dataBufPtr</a>&gt;<a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>+511){00573     <span class="comment">/* An end of sector has been reached, read the next sector */</span>    00574     <span class="keywordflow">if</span> (<a class="code" href="filesys_8c.html#a20">LoadNextSector</a>()){00575       <span class="comment">/* Error, end-of-file according to FAT records */</span>00576       <span class="keywordflow">return</span> 0; <span class="comment">/* must return something */</span>00577     }00578     <a class="code" href="buffer_8c.html#a1">dataBufPtr</a>=<a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>;00579   }00580 00581   <span class="comment">/* Everything should now be ok for reading a byte. */</span>00582 00583   <a class="code" href="filesys_8c.html#a7">fileSize</a>--;00584   <span class="keywordflow">return</span> (*<a class="code" href="buffer_8c.html#a1">dataBufPtr</a>++);00585 }</div></pre><p>Here is the call graph for this function:<p><center><img src="filesys_8c_a21_cgraph.png" border="0" usemap="#filesys_8c_a21_cgraph_map" alt=""></center><map name="filesys_8c_a21_cgraph_map"><area href="filesys_8c.html#a20" shape="rect" coords="133,56,235,80" alt=""><area href="storage_8h.html#a2" shape="rect" coords="429,56,530,80" alt=""><area href="filesys_8c.html#a18" shape="rect" coords="285,6,378,30" alt=""></map>    </td>  </tr></table><a class="anchor" name="a15" doxytag="filesys.c::GetFatEntry" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> unsigned long GetFatEntry           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">unsigned long&nbsp;</td>          <td class="mdname1" valign="top" nowrap> <em>clusterNumber</em>          </td>          <td class="md" valign="top">&nbsp;)&nbsp;</td>          <td class="md" nowrap></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Return the FAT entry for cluster clusterNumber. <p><p>Definition at line <a class="el" href="filesys_8c-source.html#l00085">85</a> of file <a class="el" href="filesys_8c-source.html">filesys.c</a>.<p>References <a class="el" href="buffer_8c-source.html#l00010">diskSect</a>, <a class="el" href="buffer_8h-source.html#l00114">DiskBlock::Fat16Table</a>, <a class="el" href="buffer_8h-source.html#l00117">DiskBlock::Fat32Table</a>, <a class="el" href="filesys_8c-source.html#l00021">fatStart</a>, <a class="el" href="filesys_8h-source.html#l00015">IS_FAT_32</a>, <a class="el" href="buffer_8h-source.html#l00129">Address::l</a>, <a class="el" href="storage_8c-source.html#l00110">ReadDiskSector()</a>, and <a class="el" href="buffer_8c-source.html#l00015">sectorAddress</a>.<p>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -