FX_FOBA.c
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:5k
源码类别:

DVD

开发平台:

Others

  1. /*
  2. Author: Jerry CAI
  3.         Zoran China
  4. Created on: May 19 , 2003
  5. Descprition: The implementation file for function FX_FOBA(file open by address, for read only)        
  6. */
  7. #include "Config.h" // Global Configuration - do not remove!
  8. #ifdef ENABLE_FILEX
  9. /**************************************************************************/
  10. /**************************************************************************/
  11. /**                                                                       */ 
  12. /** FileX Component                                                       */ 
  13. /**                                                                       */
  14. /**   File (FIL)                                                          */
  15. /**                                                                       */
  16. /**************************************************************************/
  17. /**************************************************************************/
  18. #define FX_SOURCE_CODE
  19. /* Include necessary system files.  */
  20. #include "PlaycoreFileSysFileXfx_api.h"
  21. #include "PlaycoreFileSysFileXfx_sys.h"
  22. #include "PlaycoreFileSysFileXfx_dir.h"
  23. #include "PlaycoreFileSysFileXfx_fil.h"
  24. #include "PlaycoreFileSysFileXfx_uti.h"
  25. /**************************************************************************/
  26. /*                                                                        */ 
  27. /*  FUNCTION                                               RELEASE        */ 
  28. /*                                                                        */ 
  29. /*    _fx_file_open_by_addr                                               */ 
  30. /*                                                                        */ 
  31. /*                                                                        */ 
  32. /*  DESCRIPTION                                                           */ 
  33. /*                                                                        */ 
  34. /*    This function construct a file object with the given data           */ 
  35. /*                                                                        */ 
  36. /*  INPUT                                                                 */ 
  37. /*    media_ptr                            Media control block pointer    */
  38. /*    file_ptr                             File control block pointer     */ 
  39. /*    dwStartCluster                       The start cluster num          */ 
  40. /*    cbFileSize                           File size in bytes             */ 
  41. /*                                                                        */ 
  42. /*  OUTPUT                                                                */ 
  43. /*                                                                        */ 
  44. /*    return status                                                       */ 
  45. /*                                                                        */ 
  46. /*                                                                        */ 
  47. /*  CALLED BY                                                             */ 
  48. /*                                                                        */ 
  49. /*    Application Code                                                    */ 
  50. /*                                                                        */ 
  51. /**************************************************************************/ 
  52. UINT _fx_file_open_by_addr(FX_MEDIA *media_ptr, FX_FILE * file_ptr, ULONG dwStartCluster, UINT32 cbFileSize) 
  53. {
  54.   /* Check the media to make sure it is open.  */
  55.   if (media_ptr -> fx_media_id != FX_MEDIA_ID)
  56.   {
  57.       /* Return the media not opened error.  */
  58.       return(FX_MEDIA_NOT_OPEN);
  59.   }
  60.   /* Protect against other threads accessing the media.  */
  61.   FX_PROTECT
  62.   file_ptr->fx_file_id = FX_FILE_ID;
  63.   
  64.   //file_ptr->fx_file_name = NULL; //not available
  65.   
  66.   /* Define the open mode request.  */
  67.   file_ptr->fx_file_open_mode = FX_OPEN_FOR_READ;
  68.     /* Define the file modified field.  */
  69.   file_ptr->fx_file_modified = FX_FALSE;
  70.     /* Define the complete directory entry structure.  */
  71.   //file_ptr->fx_file_dir_entry; //not available, not used by file read.
  72.     /* Define the data storage parameters.  */
  73.   //file_ptr->fx_file_total_clusters;
  74.   file_ptr->fx_file_first_physical_cluster = dwStartCluster;
  75.   file_ptr->fx_file_consecutive_cluster = 1;
  76.   //file_ptr->fx_file_last_physical_cluster;
  77.   file_ptr->fx_file_current_physical_cluster = file_ptr->fx_file_first_physical_cluster;
  78.   //file_ptr->fx_file_current_logical_sector = 0;
  79.   file_ptr->fx_file_current_logical_offset = 0;
  80.   file_ptr->fx_file_current_relative_cluster = 0;
  81.   file_ptr->fx_file_current_relative_sector = 0;
  82.   file_ptr->fx_file_current_file_offset = 0;
  83.   file_ptr->fx_file_current_file_size = cbFileSize;
  84.   file_ptr->fx_file_current_available_size = cbFileSize;
  85.     /* Remember the media that is associated with this file. */
  86.   file_ptr->fx_file_media_ptr = media_ptr;
  87.     /* Define the pointers necessary to maintain the open file on 
  88.        the list of open files.  */
  89.   //file_ptr->fx_file_opened_next;
  90.   //file_ptr->fx_file_opened_previous;
  91.   
  92.   /* Release media protection.  */
  93.   FX_UNPROTECT
  94.   /* Open is complete, return successful status.  */
  95.   return _fx_file_seek(file_ptr, 0); // to calculate file_ptr->fx_file_current_logical_sector.
  96. }
  97. #endif //#ifdef ENABLE_FILEX