base/fs/m_fs_path_norm.c
/* Normalize path separators in a path to the system separators. This will turn
 * / into \\ on Windows. */
Normalize path separators in a path to the system separators. This will turn
/ into \\ on Windows.
Normalize path separators in a path to the system separators . This will turn / into \\ on Windows .
static char *M_fs_path_norm_sep(const char *path, M_fs_system_t sys_type)
{
	M_buf_t *buf;
	size_t   len;
	size_t   i;
	char     sep;
	if (path == NULL) {
		return NULL;
	}
	sys_type = M_fs_path_get_system_type(sys_type);
	sep      = M_fs_path_get_system_sep(sys_type);
	len      = M_str_len(path);
	if (len >= M_fs_path_get_path_max(sys_type)) {
		return NULL;
	}
	buf    = M_buf_create();	
	for (i=0; i<len; i++) {
		if (sys_type == M_FS_SYSTEM_WINDOWS && path[i] == '/') {
			M_buf_add_byte(buf, (unsigned char)sep);
		} else {
			M_buf_add_byte(buf, (unsigned char)path[i]);
		}
	}
	return M_buf_finish_str(buf, NULL);
}
static char * M_fs_path_norm_sep ( const char * path , M_fs_system_t sys_type ) { M_buf_t * buf ; size_t len ; size_t i ; char sep ; if ( path == NULL ) { return NULL ; } sys_type = M_fs_path_get_system_type ( sys_type ) ; sep = M_fs_path_get_system_sep ( sys_type ) ; len = M_str_len ( path ) ; if ( len >= M_fs_path_get_path_max ( sys_type ) ) { return NULL ; } buf = M_buf_create ( ) ; for ( i = 0 ; i < len ; i ++ ) { if ( sys_type == M_FS_SYSTEM_WINDOWS && path [ i ] == ' ' ) { M_buf_add_byte ( buf , ( unsigned char ) sep ) ; } else { M_buf_add_byte ( buf , ( unsigned char ) path [ i ] ) ; } } return M_buf_finish_str ( buf , NULL ) ; }
Normalize path separators in a path to the system separators.
Normalize path separators in a path to the system separators .
/* Replace // or \\ with / or \ depending on the OS. */