getcwd in flash's and disc0:/

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
homemister
Posts: 25
Joined: Mon Mar 24, 2008 12:16 pm

getcwd in flash's and disc0:/

Post by homemister »

hi,
i have been struggling with geting the current working directory (getcwd(path,265)). i am trying to be able to acsess the flash directories and be able to browse throught them. and return the cwd.
here is some of my code

Code: Select all

int fcwd = 0;
char *cwdpath = "";
static int lua_getCurrentDirectory(lua_State *L)
{
	
	char path[256];
	//cwdpath = getcwd(path,256);
	lua_pushstring(L, cwdpath);
	return 1;
}

static int lua_setCurrentDirectory(lua_State *L)
{
	char *path = luaL_checkstring(L, 1);
	if(!path) return luaL_error(L, "Argument error: System.currentDirectory(file) takes a filename as string as argument.");
	char *ddp = strpbrk (":",path);
	if(ddp != NULL)
	{
		sceIoChdir(path);
		chdir(path);
		cwdpath = path;
		lua_pushstring(L, cwdpath);
		return 1;
	}
	if(strcmp(cwdpath,"ms0:/") == 0)
	{
		sceIoChdir(path);
		chdir(path);
		strcat(cwdpath, path);
		lua_pushstring(L, cwdpath);
		return 1;
	}
	if(strcmp(cwdpath,"disc0:/") == 0)
	{
		sceIoChdir(path);
		chdir(path);
		strcat(cwdpath, path);
		lua_pushstring(L, cwdpath);
		return 1;
	}
		sceIoChdir(path);
		chdir(path);
		strcat(cwdpath, "/");
		strcat(cwdpath, path);
		lua_getCurrentDirectory(L);
	return 1;
}
Regards
Homemister
Post Reply