Isomet Modular Synthesiser (iMS) API  v1.4.2
iMS API
List of all members
iMS::UserFileWriter Class Reference

Provides a mechanism for committing User File data to the Synthesiser FileSystem. More...

#include <include\FileSystem.h>

Public Member Functions

Constructor & Destructor
 UserFileWriter (IMSSystem &ims, const std::vector< std::uint8_t > &file_data, const std::string file_name)
 Constructor for UserFileWriter Object. More...
 
 ~UserFileWriter ()
 Destructor for UserFileWriter.
 

File Write Core Function

FileSystemIndex Program ()
 Stores User File data into a FileSystem and allocates a new FileSystemTableEntry. More...
 

Detailed Description

Provides a mechanism for committing User File data to the Synthesiser FileSystem.

Author
Dave Cowan
Date
2016-01-21
Since
1.1

Constructor & Destructor Documentation

iMS::UserFileWriter::UserFileWriter ( IMSSystem ims,
const std::vector< std::uint8_t > &  file_data,
const std::string  file_name 
)

Constructor for UserFileWriter Object.

The UserFileWriter object requires an IMSSystem object, which will have had its FileSystemTable read back during initialisation. It must therefore exist before the UserFileWriter object, and must remain valid (not destroyed) until the UserFileWriter object itself is destroyed.

A reference to the User File data wrapped in an unformatted byte array needs to be provided, along with a string representing the file name to allocate to the file in the FileSystemTable.

The File Name may be any sequence of valid ASCII characters, including all special characters ($, %, /, \ etc) but not control characters. It is limited to 8 characters and will be truncated as such. Though not recommended, it is permissible to allocate the same filename to multiple files contained in the FileSystemTable

Once constructed, the object can neither be copied or assigned to another instance.

Parameters
[in]imsA const reference to the iMS System whose FileSystemTable should be used for writing new data
[in]file_dataan unformatted byte array containing the User File contents to program
[in]file_namea string representing the name of the file to be allocated in the FileSystemTable
Since
1.1

Member Function Documentation

FileSystemIndex iMS::UserFileWriter::Program ( )

Stores User File data into a FileSystem and allocates a new FileSystemTableEntry.

Call this function to initiate writing of the provided User File data into the FileSystem.

The function will first attempt to find sufficient free space and allocate it for the new data. If it cannot do that, it will return an invalid FileSystemIndex (-1). If free space was found, it will start writing the user file data starting at the address that was found by the allocation algorithm (the user application cannot predict where in the Filesystem address space the User data will be stored but this is unlikely to be a problem). A new FileSystemTableEntry is created and added to the FileSystemTable containing the allocated address, the overall file length (including an additional 2-byte marker at the start required by the FileSystem protocol), the type as USER_DATA, a NON_DEFAULT marker, and the next available index.

Returns
the index in the FileSystemTable that was created by the Programming process, or -1 if it failed.
Since
1.1

The documentation for this class was generated from the following file: