news.PalmOS.com wrote:
The code is as follow:

    Err resultSet;
    uint32_t fileAttr;
    VFSFileOpen(gSelectedVolRefNum, FilePath, vfsModeReadWrite,
&fileDetails);
    VFSFileGetAttributes(fileDetails, &fileAttr);
    resultSet = VFSFileSetAttributes(fileDetails, isReadonly ? fileAttr |
vfsFileAttrReadOnly : fileAttr & ~vfsFileAttrReadOnly);
    VFSFileClose(fileDetails);

It works well if the file is a regular file ,but return error 0x0502 if the
file is directory.

0x0502 is sysErrParamErr.  That means one of the arguments is bad.

Since both of your arguments' values come from variables that are
set by system calls (VFSFileOpen() and VFSFileGetAttributes()),
I would start by checking the return values of both those functions
to make sure they are really succeeding.  Perhaps you are not actually
able to open the directory or perhaps you are not able to get its
attributes.  Knowing the error code from these two functions might
give you helpful information.

By the way, to convert a numeric error code into its symbol (which is
more meaningful, typically), the easiest way I know of is to look
for the first byte in Incs/Core/System/ErrorBase.h.  For example,
that header says that 0x0500 is sysErrorClass.  Once you know it's
sysErrorClass, you can search all the include files for that string,
and you will find a file that contains the error class and it will
have the specific error types for that class.  For example,
Incs/Core/System/SystemMgr.h has sysErrParamErr in it, which
is defined as "(sysErrorClass | 2)", and thus 0x0502.

  - Logan

--
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/

Reply via email to