FX_FC.C
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:10k
- /**************************************************************************/
- /* */
- /* Copyright (c) 1996-2002 by Express Logic Inc. */
- /* */
- /* This software is copyrighted by and is the sole property of Express */
- /* Logic, Inc. All rights, title, ownership, or other interests */
- /* in the software remain the property of Express Logic, Inc. This */
- /* software may only be used in accordance with the corresponding */
- /* license agreement. Any unauthorized use, duplication, transmission, */
- /* distribution, or disclosure of this software is expressly forbidden. */
- /* */
- /* This Copyright notice may not be removed or modified without prior */
- /* written consent of Express Logic, Inc. */
- /* */
- /* Express Logic, Inc. reserves the right to modify this software */
- /* without notice. */
- /* */
- /* Express Logic, Inc. info@expresslogic.com */
- /* 11423 West Bernardo Court http://www.expresslogic.com */
- /* San Diego, CA 92127 */
- /* */
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /** */
- /** FileX Component */
- /** */
- /** File (FIL) */
- /** */
- /**************************************************************************/
- /**************************************************************************/
- #include "Config.h" // Global Configuration - do not remove!
- #ifdef ENABLE_FILEX
- #ifdef _DEBUG
- #undef IFTRACE
- #define IFTRACE if (gTraceFileSys)
- #include "DebugDbgMain.h"
- #endif //_DEBUG
- #define FX_SOURCE_CODE
- /* Include necessary system files. */
- #include "PlaycoreFileSysFileXfx_api.h"
- #include "PlaycoreFileSysFileXfx_sys.h"
- #include "PlaycoreFileSysFileXfx_fil.h"
- #include "PlaycoreFileSysFileXfx_uti.h"
- #include "PlaycoreFileSysFileXfx_dir.h"
- /**************************************************************************/
- /* */
- /* FUNCTION RELEASE */
- /* */
- /* _fx_file_close PORTABLE C */
- /* 3.0 */
- /* AUTHOR */
- /* */
- /* William E. Lamie, Express Logic, Inc. */
- /* */
- /* DESCRIPTION */
- /* */
- /* This function closes the specified file. If the file was written */
- /* to this function will also write the directory entry (with the new */
- /* size and time/date stamp) out to disk. */
- /* */
- /* INPUT */
- /* */
- /* file_ptr File control block pointer */
- /* */
- /* OUTPUT */
- /* */
- /* return status */
- /* */
- /* CALLS */
- /* */
- /* _fx_directory_entry_write Write the directory entry */
- /* _fx_utility_log_sector_flush Flush the written log sector */
- /* */
- /* CALLED BY */
- /* */
- /* Application Code */
- /* */
- /* RELEASE HISTORY */
- /* */
- /* DATE NAME DESCRIPTION */
- /* */
- /* 01-01-1999 William E. Lamie Initial Version 1.0 */
- /* 03-01-2000 William E. Lamie Modified comment(s), */
- /* resulting in version 1.0b. */
- /* 01-28-2001 William E. Lamie Modified comment(s), */
- /* resulting in version 2.0. */
- /* 03-01-2002 William E. Lamie Modified comment(s), */
- /* resulting in version 3.0. */
- /* */
- /**************************************************************************/
- UINT _fx_file_close(FX_FILE *file_ptr)
- {
- UINT status;
- FX_MEDIA *media_ptr;
- FX_INT_SAVE_AREA
- /* First, determine if the file is still open. */
- if (file_ptr -> fx_file_id != FX_FILE_ID)
- {
- /* Return the file not open error status. */
- return(FX_NOT_OPEN);
- }
- /* Setup a pointer to the associated media. */
- media_ptr = file_ptr -> fx_file_media_ptr;
- /* Protect against other threads accessing the media. */
- FX_PROTECT
- #if 0 // Alexei Brizguine. Never using FX_OPEN_FOR_WRITE flag
- /* Check to see if this file needs to have it's directory entry written
- back to the media. */
- if ((file_ptr -> fx_file_open_mode == FX_OPEN_FOR_WRITE) &&
- (file_ptr -> fx_file_modified))
- {
- /* Lockout interrupts for time/date access. */
- FX_DISABLE_INTS
- /* Set the new time and date. */
- file_ptr -> fx_file_dir_entry.fx_dir_entry_time = _fx_system_time;
- file_ptr -> fx_file_dir_entry.fx_dir_entry_date = _fx_system_date;
- /* Restore interrupts. */
- FX_RESTORE_INTS
- /* Copy the new file size into the directory entry. */
- file_ptr -> fx_file_dir_entry.fx_dir_entry_file_size =
- file_ptr -> fx_file_current_file_size;
- /* Write the directory entry to the media. */
- status = _fx_directory_entry_write(media_ptr, &(file_ptr -> fx_file_dir_entry));
- /* Check for a good status. */
- if (status != FX_SUCCESS)
- {
- /* Release media protection. */
- FX_UNPROTECT
- /* Error writing the directory. */
- return(status);
- }
- }
- #endif
- #if 0 // Jerry cai, don't maintain any list.
- /* Remove this file from the opened list for the media. */
- /* See if the file is the only one on the open list for this media. */
- if (file_ptr == file_ptr -> fx_file_opened_next)
- {
- /* Only opened file, just set the opened list to NULL. */
- media_ptr -> fx_media_opened_file_list = FX_NULL;
- }
- else
- {
- /* Otherwise, not the only opened file, link-up the neighbors. */
- (file_ptr -> fx_file_opened_next) -> fx_file_opened_previous =
- file_ptr -> fx_file_opened_previous;
- (file_ptr -> fx_file_opened_previous) -> fx_file_opened_next =
- file_ptr -> fx_file_opened_next;
- /* See if we have to update the opened list head pointer. */
- if (media_ptr -> fx_media_opened_file_list == file_ptr)
-
- /* Yes, move the head pointer to the next opened file. */
- media_ptr -> fx_media_opened_file_list = file_ptr -> fx_file_opened_next;
- }
- /* Decrement the opened file counter. */
- media_ptr -> fx_media_opened_file_count--;
- #endif
- /* Finally, Indicate that this file is closed. */
- file_ptr -> fx_file_id = FX_FILE_CLOSED_ID;
- #if 0 // Alexei Brizguine. Never using FX_OPEN_FOR_WRITE flag
- /* Flush the internal logical sector. */
- status = _fx_utility_log_sector_flush(media_ptr);
- #endif
- /* Release media protection. */
- FX_UNPROTECT
- /* Return status to the caller. */
- return(status);
- }
- #endif