Difference between revisions of "Bfile CreateEntry OS"

From WikiPrizm
Jump to navigationJump to search
(Initial version)
 
Line 1: Line 1:
== Synopsis ==
+
{{syscall
 +
|signature = int Bfile_CreateEntry_OS(const unsigned short* filename, int mode, int *size);
 +
|synopsis = 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.
  
'''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:
 
The following are the modes that can be used:
 
* 1 - ''CREATEMODE_FILE'' - Makes a file using the size provided.
 
* 1 - ''CREATEMODE_FILE'' - Makes a file using the size provided.
 
* 5 - ''CREATEMODE_FOLDER'' - Makes a folder.  Size should be NULL.
 
* 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.
+
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. If you expect to be resizing a file while writing, it is preferred to use the [[:Category:Syscalls:MCS|main memory]].
 
+
}}
== Alternative Declaration ==
 
This is a modified declaration that is more descriptive
 
<nowiki>typedef enum
 
{
 
  CREATEMODE_FILE = 1,
 
  CREATEMODE_FOLDER = 5
 
} CREATE_MODE;
 
 
 
int Bfile_OpenFile_OS(const unsigned short* filename, CREATE_MODE mode, int* size);
 
</nowiki>
 

Revision as of 19:58, 9 June 2012


Synopsis

Header: Not documented
Syscall index: Not documented
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 not dynamically resizable. If you expect to be resizing a file while writing, it is preferred to use the main memory.