?? fat32.lst
字號:
488 1 {
489 2 fat_total_clusters += dclusters[i].number; /* calculate the total numbers of clusters */
490 2 }
491 1
492 1 fat_clear_dir_info(); /* clear directory variable */
493 1
494 1 Hard_read_open(fat_dir_start_sect);
495 1 do
496 1 {
497 2 for (i = 0; i < DIR_SIZE; i++)
498 2 gl_buffer[i] = fat_dgetc();
499 2
500 2 if (gl_buffer[0] != FILE_NOT_EXIST)
501 2 {
502 3 if (gl_buffer[0] != FILE_DELETED)
503 3 {
504 4 fat_nb_total_entries++; /* increase total number of entries */
505 4 while (gl_buffer[11] == ATTR_LFN_ENTRY)
506 4 {
507 5 for (i = 0; i < DIR_SIZE; i++)
508 5 gl_buffer[i] = fat_dgetc();
509 5 fat_nb_total_entries++; /* increase total number of entries */
510 5 }
511 4
512 4 fat_cache.current.attributes = gl_buffer[11]; /* filter on the file type */
513 4 ext[0] = gl_buffer[8];
514 4 ext[1] = gl_buffer[9];
515 4 ext[2] = gl_buffer[10];
516 4 if ((fat_check_ext() & current_ext) != FILE_XXX) /* Check if file type is OK */
517 4 {
518 5 fat_dir_list_last++; /* increase the number of selected entries */
519 5 }
520 4 }
521 3 else
522 3 {
523 4 fat_nb_deleted_entries++; /* increase number of deleted entries */
524 4 fat_nb_total_entries++; /* increase total number of entries */
525 4 }
526 3 }
527 2 else
528 2 {
529 3 exit = TRUE; /* "not exist" entries mark the end of directory */
530 3 }
531 2
532 2 if ((((Byte*)&fat_dclust_byte_count)[1] == 0x00) &&
533 2 ((((Byte*)&fat_dclust_byte_count)[0] & fat_cluster_mask) == 0x00) &&
534 2 (fat_last_dclust_index == fat_dchain_index))
535 2 {
536 3 exit = TRUE; /* if the last entries of the last cluster is reached */
537 3 fat_last_dir_cluster_full = TRUE; /* then exit and set this flag */
538 3 }
539 2 }
540 1 while (!exit);
541 1
542 1 Hard_read_close(); /* close disk */
543 1 if (fat_last_dir_cluster_full) /* if the last directory cluster is full */
544 1 {
545 2 if (!fat_nb_deleted_entries) /* and if there is no deleted entries detected */
546 2 {
547 3 fat_no_entries_free = TRUE; /* set this flag that there is no free entries */
C51 COMPILER V6.20c FAT32 10/19/2004 12:22:16 PAGE 10
548 3 }
549 2 }
550 1
551 1 fat_dir_current_sect = fat_dir_start_sect;
552 1 fat_clear_dir_info(); /* reset directory variable */
553 1
554 1 }
555
556
557 /*F**************************************************************************
558 * NAME: fat_fetch_file_info
559 *----------------------------------------------------------------------------
560 * PARAMS:
561 * entry: directory entry structure
562 *
563 * return:
564 *----------------------------------------------------------------------------
565 * PURPOSE:
566 * Get information about a directory or file entry
567 *----------------------------------------------------------------------------
568 * EXAMPLE:
569 *----------------------------------------------------------------------------
570 * NOTE:
571 *
572 *----------------------------------------------------------------------------
573 * REQUIREMENTS:
574 *****************************************************************************/
575 void fat_fetch_file_info (fat_st_dir_entry xdata *entry, bit direction)
576 {
577 1 Uint16 i;
578 1 Uint16 j;
579 1 bit entry_found = FALSE;
580 1
581 1 /* clear the name buffer */
582 1 for (i = MAX_FILENAME_LEN; i != 0; lfn_name[--i] = '\0');
583 1
584 1 if (direction == FETCH_PREV)
585 1 {
586 2 /* fetch previous file */
587 2 fat_current_start_entry_position--; /* seek to the previous entry */
588 2 fat_dir_current_offs = (fat_current_start_entry_position) * DIR_SIZE; /* update fat_dir_current_offs *
-/
589 2 fat_calc_cluster(); /* update directory position variable
-*/
590 2 j = (fat_current_start_entry_position % 16) * DIR_SIZE; /* seek to the previous entry */
591 2 fat_up_down_load_sector(fat_dir_current_sect, UPLOAD); /* load the directory sector */
592 2 do
593 2 {
594 3 if (fat_buf_sector[j] != FILE_DELETED) /* if it's not a deleted entries */
595 3 {
596 4 entry->attributes = fat_buf_sector[j + 11];
597 4 ext[0]= fat_buf_sector[j + 8];
598 4 ext[1]= fat_buf_sector[j + 9];
599 4 ext[2]= fat_buf_sector[j + 10];
600 4 if ((fat_check_ext() & current_ext) != FILE_XXX) /* check id of entry */
601 4 {
602 5 entry_found = TRUE;
603 5 }
604 4 }
605 3
606 3 if (!entry_found ) /* if id is not correct */
607 3 {
C51 COMPILER V6.20c FAT32 10/19/2004 12:22:16 PAGE 11
608 4 fat_dir_current_offs -= DIR_SIZE; /* seek to previous entry */
609 4 if (j == 0) /* sector change */
610 4 {
611 5 fat_calc_cluster();
612 5 fat_up_down_load_sector(fat_dir_current_sect, UPLOAD); /* load the directory sector */
613 5 j = SECTOR_SIZE - DIR_SIZE;
614 5 }
615 4 else
616 4 {
617 5 j -= DIR_SIZE;
618 5 }
619 4 fat_current_start_entry_position--;
620 4 }
621 3 }
622 2 while (!entry_found);
623 2
624 2 if (fat_current_start_entry_position != 0)
625 2 {
626 3 /* we find an entry. Now seek to previous entry for the process LFN */
627 3 fat_dir_current_offs -= DIR_SIZE; /* seek to previous entry */
628 3 if (j == 0) /* sector change */
629 3 {
630 4 fat_calc_cluster();
631 4 fat_up_down_load_sector(fat_dir_current_sect, UPLOAD); /* load the directory sector */
632 4 j = SECTOR_SIZE - DIR_SIZE;
633 4 }
634 3 else
635 3 {
636 4 j -= DIR_SIZE;
637 4 }
638 3 fat_current_start_entry_position--;
639 3 if (fat_buf_sector[j + 11] != ATTR_LFN_ENTRY)
640 3 {
641 4 fat_dir_current_offs += DIR_SIZE;
642 4 fat_current_start_entry_position++;
643 4 }
644 3 else
645 3 {
646 4 while ((fat_buf_sector[j + 11] == ATTR_LFN_ENTRY) && (fat_current_start_entry_position != 0))
647 4 {
648 5 fat_dir_current_offs -= DIR_SIZE;
649 5 fat_current_start_entry_position--;
650 5 if (j == 0) /* sector change */
651 5 {
652 6 fat_calc_cluster();
653 6 fat_up_down_load_sector(fat_dir_current_sect, UPLOAD); /* load the directory sector */
654 6 j = SECTOR_SIZE - DIR_SIZE;
655 6 }
656 5 else
657 5 {
658 6 j -= DIR_SIZE;
659 6 }
660 5 }
661 4
662 4 if (fat_current_start_entry_position)
663 4 {
664 5 fat_dir_current_offs += DIR_SIZE;
665 5 fat_current_start_entry_position++;
666 5 }
667 4 }
668 3
669 3 }
C51 COMPILER V6.20c FAT32 10/19/2004 12:22:16 PAGE 12
670 2
671 2 fat_current_end_entry_position = fat_current_start_entry_position;
672 2 fat_dseek(0);
673 2 }
674 1 else /* fetch next file */
675 1 {
676 2 fat_dseek((fat_current_end_entry_position - fat_current_start_entry_position) << 5);
677 2 }
678 1
679 1 do
680 1 {
681 2 fat_current_start_entry_position = fat_current_end_entry_position;
682 2 for (i = 0; i < DIR_SIZE; i++)
683 2 gl_buffer[i] = fat_dgetc();
684 2
685 2 while (gl_buffer[0] == FILE_DELETED) /* find a non deleted file */
686 2 {
687 3 fat_current_start_entry_position++;
688 3 fat_dir_current_offs += DIR_SIZE;
689 3 for (i = 0; i < DIR_SIZE; i++)
690 3 gl_buffer[i] = fat_dgetc();
691 3 }
692 2
693 2 fat_current_end_entry_position = fat_current_start_entry_position;
694 2
695 2 if (gl_buffer[11] == ATTR_LFN_ENTRY)
696 2 {
697 3 for (j = gl_buffer[0] & 0x0F; j != 0; j--) /* computes lfn name */
698 3 {
699 4 for (i = 0; i < 5; i++)
700 4 lfn_name[i + 13 * (j - 1)] = gl_buffer[2 * i + 1];
701 4 for (i = 0; i < 6; i++)
702 4 lfn_name[i + 5 + 13 * (j - 1)] = gl_buffer[2 * i + 14];
703 4 for (i = 0; i < 2; i++)
704 4 lfn_name[i + 11 + 13 * (j - 1)] = gl_buffer[2 * i + 28];
705 4
706 4 for (i = 0; i < DIR_SIZE; i++) /* read the directory entry */
707 4 gl_buffer[i] = fat_dgetc();
708 4 fat_current_end_entry_position++;
709 4 }
710 3 i = 0;
711 3 while (lfn_name[i] != '\0') /* search for the end of the string */
712 3 {
713 4 i++;
714 4 }
715 3 if (i <= 14) /* append spaces for display reason (no
-scrolling) */
716 3 {
717 4 while (i != 14)
718 4 {
719 5 lfn_name[i++] = ' ';
720 5 }
721 4 }
722 3 else
723 3 { /* append beginning of name to ease scrolling display */
724 4 lfn_name[i++] = ' ';
725 4 lfn_name[i++] = ' ';
726 4 lfn_name[i++] = lfn_name[0];
727 4 lfn_name[i++] = lfn_name[1];
728 4 lfn_name[i++] = lfn_name[2];
729 4 lfn_name[i++] = lfn_name[3];
730 4 lfn_name[i++] = lfn_name[4];
C51 COMPILER V6.20c FAT32 10/19/2004 12:22:16 PAGE 13
731 4 lfn_name[i++] = lfn_name[5];
732 4 lfn_name[i++] = lfn_name[6];
733 4 lfn_name[i++] = lfn_name[7];
734 4 lfn_name[i++] = lfn_name[8];
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -