Bfile OpenFile OS

From WikiPrizm
Revision as of 02:03, 10 March 2012 by Ahelper (talk | contribs) (Initial)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Synopsis

Syscall:

Function declaration: int Bfile_OpenFile_OS(const unsigned short* filename, int mode); (See alternative decl.)

This function is used to make a 16 bit string from an 8 bit character array.

Inputs

  • const unsigned short* filename - A 16 bit character array, most likely generated by Bfile_StrToName_ncpy.
  • int mode - The mode of which the file will be opened with.

Outputs

  • Returns < 0 if an error occurred.
  • Returns a handle (0 or greater) on success.

Comments

The following are the open modes that can be used:

  • 0 - READ - Opens a file in read-only mode.
  • 1 - READ_SHARE - Opens a file in read-only mode and cannot be modified by other add-ins (?)
  • 2 - WRITE - Opens a file in write-only mode.
  • 3 - READWRITE - Opens a file in read/write mode.
  • 4 - READWRITE_SHARE - Opens a file in read/write mode and cannot be modified by other add-ins (?)

As opposed to fopen, if you attempt to open a file in write mode that does not exist, this function will return a file not found error. You must use Bfile_CreateEntry_OS.

Alternative Declaration

This is a modified declaration that is more descriptive

typedef enum
{
  OPENMODE_READ = 0,
  OPENMODE_READ_SHARE,
  OPENMODE_WRITE,
  OPENMODE_READWRITE,
  OPENMODE_READWRITE_SHARE
} FILE_MODE;

int Bfile_OpenFile_OS(const unsigned short* filename, FILE_MODE mode);