static BOOL load_head( LOG_HEADER_T* head ) { BOOL create = FALSE; fs_handle_type file; sys_mkdir(LOG_DIR, 0700);//make directory.. if((file = pantech_fopen( LOG_PATH, O_RDONLY, S_IRUSR | S_IWUSR)) != NULL) { if( check_head_valid() == FALSE ) { create = TRUE; } pantech_fclose(file); } else { create = TRUE; } if( create == TRUE ) { if( create_log_file() == FALSE ) { return FALSE; } } file = open_log_file(); if( file == FS_NULL_HANDLE ) { return FALSE; } head->first_log_pos_ = get_value( file, FIRST_LOG_POS, 6 ); // FIRST LOG head->count_ = get_value( file, LOG_COUNT_POS, 4 ); // 로그수 head->head_ = get_value( file, HEAD_POS, 4 ); // head head->tail_ = get_value( file, TAIL_POS, 4 ); // tail head->free_head_ = get_value( file, FREE_HEAD_POS, 4 ); // free head if( head->first_log_pos_ == (UINT32)-1 || head->count_ == (UINT32)-1 || head->head_ == (UINT32)-1 || head->tail_ == (UINT32)-1 || head->free_head_ == (UINT32)-1 ) { goto _fail; } if( get_prev_next( file, head ) == FALSE ) { goto _fail; } pantech_fclose( file ); return TRUE; _fail: pantech_fclose( file ); return FALSE; }
bool DataHeader::read_prev() { if (offset == INVALID_OFFSET) return false; return get_prev_next(data.prev_file, data.prev_offset); }