Bfile CreateEntry OS

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

Synopsis

Syscall:

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

This function is used to create a file or folder in the storage memory.

Inputs

  • const unsigned short* filename - A 16 bit character array, most likely generated by Bfile_StrToName_ncpy.
  • int mode - Used to determine whether a file or folder will be made.
  • int* size - A pointer to the size of the file, NULL if making a folder.

Outputs

  • Returns < 0 if an error occurred.
  • Returns 0 on success. Does not return a handle for created files. Use Bfile_OpenFile_OS after a successful creation.

Comments

The following are the modes that can be used:

  • 1 - CREATEMODE_FILE - Makes a file using the size provided.
  • 5 - CREATEMODE_FOLDER - Makes a folder. Size should be NULL.

This function is a combination of fopen's file creation and mkdir. Please note that the size of the file must be set upon creation. Files are not dynamically resizable.

Alternative Declaration

This is a modified declaration that is more descriptive

typedef enum
{
  CREATEMODE_FILE = 1,
  CREATEMODE_FOLDER = 5
} CREATE_MODE;

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