PS2Client & Directory Listing

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
User avatar
evilo
Posts: 230
Joined: Thu Apr 22, 2004 8:40 pm
Contact:

PS2Client & Directory Listing

Post by evilo »

hi,

in ps2link.c I see :

Code: Select all

  // Convert the mode.
  mode = (stats.st_mode & 0x07);
  if (S_ISDIR(stats.st_mode)) { mode |= 0x20; }
#ifndef _WIN32
  if (S_ISLNK(stats.st_mode)) { mode |= 0x08; }
#endif
  if (S_ISREG(stats.st_mode)) { mode |= 0x10; }

now, when i'm using dread from my software I get mode equals to 0x25 for a directory. Is it normal ? Since based on sys\stat.h, for a directory I should have the value 0x1000 (once masked) ?

Code: Select all

// File mode flags
#define FIO_S_IFMT		0xF000		// Format mask
#define FIO_S_IFLNK		0x4000		// Symbolic link
#define FIO_S_IFREG		0x2000		// Regular file
#define FIO_S_IFDIR		0x1000		// Directory

#define FIO_S_ISDIR(m)	(((m) & FIO_S_IFMT) == FIO_S_IFDIR)
So today I cannot use the "standard" following condition to test for a directory

Code: Select all

S_ISDIR(dircontent.stat.mode)
but this

Code: Select all

(dircontent.stat.mode==0x25)
Is there something i'm missing or the ps2link.c code should be instead :

Code: Select all

  // Convert the mode.
  mode = (stats.st_mode & 0x07);
  if (S_ISDIR(stats.st_mode)) { mode |= 0x1000; }
#ifndef _WIN32
  if (S_ISLNK(stats.st_mode)) { mode |= 0x4000; }
#endif
  if (S_ISREG(stats.st_mode)) { mode |= 0x2000; }
thank you.
evilo

[EDIT]
1st, wrong place anyway, should be under "PS2 Software development",sorry...

then I just only saw that...

Code: Select all


/* The following defines are only supported by ioman.  */

// File mode flags (for mode in io_stat_t)
#define FIO_SO_IFMT		0x0038		// Format mask
#define FIO_SO_IFLNK		0x0008		// Symbolic link
#define FIO_SO_IFREG		0x0010		// Regular file
#define FIO_SO_IFDIR		0x0020		// Directory

#define FIO_SO_IROTH		0x0004		// read
#define FIO_SO_IWOTH		0x0002		// write
#define FIO_SO_IXOTH		0x0001		// execute

// File mode checking macros
#define FIO_SO_ISLNK(m)	(((m) & FIO_SO_IFMT) == FIO_SO_IFLNK)
#define FIO_SO_ISREG(m)	(((m) & FIO_SO_IFMT) == FIO_SO_IFREG)
#define FIO_SO_ISDIR(m)	(((m) & FIO_SO_IFMT) == FIO_SO_IFDIR)
so ioman has it's own specific values, and FIO_SO_ISDIR(dircontent.stat.mode) is working like a charm :)

sorry ...
Post Reply