Ejemplo n.º 1
0
int io_mkdir(const char* path)
{
	/* Remember the current directory */
	char cwd[8192];
	platform_getcwd(cwd, 8192);

	/* Split the path and check each part in turn */
	strcpy(buffer, path);
	path = buffer;

	while (path != NULL)
	{
		char* ptr = strchr(path, '/');
		if (ptr != NULL)
			*ptr = '\0';

		platform_mkdir(path);
		platform_chdir(path);

		path = (ptr != NULL) ? ptr + 1 : NULL;
	}

	/* Restore the original working directory */
	platform_chdir(cwd);
	return 1;
}
Ejemplo n.º 2
0
const char* path_absolute(const char* path)
{
	char  relative[8192];
	char* ptr;

	strcpy(relative, path);
	if (strlen(relative) == 0)
		strcpy(relative, ".");
	path_translateInPlace(relative, "posix");

	/* If the directory is already absolute I don't have to do anything */
	if (platform_isAbsolutePath(relative))
		return path;

	/* Figure out where I am currently */
	platform_getcwd(working, 8192);
	path_translateInPlace(working, "posix");

	/* Split the target path and add it in piece by piece */
	ptr = relative;
	while (ptr != NULL)
	{
		char* end = strchr(ptr, '/');
		if (end != NULL)
			*end = '\0';

		if (matches(ptr, ".."))
		{
			char* sep = strrchr(working, '/');
			if (sep != NULL)
				*sep = '\0';
		}
		else if (!matches(ptr, "."))
		{
			strcat(working, "/");
			strcat(working, ptr);
		}

		ptr = (end != NULL) ? end + 1 : NULL;
	}

	return working;
}
Ejemplo n.º 3
0
const char* io_getcwd()
{
	platform_getcwd(buffer, 8192);
	return buffer;
}