Synopsis #

Header: fxcg/file.h
Syscall index: 0x1DAE
Function signature: int Bfile_CreateEntry_OS(const unsigned short* filename, int mode, int *size)

Creates a file or folder in storage memory.

Parameters #

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

Returns #

0 on success, or a negative error code on failure.

Comments #

Does not return a handle for created files. Use Bfile_OpenFile_OS after a successful creation.

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 dynamically expandable (using Bfile_WriteFile_OS past the end of a file), but currently there’s no known way to shrink a file. You can delete and re-create to reduce a file’s size; if you expect to do it frequently, using the main memory may be more appropriate.

Using Bfile functions while user timers are installed can cause SYSTEM ERRORs and other undefined behavior, especially with functions that change data on the file system. Make sure to stop and uninstall all timers before using Bfile functions (and optionally restore them later). See Incompatibility_between_Bfile_Syscalls_and_Timers for more information.