BUG: incorrect way of detecting if a file is a directory

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

BUG: incorrect way of detecting if a file is a directory

Post by moonlight »

There is a bug in luasystem.cpp, in the function lua_dir(lua_State *L).
The following code is NOT the correct way of checking if a file is a directory:

lua_pushboolean(L, g_dir.d_stat.st_attr & FIO_SO_IFDIR);

Even if that works with memory sticks and flash devices, it fails with umd's.

The correct way to check if a file is adirectory is:

lua_pushboolean(L, FIO_S_ISDIR(g_dir.d_stat.st_mode));

(this is the bug that causes LuaFileManager to list umd directories as files, i hope this helps to solve that bug)
glynnder
Posts: 35
Joined: Sun Sep 04, 2005 9:54 pm

Post by glynnder »

Ahhhh, that doesn't work on flash0 or flash1 either!

I hope either a) Shine or b) any other decent coder can change that.
Then maybe lua fm will work even better!
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

Here i leave a precompiled binary of LuaPlayer-0.17dk2 with that bug solved.

http://rapidshare.de/files/17099461/EBOOT.PBP.html

To make Lua FileManager work properly with umd's, simply replace the EBOOT.PBP with that one.
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Re: BUG: incorrect way of detecting if a file is a directory

Post by Shine »

moonlight wrote:The correct way to check if a file is adirectory is:

lua_pushboolean(L, FIO_S_ISDIR(g_dir.d_stat.st_mode));
Thanks, I've fixed this, will be in the next version.
mallchin
Posts: 36
Joined: Thu Feb 16, 2006 2:03 am

Post by mallchin »

moonlight wrote:Here i leave a precompiled binary of LuaPlayer-0.17dk2 with that bug solved.

http://rapidshare.de/files/17099461/EBOOT.PBP.html

To make Lua FileManager work properly with umd's, simply replace the EBOOT.PBP with that one.
Great, thanks.

I'll include this in the next release unless Shine updates LuaPlayer upstream.
Post Reply