homemister
Joined: 24 Mar 2008 Posts: 25
|
Posted: Mon Jun 02, 2008 6:58 pm Post subject: getcwd in flash's and disc0:/ |
|
|
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: | 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 |
|