fsopen.c 649 Bytes
#include <PR/bcp.h>
#include "os.h"
#include "os_bbfs.h"
#include "bbint.h"

s32
osBbFOpen(const char* name, const char* mode) {
    unsigned char fname[BB_INODE16_NAMELEN];
    int i;
    s32 rv;
    BbFat16* fat;
    __osBbFsFormatName(fname, name);
    if (!fname[0]) return BBFS_ERR_INVALID;
    if ((rv = __osBbFsGetAccess()) < 0) return rv;
    fat = __osBbFat;
    for(i = 0; i < BB_INODE16_ENTRIES; i++) {
	if (fat->inode[i].type &&
	    bcmp(fname, fat->inode[i].name, BB_INODE16_NAMELEN) == 0) {
	    /*XXXblythe mark as open? */
	    rv = i;
	    goto out;
	}
    }
    rv = BBFS_ERR_ENTRY;
out:
    __osBbFsRelAccess();
    return rv;
}