log/m_log_file.c
/* Open the head logfile, update file creation time. */
Open the head logfile, update file creation time.
Open the head logfile update file creation time .
static M_fs_error_t open_head_logfile(writer_thunk_t *wdata, M_bool is_rotate)
{
	M_fs_error_t err;
	size_t       buf_size;
	if (wdata == NULL) {
		return M_FS_ERROR_INVALID;
	}
	buf_size = 0;
	err = M_fs_file_open(&wdata->fstream, wdata->log_file_path, buf_size,
		M_FS_FILE_MODE_WRITE | M_FS_FILE_MODE_APPEND, NULL);
	if (is_rotate) {
		wdata->log_file_create_time = M_time();
		wdata->log_file_size        = 0;
	} else if (err == M_FS_ERROR_SUCCESS) {
		M_fs_info_t *info;
		M_fs_info(&info, wdata->log_file_path, M_FS_PATH_INFO_FLAGS_BASIC);
		wdata->log_file_create_time = M_fs_info_get_btime(info);
		wdata->log_file_size        = M_fs_info_get_size(info);
		if (wdata->log_file_create_time <= 0) {
			wdata->log_file_create_time = M_time();
		}
		M_fs_info_destroy(info);
	}
	return err;
}
static M_fs_error_t open_head_logfile ( writer_thunk_t * wdata , M_bool is_rotate ) { M_fs_error_t err ; size_t buf_size ; if ( wdata == NULL ) { return M_FS_ERROR_INVALID ; } buf_size = 0 ; err = M_fs_file_open ( & wdata -> fstream , wdata -> log_file_path , buf_size , M_FS_FILE_MODE_WRITE | M_FS_FILE_MODE_APPEND , NULL ) ; if ( is_rotate ) { wdata -> log_file_create_time = M_time ( ) ; wdata -> log_file_size = 0 ; } else if ( err == M_FS_ERROR_SUCCESS ) { M_fs_info_t * info ; M_fs_info ( & info , wdata -> log_file_path , M_FS_PATH_INFO_FLAGS_BASIC ) ; wdata -> log_file_create_time = M_fs_info_get_btime ( info ) ; wdata -> log_file_size = M_fs_info_get_size ( info ) ; if ( wdata -> log_file_create_time <= 0 ) { wdata -> log_file_create_time = M_time ( ) ; } M_fs_info_destroy ( info ) ; } return err ; }
Open the head logfile, update file creation time.
Open the head logfile update file creation time .
/* TODO: do we need the extra buf? It's currently turned off. Need to performance test. */ /* We know the file has to be new, so don't bother checking the filesystem for creation time and size.
		 * NOTE: this is an attempted workaround for a windows logging issue we can't reproduce (one line per file)
		 */ /* If we aren't creating a new file after a rotate, we want to try and get the creation time and size from
		 * the filesystem, in case we just opened an existing file.
		 */ /* If we couldn't get a file creation time from the filesystem, just use the current time. */