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

📄 fat_8c-source.html

📁 方便飞利浦arm7tdmi 处理器lpc2100开发的C函数库 Procyon ARMlib-LPC2100 C-Language Function Library for Philips LPC21
💻 HTML
📖 第 1 页 / 共 4 页
字号:
00324                     <span class="keywordflow">if</span>(entrycount == entry)     00325                     {00326                         <span class="comment">// desired entry has been found, break out</span>00327                         gotEntry = 1;00328                         <span class="keywordflow">break</span>;00329                     }00330                     <span class="comment">// otherwise</span>00331                     entrycount++;           <span class="comment">// increment entry counter      </span>00332                 }00333             }00334         }00335         <span class="comment">// next directory entry</span>00336         de++;00337         <span class="comment">// next index</span>00338         index++;00339     }00340     00341     <span class="comment">// we have a file/dir to return</span>00342     <span class="comment">// store file/dir starting cluster (start of data)</span>00343     FileInfo.StartCluster = (<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span>) ((<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span>)de-&gt;deHighClust &lt;&lt; 16) + de-&gt;deStartCluster;00344     <span class="comment">// store file/dir size</span>00345     <span class="comment">// (note: size field for subdirectory entries is always zero)</span>00346     FileInfo.Size = de-&gt;deFileSize;00347     <span class="comment">// store file/dir attributes</span>00348     FileInfo.Attr = de-&gt;deAttributes;00349     <span class="comment">// store file/dir creation time</span>00350     FileInfo.CreateTime = de-&gt;deCTime[0] | de-&gt;deCTime[1]&lt;&lt;8;00351     <span class="comment">// store file/dir creation date</span>00352     FileInfo.CreateTime = de-&gt;deCDate[0] | de-&gt;deCDate[1]&lt;&lt;8;00353 00354     <span class="keywordflow">return</span> gotEntry;00355 }00356 00357 <span class="comment"></span>00358 <span class="comment">///////////////////////////////////////////////////////////////////////////////////</span>00359 <span class="comment"></span><span class="comment">/*</span>00360 <span class="comment">    index = 16; // crank it up</span>00361 <span class="comment">    do </span>00362 <span class="comment">    {</span>00363 <span class="comment">        if(index == 16) // time for next sector ?</span>00364 <span class="comment">        {</span>00365 <span class="comment">            ataReadSectors( DRIVE0, sector++, 1, SectorBuffer);</span>00366 <span class="comment">            de = (struct direntry *) SectorBuffer;</span>00367 <span class="comment">            index = 0;</span>00368 <span class="comment">        }</span>00369 <span class="comment">        </span>00370 <span class="comment">        // check if this is a deleted entry slot</span>00371 <span class="comment">        if(de-&gt;deName[0] != 0xE5)</span>00372 <span class="comment">        {</span>00373 <span class="comment">            // a valid entry</span>00374 <span class="comment">            // is it a part of a long file/dir name?</span>00375 <span class="comment">            if(de-&gt;deAttributes == ATTR_LONG_FILENAME)</span>00376 <span class="comment">            {</span>00377 <span class="comment">                // we have a long name entry</span>00378 <span class="comment">                // cast this directory entry as a "windows" (LFN: LongFileName) entry</span>00379 <span class="comment">                we = (struct winentry *) de;</span>00380 <span class="comment">                </span>00381 <span class="comment">                b = WIN_ENTRY_CHARS*( (we-&gt;weCnt-1) &amp; 0x0f);        // index into string</span>00382 <span class="comment">                fnbPtr = &amp;FileNameBuffer[b];</span>00383 <span class="comment">                for (i=0;i&lt;5;i++)   *fnbPtr++ = we-&gt;wePart1[i*2];   // copy first part</span>00384 <span class="comment">                for (i=0;i&lt;6;i++)   *fnbPtr++ = we-&gt;wePart2[i*2];   // second part</span>00385 <span class="comment">                for (i=0;i&lt;2;i++)   *fnbPtr++ = we-&gt;wePart3[i*2];   // and third part</span>00386 <span class="comment">                if (we-&gt;weCnt &amp; 0x40) *fnbPtr = 0;                  // in case dirnamelength is multiple of 13</span>00387 <span class="comment">                if ((we-&gt;weCnt &amp; 0x0f) == 1) hasBuffer = 1;     // mark that we have a long entry</span>00388 <span class="comment">            }</span>00389 <span class="comment">            else</span>00390 <span class="comment">            {</span>00391 <span class="comment">                // we have a short name entry</span>00392 <span class="comment">                </span>00393 <span class="comment">                // check if this is the end of a multi-part long name entry</span>00394 <span class="comment">                if(hasBuffer)</span>00395 <span class="comment">                {</span>00396 <span class="comment">                    // a long entry name has been collected</span>00397 <span class="comment">                    if(entrycount == entry)     </span>00398 <span class="comment">                    {</span>00399 <span class="comment">                        // desired entry has been found, break out</span>00400 <span class="comment">                        break;</span>00401 <span class="comment">                    }</span>00402 <span class="comment">                    </span>00403 <span class="comment">                    hasBuffer = 0;  // clear buffer </span>00404 <span class="comment">                    entrycount++;   // increment entry counter      </span>00405 <span class="comment">                }</span>00406 <span class="comment">                else</span>00407 <span class="comment">                {</span>00408 <span class="comment">                    // entry is a short name (8.3 format)</span>00409 <span class="comment">                    fnbPtr = FileNameBuffer;</span>00410 <span class="comment">                    for (i=0;i&lt;8;i++)   *fnbPtr++ = de-&gt;deName[i];      // copy name</span>00411 <span class="comment">                    *fnbPtr++ = '.';                                    // insert '.'</span>00412 <span class="comment">                    for (i=0;i&lt;3;i++)   *fnbPtr++ = de-&gt;deExtension[i]; // copy extension</span>00413 <span class="comment">                    *fnbPtr = 0;                                        // null-terminate</span>00414 <span class="comment"></span>00415 <span class="comment">                    if(entrycount == entry)     </span>00416 <span class="comment">                    {</span>00417 <span class="comment">                        // desired entry has been found, break out</span>00418 <span class="comment">                        hasBuffer = 1;</span>00419 <span class="comment">                        break;</span>00420 <span class="comment">                    }</span>00421 <span class="comment">                    entrycount++;   // increment entry counter      </span>00422 <span class="comment">                }</span>00423 <span class="comment">            }</span>00424 <span class="comment">        }</span>00425 <span class="comment">        // next directory entry</span>00426 <span class="comment">        de++;</span>00427 <span class="comment">        // next index</span>00428 <span class="comment">        index++;</span>00429 <span class="comment">    } while (*(de-&gt;deName) || index == 16); // 0 in de-&gt;deName[0] if no more entries</span>00430 <span class="comment">*/</span>00431 <span class="comment"></span>00432 <span class="comment">///////////////////////////////////////////////////////////////////////////////////</span>00433 <span class="comment"></span>00434                     <span class="comment">// is it a directory ?</span>00435 <span class="comment">/*                  if(de-&gt;deAttributes == ATTR_DIRECTORY)</span>00436 <span class="comment">                    {</span>00437 <span class="comment">                        unsigned long save = FirstDirCluster;</span>00438 <span class="comment">                        unsigned int save2 = baseentry;</span>00439 <span class="comment">                        unsigned long rval;</span>00440 <span class="comment">                        </span>00441 <span class="comment">                        strcpy(DirNameBuffer,FileNameBuffer);</span>00442 <span class="comment">                        strcat(DirNameBuffer,"/");</span>00443 <span class="comment"></span>00444 <span class="comment">//                      rprintfStr(FileNameBuffer); rprintfStr("/"); //EOL();</span>00445 <span class="comment"></span>00446 <span class="comment">                        // call recursively</span>00447 <span class="comment">                        FirstDirCluster = ((unsigned long)de-&gt;deHighClust &lt;&lt; 16) + de-&gt;deStartCluster;</span>00448 <span class="comment">                        rval = fatGetDirEntry(entry,1);</span>00449 <span class="comment">                        FirstDirCluster = save;</span>00450 <span class="comment">                        baseentry = save2;</span>00451 <span class="comment">                        if (rval)</span>00452 <span class="comment">                            return rval;</span>00453 <span class="comment">                        else    </span>00454 <span class="comment">                        {</span>00455 <span class="comment">                            // reload original sector</span>00456 <span class="comment">                            ataReadSectors( DRIVE0, sector-1, 1, SectorBuffer);</span>00457 <span class="comment">                            entrycount--;           // decrement entry counter      </span>00458 <span class="comment">                            *DirNameBuffer = 0;</span>00459 <span class="comment">                        }</span>00460 <span class="comment">                    }</span>00461 <span class="comment">                    else // normal file entry</span>00462 <span class="comment">*/</span><span class="comment"></span>00463 <span class="comment">//////////////////////////////////////////////////////////////////////////////////</span>00464 <span class="comment"></span>00465 <span class="comment">// change directory into </span>00466 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> fatChangeDirectory(<span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> entry)00467 {00468     <span class="comment">// get the requested directory entry</span>00469     <span class="keywordflow">if</span>( fatGetDirEntry(entry) )00470     {00471         <span class="comment">// make sure the entry is a directory</span>00472         <span class="keywordflow">if</span>(FileInfo.Attr &amp; ATTR_DIRECTORY)00473         {00474             <span class="comment">// change directories into this directory</span>00475             <span class="comment">// check to see if we are changing back to root directory</span>00476             <span class="keywordflow">if</span>(FileInfo.StartCluster)00477             {00478                 <span class="comment">// standard change directory</span>00479                 CurrentDirStartCluster = FileInfo.StartCluster;00480             }00481             <span class="keywordflow">else</span>00482             {00483                 <span class="comment">// if startCluster pointer is zero,</span>00484                 <span class="comment">// a change to the root directory is intended</span>00485                 <span class="comment">// change directory to root</span>00486                 CurrentDirStartCluster = RootDirStartCluster;00487             }00488             <span class="comment">// TODO: handle pathname properly for going up a directory</span>

⌨️ 快捷键说明

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