Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
Burger::FileManager Class Reference

Global file system manager. More...

Collaboration diagram for Burger::FileManager:
Collaboration graph
[legend]

Classes

struct  Queue_t
 Asynchronous file I/O message. More...
 

Public Types

enum  ePrefix {
  kPrefixCurrent = 8 , kPrefixApplication = 9 , kPrefixBoot = 32 , kPrefixPrefs = 33 ,
  kPrefixSystem = 34 , kPrefixCount = 35 , kPrefixInvalid = 999
}
 Predefined pathname prefixes. More...
 
enum  eIOCommand {
  kIOCommandInvalid , kIOCommandOpen , kIOCommandClose , kIOCommandRead ,
  kIOCommandWrite , kIOCommandSeek , kIOCommandSeekEOF , kIOCommandCallback ,
  kIOCommandSync , kIOCommandEndThread
}
 Asynchronous file I/O commands. More...
 
typedef void(* ProcCallback) (Queue_t *pQueue)
 Function prototype for asynchronous I/O callbacks.
 

Public Member Functions

void flush_IO (void) noexcept
 Clear out pending events.
 
void wait_until_queue_has_space (void) noexcept
 Test if there is space in the queue.
 
void add_queue (File *pFile, eIOCommand uIOCommand, void *pBuffer, uintptr_t uLength) noexcept
 Add a file event into the queue.
 
void sync (File *pFile) noexcept
 Wait until all pending file calls are processed.
 

Static Public Member Functions

static uintptr_t queue_handler (void *pData) noexcept
 Queue thread.
 
static eError initialize (void) noexcept
 Initialize the global file system manager.
 
static void shut_down (void) noexcept
 Shut down the global file system manager.
 
static uint_t MSDOS_has_long_filenames (void) noexcept
 Returns TRUE if long filenames are allowed.
 
static uint_t MSDOS_get_os_version (void) noexcept
 Returns SETVER version of MS/DOS.
 
static uint_t MSDOS_get_os_true_version (void) noexcept
 Returns SETVER version of MS/DOS.
 
static const char * MSDOS_get_name (void) noexcept
 Returns the name of the version of DOS running.
 
static uint_t MSDOS_get_flavor (void) noexcept
 Returns the OEM flavor of MS/DOS.
 
static eError MSDOS_expand_8_3_filename (String *pInput) noexcept
 Convert 8.3 MSDos filename to long version.
 
static eError MSDOS_convert_to_8_3_filename (String *pInput) noexcept
 Convert long filename to an MSDos 8.3 filename.
 
static uint_t is_UTF8_file_system (void) noexcept
 Test if the file system supports UTF8 pathnames.
 
static eError get_volume_name (Filename *pOutput, uint_t uVolumeNum) noexcept
 Return the name of a drive.
 
static uint_t get_volume_number (const char *pInput) noexcept
 Given a volume name, return the volume number it's mounted on.
 
static eError set_default_prefixes (void) noexcept
 Set the initial default prefixes for a power up state.
 
static eError get_prefix (Filename *pOutput, uint_t uPrefixNum) noexcept
 Return the contents of a prefix.
 
static eError get_prefix (String *pOutput, uint_t uPrefixNum) noexcept
 Return the contents of a prefix.
 
static eError set_prefix (uint_t uPrefixNum, const char *pPrefixName) noexcept
 Set the contents of a prefix.
 
static eError set_prefix (uint_t uPrefixNum, const Filename *pPrefixName) noexcept
 Set the contents of a prefix with a filename.
 
static eError pop_prefix (uint_t uPrefixNum) noexcept
 Remove the last entry of a prefix.
 
static eError get_modification_time (const char *pFileName, TimeDate_t *pOutput) noexcept
 Get a file's last modification time.
 
static eError get_modification_time (Filename *pFileName, TimeDate_t *pOutput) noexcept
 Get a file's last modification time.
 
static eError get_creation_time (const char *pFileName, TimeDate_t *pOutput) noexcept
 Get a file's creation time.
 
static eError get_creation_time (Filename *pFileName, TimeDate_t *pOutput) noexcept
 Get a file's creation time.
 
static uint_t does_file_exist (const char *pFileName) noexcept
 Detect for a file's existence.
 
static uint_t does_file_exist (Filename *pFileName) noexcept
 Detect for a file's existence using a native pathname.
 
static uint32_t get_creator_type (const char *pFileName)
 Return a file's creator code.
 
static uint32_t get_creator_type (Filename *pFileName)
 Return a file's type code using a native filename.
 
static uint32_t get_file_type (const char *pFileName)
 Return a file's type code.
 
static uint32_t get_file_type (Filename *pFileName)
 Return a file's creator code using a native filename.
 
static eError get_creator_and_file_type (const char *pFileName, uint32_t *pCreatorType, uint32_t *pFileType)
 Return a file's type and creator codes.
 
static eError get_creator_and_file_type (Filename *pFileName, uint32_t *pCreatorType, uint32_t *pFileType)
 Return a file's type and creator codes using a native filename.
 
static eError set_creator_type (const char *pFileName, uint32_t uCreatorType)
 Set a file's creator code.
 
static eError set_creator_type (Filename *pFileName, uint32_t uCreatorType)
 Set a file's type code using a native filename.
 
static eError set_file_type (const char *pFileName, uint32_t uFileType)
 Set a file's type code.
 
static eError set_file_type (Filename *pFileName, uint32_t uFileType)
 Set a file's type code using a native filename.
 
static eError set_creator_and_file_type (const char *pFileName, uint32_t uCreatorType, uint32_t uFileType)
 Set a file's type and creator codes.
 
static eError set_creator_and_file_type (Filename *pFileName, uint32_t uCreatorType, uint32_t uFileType)
 Set a file's type and creator codes using a native filename.
 
static eError create_directory_path (const char *pFileName) noexcept
 Create a directory path.
 
static eError create_directory_path (Filename *pFileName) noexcept
 Create a directory path.
 
static eError create_directory_path_dirname (const char *pFileName)
 Create a directory path sans the last filename token.
 
static eError create_directory_path_dirname (const Filename *pFileName)
 Create a directory path sans the last filename token.
 
static eError delete_file (const char *pFileName) noexcept
 Delete a file or empty directory.
 
static eError delete_file (Filename *pFileName) noexcept
 Delete a file or empty directory using a Filename.
 
static eError rename_file (const char *pNewName, const char *pOldName) noexcept
 Rename a file.
 
static eError rename_file (Filename *pNewName, Filename *pOldName) noexcept
 Rename a file using Filename.
 
static eError change_OS_directory (const char *pDirName)
 Change the OS working directory.
 
static eError change_OS_directory (Filename *pDirName)
 Change the OS working directory using an OS native pathname..
 
static FILE * open_file (const char *pFileName, const char *pType) noexcept
 Open a file using stdio.
 
static FILE * open_file (Filename *pFileName, const char *pType) noexcept
 Open a file using stdio.
 
static eError copy_file (const char *pDestName, const char *pSourceName) noexcept
 Copy a file.
 
static eError copy_file (Filename *pDestName, Filename *pSourceName) noexcept
 Copy a file using OS native pathnames.
 
static eError save_file (const char *pFileName, const void *pData, uintptr_t uLength) noexcept
 Save a file.
 
static eError save_file (Filename *pFileName, const void *pData, uintptr_t uLength) noexcept
 Save a file using an OS native pathname.
 
static eError save_text_file (const char *pFileName, const void *pData, uintptr_t uLength) noexcept
 Save a text file.
 
static eError save_text_file (Filename *pFileName, const void *pData, uintptr_t uLength) noexcept
 Save a text file using a Filename.
 
static void * load_file (const char *pFileName, uintptr_t *pLength) noexcept
 Load a file into memory.
 
static void * load_file (Filename *pFileName, uintptr_t *pLength) noexcept
 Load a file into memory using a Filename.
 
static const char * get_boot_name (void) noexcept
 Return the boot volume name.
 
static uintptr_t get_boot_name_length (void) noexcept
 Return the length of the boot volume name.
 
static const Stringget_volume_prefix (void) noexcept
 Access the volume prefix string.
 
static short OpenResourceFile (const char *pFileName, char uPermission)
 Open a MacOS resource fork.
 
static uint_t CreateResourceFIle (const char *pFileName)
 Create a Mac OS resource fork.
 
static const char * UnixFindProcFolder (void) noexcept
 Find the location of /proc.
 
static void UnixFind_etc_mtab (String &rOutput, const char *pProcPath) noexcept
 Find the location of /etc/mtab.
 
static void UnixParseFSTypes (ClassArray< String > &rFSTypes, const char *pProcPath) noexcept
 Create the list of file system types.
 
static void UnixParseFStab (ClassArray< String > &rFSTabs) noexcept
 Create the list of mounted volumes.
 
static void UnixParseMTab (ClassArray< String > &rVolumePaths, const char *pEtcMtab, const ClassArray< String > &rFSTypes) noexcept
 Create the list of mounted volumes.
 
static void unix_find_volumes_folder (String *pOutput) noexcept
 Find the folder the has the mounted volumes.
 

Static Public Attributes

static const uint_t kMaxQueue = 128
 Maximum number of pending IO events(Power of 2)
 
static FileManagerg_pFileManager
 Global instance of the file manager.
 

Protected Member Functions

 FileManager () noexcept
 Construct the file manager.
 
 ~FileManager ()
 Destroy the file manager.
 
void platform_setup (void) noexcept
 Handle platform specific startup code.
 
void platform_shutdown (void) noexcept
 Handle platform specific shutdown code.
 

Protected Attributes

Semaphore m_PingIOThread
 Semaphore to ping the IO thread.
 
Semaphore m_IOThreadSync
 Semaphore to get a reply from the IO thread for syncing.
 
Thread m_Thread
 Worker thread record pointer.
 
volatile uint32_t m_uQueueStart
 Index to the queue start.
 
volatile uint32_t m_uQueueEnd
 Index to the end of the queue.
 
String m_Prefixes [kPrefixCount]
 Array of prefix strings.
 
Queue_t m_IOQueue [kMaxQueue]
 Queue of IO events.
 
const char * m_pDOSName
 Name of the MSDos flavor being run.
 
uint16_t m_uMSDOSVersion
 MSDOS version (MSDOS Only)
 
uint16_t m_uMSDOSTrueVersion
 MSDOS TRUE version (MSDOS Only)
 
uint8_t m_bLongNamesAllowed
 True if MSDOS has long filename support (MSDOS Only)
 
uint8_t m_uOEMFlavor
 OEM number (MSDOS Only)
 
uintptr_t m_uBootNameSize
 Length of the boot volume name (Darwin only)
 
char * m_pBootName
 Boot volume name in the format ":FooBar" (Zero terminated) (Darwin only)
 
String m_ProcPath
 Pointer to the /proc pathname or nullptr is no permission exists to access it.
 
String m_EtcMtab
 Pointer to the /etc/mtab file.
 
String m_VolumePrefix
 Volume prefix for paths.
 
ClassArray< Stringm_FSTypes
 Array of strings of file system types.
 
ClassArray< Stringm_FSTabs
 Array of strings from fstab.
 
ClassArray< Stringm_VolumePaths
 Array of string of mounted volume paths.
 

Private Member Functions

 FileManager (const FileManager &)=delete
 
FileManageroperator= (const FileManager &)=delete
 
 FileManager (FileManager &&)=delete
 
FileManageroperator= (FileManager &&)=delete
 

Detailed Description

Global file system manager.


Since file systems are all tied to a single device such as a hard drive or CD/DVD/Blu-Ray, all file calls are routed through a singleton class to enable Burgerlib to prioritize file streaming to reduce seeks and read/write operations for peak performance.

To ensure cross platform compatibility, all file/pathnames use a generic universal format that BurgerLib will accept and the library will perform any translations needed to the exact same behavior is consistent across operating systems.

The strings are "C" format, UTF8 with a zero termination byte. Colons are used at filename delimiters.

The concept of a BurgerLib path is simple. The first part is either a drive specifier, a volume name or a directory prefix. Drive specifiers act much like "C:" does on Windows machines. Volume names allow you to ask for a CD or DVD by name and query if it is mounted regardless of which drive it physically resides. Prefixes act like current working directories except that there are over 30 of them active at the same time and with a numeric or special character code you can quickly select the desired one at runtime.

Some prefixes are preset after a call to set_default_prefixes().

Default prefixes:

Example pathnames:

See also
UTF8

Member Typedef Documentation

◆ ProcCallback

typedef void( * Burger::FileManager::ProcCallback) (Queue_t *pQueue)

Function prototype for asynchronous I/O callbacks.

Member Enumeration Documentation

◆ eIOCommand

Asynchronous file I/O commands.


These are the commands for the file event queue to perform file operations in the background.

See also
add_queue()
Enumerator
kIOCommandInvalid 

Invalid command (Must be zero)

kIOCommandOpen 

Pending open file command.

kIOCommandClose 

Pending close file command.

kIOCommandRead 

Pending read file command.

kIOCommandWrite 

Pending write file command.

kIOCommandSeek 

Pending seek file command.

kIOCommandSeekEOF 

Pending seek to end of file command.

kIOCommandCallback 

Pending completion callback command.

kIOCommandSync 

Pending sync command.

kIOCommandEndThread 

Pending end thread command.

◆ ePrefix

Predefined pathname prefixes.


Enumerations for all of the built-in prefixes that are outside the bounds of prefixes 0-31

See also
set_default_prefixes()
Enumerator
kPrefixCurrent 

8: Current working directory at application launch

kPrefixApplication 

9: Directory where the application executable resides

kPrefixBoot 

"*:" Boot volume prefix number

kPrefixPrefs 

"@:" User preferences folder prefix number

kPrefixSystem 

"$:" System volume folder prefix number

kPrefixCount 

Maximum number of pathname prefixes.

kPrefixInvalid 

Illegal prefix number.

Constructor & Destructor Documentation

◆ FileManager() [1/3]

Burger::FileManager::FileManager ( const FileManager & )
privatedelete

◆ FileManager() [2/3]

Burger::FileManager::FileManager ( FileManager && )
privatedelete

◆ FileManager() [3/3]

Burger::FileManager::FileManager ( )
protectednoexcept

Construct the file manager.


Guaranteed to construct without errors.

◆ ~FileManager()

Burger::FileManager::~FileManager ( )
protected

Destroy the file manager.


Member Function Documentation

◆ add_queue()

void BURGER_API Burger::FileManager::add_queue ( File * pFile,
eIOCommand uIOCommand,
void * pBuffer,
uintptr_t uLength )
noexcept

Add a file event into the queue.


If the queue is full, wait until there is room and then insert the command into the queue.

The data buffer must exist until after the async event occurs.

Parameters
pFilePointer to the File object to perform the action on
uIOCommandCommand to execute on the File object
pBufferOptional pointer to a buffer for a read/write command
uLengthOptional buffer size or file marker for read/write/seek command

◆ change_OS_directory() [1/2]

Burger::eError BURGER_API Burger::FileManager::change_OS_directory ( const char * pDirName)
static

Change the OS working directory.


Given a BurgerLib pathname, set the OS's current working directory to this path.

This function is useful in cases where an OS native file dialog to select a file or perform an OS native function where the current working directory needs to be preset. This function under most circumstances is not necessary to use, however, it exists since there are some OS native functions in MacOS and Windows that require a little "help".

Note
On most systems, this is the same as calling cwd().
Parameters
pDirNamePointer to a "C" string of a BurgerLib path.
Returns
Zero if successful, non-zero on error.
See also
change_OS_directory(Filename*)

◆ change_OS_directory() [2/2]

Burger::eError BURGER_API Burger::FileManager::change_OS_directory ( Filename * pDirName)
static

Change the OS working directory using an OS native pathname..


Given an OS native pathname, set the OS's current working directory to this path.

This function is useful in cases where an OS native file dialog to select a file or perform an OS native function where the current working directory needs to be preset. This function under most circumstances is not necessary to use, however, it exists since there are some OS native functions in MacOS and Windows that require a little "help".

Note
On most systems, this is the same as calling cwd().
Parameters
pDirNamePointer to a Filename of a native OS path.
Returns
Zero if successful, non-zero on error.
See also
change_OS_directory(const char*)

◆ copy_file() [1/2]

Burger::eError BURGER_API Burger::FileManager::copy_file ( const char * pDestName,
const char * pSrcName )
staticnoexcept

Copy a file.


Given a BurgerLib formatted old pathname and new pathname, make a duplicate of the file at the end of the pathname.

Parameters
pDestNamePointer to a "C" string of a BurgerLib path for the new name.
pSrcNamePointer to a "C" string of a BurgerLib path for the current file name.
Returns
Zero if successful, non-zero on error.
See also
copy_file(Filename*, Filename*)

◆ copy_file() [2/2]

Burger::eError BURGER_API Burger::FileManager::copy_file ( Filename * pDestName,
Filename * pSourceName )
staticnoexcept

Copy a file using OS native pathnames.


Given an OS native formatted old pathname and new pathname, make a duplicate of the file at the end of the pathname.

Parameters
pDestNamePointer to a Filename of an OS native path for the new name.
pSourceNamePointer to a Filename of an OS native path for the current file name.
Returns
Zero if successful, non-zero on error.
See also
copy_file(const char*, const char*)

◆ create_directory_path() [1/2]

Burger::eError BURGER_API Burger::FileManager::create_directory_path ( const char * pFileName)
staticnoexcept

Create a directory path.


Given a BurgerLib directory, create each and every part of the directory. If the directory already exists, or is successfully created, the call is considered successful.

Example:

If the path :Foo:Bar: exists, a call with ":Foo:Bar:Fooey:Temp:" will create both "Fooey" and "Temp" in this single call.

Parameters
pFileNamePointer to a "C" string of a BurgerLib path.
Returns
Zero if successful, non-zero on error.
See also
create_directory_path_dirname(const char *)

◆ create_directory_path() [2/2]

Burger::eError BURGER_API Burger::FileManager::create_directory_path ( Filename * pFileName)
staticnoexcept

Create a directory path.


Given an Burgerlib directory, create each and every part of the directory. If the directory already exists, or is successfully created, the call is considered successful.

Example:

If the path c:\Foo\Bar exists, a call with "c:\Foo\Bar\Fooey\Temp\" will create both "Fooey" and "Temp" in this single call.

Parameters
pFileNamePointer to a Filename that contains a Burgerlib pathname.
Returns
Zero if successful, non-zero on error.
See also
create_directory_path(const char*) or create_directory_path_dirname(const char*)

◆ create_directory_path_dirname() [1/2]

Burger::eError BURGER_API Burger::FileManager::create_directory_path_dirname ( const char * pFileName)
static

Create a directory path sans the last filename token.


Given a BurgerLib directory, create each and every part of the directory from a path that includes a filename. If the directory already exists, or is successfully created, the call is considered successful.

Example:

If the path :Foo:Bar: exists, a call with ":Foo:Bar:Fooey:Temp:File.txt" will create both "Fooey" and "Temp" in this single call. The last token of "File.txt" is ignored.

Parameters
pFileNamePointer to a "C" string of a BurgerLib path.
Returns
Zero if successful, non-zero on error.
See also
create_directory_path(const char*)

◆ create_directory_path_dirname() [2/2]

Burger::eError BURGER_API Burger::FileManager::create_directory_path_dirname ( const Filename * pFileName)
static

Create a directory path sans the last filename token.


Given a BurgerLib directory, create each and every part of the directory from a path that includes a filename. If the directory already exists, or is successfully created, the call is considered successful.

Example:

If the path :Foo:Bar: exists, a call with ":Foo:Bar:Fooey:Temp:File.txt" will create both "Fooey" and "Temp" in this single call. The last token of "File.txt" is ignored.

Parameters
pFileNamePointer to a Filename class
Returns
Zero if successful, non-zero on error.
See also
create_directory_path(Filename*)

◆ CreateResourceFIle()

uint_t BURGER_API Burger::FileManager::CreateResourceFIle ( const char * pFileName)
static

Create a Mac OS resource fork.


This will use a generic pathname and creates a Macintosh resource file with a call to HCreateResFile().

Note
This function is only available for Mac OS Carbon/Classic
Parameters
pFileNamePointer to a Burgerlib file name
Returns
The value returned by ResError() immediately after the call to HCreateResFile()

◆ delete_file() [1/2]

Burger::eError BURGER_API Burger::FileManager::delete_file ( const char * pFileName)
staticnoexcept

Delete a file or empty directory.


Given a BurgerLib pathname, delete the file at the end of the pathname.

Example:

If a call with ":Foo:Bar:Fooey:Temp.txt" is issued, only the file "Temp.txt" is deleted. The rest of the path is left intact. This call will not delete non-empty directories, only files. If the file is already deleted, an error is returned.

Parameters
pFileNamePointer to a "C" string of a BurgerLib path.
Returns
Zero if successful, non-zero on error.
See also
delete_file(Filename*)

◆ delete_file() [2/2]

Burger::eError BURGER_API Burger::FileManager::delete_file ( Filename * pFileName)
staticnoexcept

Delete a file or empty directory using a Filename.


Given an OS native pathname, delete the file at the end of the pathname.

Example:

If a call with "c:\Foo\Bar\Fooey\Temp.txt" is issued, only the file "Temp.txt" is deleted. The rest of the path is left intact. This call will not delete non-empty directories, only files. If the file is already deleted, an error is returned.

Parameters
pFileNamePointer to a Filename of a Burgerlib path.
Returns
Zero if successful, non-zero on error.
See also
delete_file(const char*)

◆ does_file_exist() [1/2]

uint_t BURGER_API Burger::FileManager::does_file_exist ( const char * pFileName)
staticnoexcept

Detect for a file's existence.


Given a BurgerLib pathname, return TRUE if the file exists. FALSE if there is an disk error or the file does not exist.

Note
This does not guarantee that the file can be opened due to security permissions or the file being on a locked folder. It only guarantees its existence.
Parameters
pFileNamePointer to a "C" string of a BurgerLib pathname,
Returns
FALSE if the file does not exist, TRUE if the file exists.
See also
does_file_exist(Filename *)

◆ does_file_exist() [2/2]

uint_t BURGER_API Burger::FileManager::does_file_exist ( Filename * pFileName)
staticnoexcept

Detect for a file's existence using a native pathname.


Given a OS native pathname, return TRUE if the file exists. FALSE if there is an disk error or the file does not exist.

Note
This does not guarantee that the file can be opened due to security permissions or the file being on a locked folder. It only guarantees its existence.
Parameters
pFileNamePointer to a Filename which contains a native version of the path to the file.
Returns
FALSE if the file does not exist, TRUE if the file exists.
See also
does_file_exist(const char*)

◆ flush_IO()

void BURGER_API Burger::FileManager::flush_IO ( void )
noexcept

Clear out pending events.


Clear out the I/O file queue. All events with callbacks will return a cancel error.

See also
sync() or wait_until_queue_has_space()

◆ get_boot_name()

Burger::FileManager::get_boot_name ( void )
inlinestaticnoexcept

Return the boot volume name.


The boot volume is a UTF8 "C" string in the format of ":Foobar" (A leading colon and no ending colon)

Note
Available only on MacOSX
Returns
const char * to the boot volume name.
See also
Burger::FileManager::get_boot_name_length()

◆ get_boot_name_length()

Burger::FileManager::get_boot_name_length ( void )
inlinestaticnoexcept

Return the length of the boot volume name.


The boot volume is a UTF8 "C" string in the format of ":Foobar" (A leading colon and no ending colon).

Note
Available only on MacOSX
Returns
Number of bytes in length of the boot volume name
See also
Burger::FileManager::get_boot_name()

◆ get_creation_time() [1/2]

Burger::eError BURGER_API Burger::FileManager::get_creation_time ( const char * pFileName,
TimeDate_t * pOutput )
staticnoexcept

Get a file's creation time.


Given a BurgerLib path, access the file and return the time/date that it was created.

Parameters
pFileNamePointer to a "C" string to a BurgerLib pathname
pOutputPointer to an uninitialized TimeDate_t structure that will receive the time/date.
Returns
Zero on success, non-zero in the event of an error (Usually file not found)
See also
get_creation_time(Filename*, TimeDate_t*)

◆ get_creation_time() [2/2]

Burger::eError BURGER_API Burger::FileManager::get_creation_time ( Filename * pFileName,
TimeDate_t * pOutput )
staticnoexcept

Get a file's creation time.


Given a native operating system path, access the file and return the time/date that it was created.

Parameters
pFileNamePointer to a Filename class that is properly initialized to the native file system.
pOutputPointer to an uninitialized TimeDate_t structure that will receive the time/date.
Returns
Zero on success, non-zero in the event of an error (Usually file not found)
See also
get_modification_time(Filename*, TimeDate_t*) or get_creation_time( const char*, TimeDate_t*)

◆ get_creator_and_file_type() [1/2]

Burger::eError BURGER_API Burger::FileManager::get_creator_and_file_type ( const char * pFileName,
uint32_t * pCreatorType,
uint32_t * pFileType )
static

Return a file's type and creator codes.


On MacOS, a file has extended data which includes the file's type, which is independent of the filename, and the creator code of the application that owns this file. This function will retrieve the 4 byte codes from the file.

On non MacOS platforms, this function only return non-zero (An error condition) and perform store zeros in the result values..

Parameters
pFileNamePointer to a "C" string of a BurgerLib pathname
pCreatorTypePointer to a uint32_t that will receive the file creator code.
pFileTypePointer to a uint32_t that will receive the file type code.
Returns
Non-zero if the file doesn't exist, the function isn't implemented of if the file doesn't have extended information. Zero is returned on successful completion.
See also
get_creator_and_file_type(Filename*, uint32_t*, uint32_t *), get_file_type(const char*) or get_creator_type(const char*)

◆ get_creator_and_file_type() [2/2]

Burger::eError Burger::FileManager::get_creator_and_file_type ( Filename * pFileName,
uint32_t * pCreatorType,
uint32_t * pFileType )
static

Return a file's type and creator codes using a native filename.


On MacOS, a file has extended data which includes the file's type, which is independent of the filename, and the creator code of the application that owns this file. This function will retrieve the 4 byte codes from the file.

On non MacOS platforms, this function only return non-zero (An error condition) and perform store zeros in the result values..

Parameters
pFileNamePointer to a Filename of a native OS pathname
pCreatorTypePointer to a uint32_t that will receive the file creator code.
pFileTypePointer to a uint32_t that will receive the file type code.
Returns
Non-zero if the file doesn't exist, the function isn't implemented of if the file doesn't have extended information. Zero is returned on successful completion.
See also
get_creator_and_file_type(Filename*, uint32_t*, uint32_t*), get_file_type(const char*) or get_creator_type(const char*)

◆ get_creator_type() [1/2]

uint32_t BURGER_API Burger::FileManager::get_creator_type ( const char * pFileName)
static

Return a file's creator code.


On MacOS, a file has extended data which includes the application code that owns the file. This function will retrieve the 4 byte code from the file.

On non MacOS platforms, this function only return 0 (An error condition) and perform nothing.

Parameters
pFileNamePointer to a "C" string of a BurgerLib pathname
Returns
0 if the file doesn't exist, the function isn't implemented of if the file doesn't have extended information. A 32 bit value if the data can be retrieved.
See also
get_creator_type(Filename*), get_file_type(const char*) or get_creator_and_file_type(const char*, uint32_t*, uint32_t*)

◆ get_creator_type() [2/2]

uint32_t BURGER_API Burger::FileManager::get_creator_type ( Filename * pFileName)
static

Return a file's type code using a native filename.


On MacOS, a file has extended data which includes the file's type, which is independent of the filename. This function will retrieve the 4 byte code from the file.

On non MacOS platforms, this function only return 0 (An error condition) and perform nothing.

Parameters
pFileNamePointer to a Filename of a native OS pathname
Returns
0 if the file doesn't exist, the function isn't implemented of if the file doesn't have extended information. A 32 bit value if the data can be retrieved.
See also
get_file_type(const char*), get_creator_type(const char*) or get_creator_and_file_type(const char*, uint32_t*, uint32_t*)

◆ get_file_type() [1/2]

uint32_t BURGER_API Burger::FileManager::get_file_type ( const char * pFileName)
static

Return a file's type code.


On MacOS, a file has extended data which includes the file's type, which is independent of the filename. This function will retrieve the 4 byte code from the file.

On non MacOS platforms, this function only return 0 (An error condition) and perform nothing..

Parameters
pFileNamePointer to a "C" string of a BurgerLib pathname
Returns
0 if the file doesn't exist, the function isn't implemented of if the file doesn't have extended information. A 32 bit value if the data can be retrieved.
See also
get_file_type(Filename*), get_creator_type(const char*) or get_creator_and_file_type(const char*, uint32_t*, uint32_t*)

◆ get_file_type() [2/2]

uint32_t Burger::FileManager::get_file_type ( Filename * pFileName)
static

Return a file's creator code using a native filename.


On MacOS, a file has extended data which includes the application code that owns the file. This function will retrieve the 4 byte code from the file.

On non MacOS platforms, this function only return 0 (An error condition) and perform nothing..

Parameters
pFileNamePointer to a Filename of a native OS pathname
Returns
0 if the file doesn't exist, the function isn't implemented of if the file doesn't have extended information. A 32 bit value if the data can be retrieved.
See also
get_creator_type(const char*), get_file_type(const char*) or get_creator_and_file_type(const char*, uint32_t*, uint32_t*)

◆ get_modification_time() [1/2]

Burger::eError BURGER_API Burger::FileManager::get_modification_time ( const char * pFileName,
TimeDate_t * pOutput )
staticnoexcept

Get a file's last modification time.


Given a BurgerLib path, access the file and return the time/date that it was last modified.

Parameters
pFileNamePointer to a "C" string to a BurgerLib pathname
pOutputPointer to an uninitialized TimeDate_t structure that will receive the time/date.
Returns
Zero on success, non-zero in the event of an error (Usually file not found)
See also
get_modification_time(Filename*, TimeDate_t*)

◆ get_modification_time() [2/2]

Burger::eError BURGER_API Burger::FileManager::get_modification_time ( Filename * pFileName,
TimeDate_t * pOutput )
staticnoexcept

Get a file's last modification time.


Given a native operating system path, access the file and return the time/date that it was last modified.

Parameters
pFileNamePointer to a Filename class that is properly initialized to the native file system.
pOutputPointer to an uninitialized TimeDate_t structure that will receive the time/date.
Returns
Zero on success, non-zero in the event of an error (Usually file not found)
See also
get_modification_time(const char*, TimeDate_t*) or get_creation_time(Filename*, TimeDate_t*)

◆ get_prefix() [1/2]

Burger::eError BURGER_API Burger::FileManager::get_prefix ( Filename * pOutput,
uint_t uPrefixNum )
staticnoexcept

Return the contents of a prefix.


Given a prefix number, fill in a Filename structure with a copy of the prefix pathname. The string could be an empty string in the case of an unused or nullptr prefix.

Parameters
pOutputPointer to a Filename class to store the string
uPrefixNumIndex to the requested prefix to obtain
Returns
Zero if no error, non-zero if error
See also
set_prefix(uint_t, const char*)

◆ get_prefix() [2/2]

Burger::eError BURGER_API Burger::FileManager::get_prefix ( String * pOutput,
uint_t uPrefixNum )
staticnoexcept

Return the contents of a prefix.


Given a prefix number, fill in a String structure with a copy of the prefix pathname. The string could be an empty string in the case of an unused or nullptr prefix.

Parameters
pOutputPointer to a String class to store the string
uPrefixNumIndex to the requested prefix to obtain
Returns
Zero if no error, non-zero if error
See also
get_prefix(Filename*, uint_t)

◆ get_volume_name()

Burger::eError BURGER_API Burger::FileManager::get_volume_name ( Filename * pOutput,
uint_t uVolumeNum )
staticnoexcept

Return the name of a drive.


Given a drive number (0-?), return the name of the volume in the format of ":Volume name:". The function will guarantee the existence of the colons.

Note
This function should be used with caution. Only mounted drives would return immediately and if the drive has ejectable media may take a while for it to respond to a volume name query.
Parameters
pOutputA Filename structure to contain the filename (Can be nullptr )
uVolumeNumA valid drive number from 0-?? with ?? being the maximum number of drives in the system
Returns
Zero if no error, non-zero if an error occurred
See also
get_volume_number(const char *)

◆ get_volume_number()

uint_t BURGER_API Burger::FileManager::get_volume_number ( const char * pVolumeName)
staticnoexcept

Given a volume name, return the volume number it's mounted on.


Scanning all the disk volumes, search for a drive that is labeled by the input name. The input is in the form of ":home:". The search is case insensitive.

Parameters
pVolumeNameValid pointer to "C" string in the form of ":name:"
Returns
Volume number from 0-max drives and -1 in case of the volume was not found.
Note
This function will NOT search floppy drives A: and B: on MSDOS and Windows platforms. This is to prevent an annoying error for bad media.
See also
get_volume_name(Filename *,uint_t)

◆ get_volume_prefix()

Burger::FileManager::get_volume_prefix ( void )
inlinestaticnoexcept

Access the volume prefix string.


Unix like operating systems can't agree on the name of the mount point for all mounted block devices. This function will return the prefix for the pathname for a mount point.

Note
This is only available on unix/posix compatible platforms
Returns
String pointer to the volume prefix string.
See also
unix_find_volumes_folder(String*)

◆ initialize()

Burger::eError BURGER_API Burger::FileManager::initialize ( void )
staticnoexcept

Initialize the global file system manager.


Call this function once on startup to start up the Burgerlib file manager. This function's primary purpose is to initialize the default prefixes.

See also
set_default_prefixes(void) or shut_down(void)

◆ is_UTF8_file_system()

uint_t BURGER_API Burger::FileManager::is_UTF8_file_system ( void )
staticnoexcept

Test if the file system supports UTF8 pathnames.


Returns TRUE if the filesystem has native Unicode filenames. On legacy or some game consoles, only the ASCII character set is supported.

Mac OS classic is special because if the application is running under MacOS 8.1 or higher, Unicode is supported, if it's earlier, only character codes that exist in Mac Roman US are used.

Note
While MacOS 8.1 supports Unicode, it's only available with HFS+ volumes
Returns
TRUE if Unicode is supported.
See also
MSDOS_has_long_filenames()

◆ load_file() [1/2]

void *BURGER_API Burger::FileManager::load_file ( const char * pFileName,
uintptr_t * pLength )
staticnoexcept

Load a file into memory.


Given a BurgerLib pathname, open the file, allocate a buffer for it, load it into memory and return the pointer to the allocated buffer and the optional buffer size.

This function is a quick and easy way to read the contents of a file into a buffer. The buffer must be deleted with a call to Burger::Free( const void*)

Note
This function does no data translation. The buffer contains an exact byte for byte copy of the contents of the file on disk.
Parameters
pFileNamePointer to a "C" string of a BurgerLib path.
pLengthPointer to a uintptr_t to receive the size of the buffer.
Returns
nullptr if failure, a valid pointer to the buffer on success.
See also
load_file(Filename*, uintptr_t *) or save_file(Filename*, const void*, uintptr_t)

◆ load_file() [2/2]

void *BURGER_API Burger::FileManager::load_file ( Filename * pFileName,
uintptr_t * pLength )
staticnoexcept

Load a file into memory using a Filename.


Given an OS native pathname, open the file, allocate a buffer for it, load it into memory and return the pointer to the allocated buffer and the optional buffer size.

This function is a quick and easy way to read the contents of a file into a buffer. The buffer must be deleted with a call to Burger::Free( const void *)

Note
This function does no data translation. The buffer contains an exact byte for byte copy of the contents of the file on disk.
Parameters
pFileNamePointer to a Filename object.
pLengthPointer to a uintptr_t to receive the size of the buffer.
Returns
nullptr if failure, a valid pointer to the buffer on success.
See also
load_file(const char*, uintptr_t*), or save_file(Filename*, const void*, uintptr_t)

◆ MSDOS_convert_to_8_3_filename()

Burger::eError BURGER_API Burger::FileManager::MSDOS_convert_to_8_3_filename ( String * pInput)
staticnoexcept

Convert long filename to an MSDos 8.3 filename.


On versions of MS/DOS that supports long filenames, convert an input long filename into its 8.3 filename counterpart if possible. If the operating system does not support long filenames, nothing is done to the input string.

Note
This is only available on MS/DOS
Parameters
pInputPointer to String with the long filename in MS/DOS format
Returns
Error code, kErrorNone if no error.
See also
MSDOS_get_name() or MSDOS_expand_8_3_filename()

◆ MSDOS_expand_8_3_filename()

Burger::eError BURGER_API Burger::FileManager::MSDOS_expand_8_3_filename ( String * pInput)
staticnoexcept

Convert 8.3 MSDos filename to long version.


On versions of MS/DOS that supports long filenames, convert an input 8.3 filename into its long filename counterpart if possible. If the operating system does not support long filenames, nothing is done to the input string.

Note
This is only available on MS/DOS
Parameters
pInputPointer to String with the 8.3 filename in MS/DOS format
Returns
Error code, kErrorNone if no error.
See also
MSDOS_get_name() or MSDOS_convert_to_8_3_filename()

◆ MSDOS_get_flavor()

uint_t BURGER_API Burger::FileManager::MSDOS_get_flavor ( void )
staticnoexcept

Returns the OEM flavor of MS/DOS.


Returns the OEM flavor value for MS/DOS to determine the vendor of the version of the OS running.

Note
This is only available on MS/DOS
See also
MSDOS_get_name()

◆ MSDOS_get_name()

const char *BURGER_API Burger::FileManager::MSDOS_get_name ( void )
staticnoexcept

Returns the name of the version of DOS running.


Returns a string with the name of the type of MS/DOS running. DOSBox is detected and reported as DOSBox.

Example strings:

  • IBM
  • Compaq
  • MS/DOS
  • AT&T
  • Zenith
  • Hewlett Packard
  • Groupe Bull
  • Tandon
  • AST
  • Asem
  • Hantarex
  • SystemsLine
  • Packard Bell
  • Intercomp
  • Unibit
  • Unidata
  • Digital Equipment
  • Olivetti
  • Texas Instruments
  • Toshiba
  • Novell 386
  • MS Multimedia 386
  • RxDOS
  • PhysTechSoft
  • DOSBox
  • Concurrent DOS
  • GenSoft DOS
  • DR-DOS
  • Novell
Note
This is only available on MS/DOS
See also
MSDOS_get_flavor()

◆ MSDOS_get_os_true_version()

uint_t BURGER_API Burger::FileManager::MSDOS_get_os_true_version ( void )
staticnoexcept

Returns SETVER version of MS/DOS.


Returns the real version of MS/DOS. This cannot be overridden by the command SETVER.

Note
This is only available on MS/DOS
See also
MSDOS_get_os_version() or MSDOS_get_name()

◆ MSDOS_get_os_version()

uint_t BURGER_API Burger::FileManager::MSDOS_get_os_version ( void )
staticnoexcept

Returns SETVER version of MS/DOS.


Returns the version of MS/DOS. This can be overridden by the command SETVER for compatibility. Use the function MSDOS_get_os_true_version() to get the true version.

Note
This is only available on MS/DOS
See also
MSDOS_get_os_true_version() or MSDOS_get_name()

◆ MSDOS_has_long_filenames()

uint_t BURGER_API Burger::FileManager::MSDOS_has_long_filenames ( void )
staticnoexcept

Returns TRUE if long filenames are allowed.


On most MSDOS file systems, only 8.3 filenames are permitted. Test if support for longer than 8.3 filenames is present and if so, return TRUE, otherwise return FALSE.

Note
This function returns TRUE on all target platforms except BURGER_MSDOS, the MS/DOS target performs a check to see if it's running under Windows 95 or higher or RxDOS and if so, Burgerlib will automatically support long filenames.
See also
is_UTF8_file_system(), FileManager, or BURGER_MSDOS

◆ open_file() [1/2]

FILE *BURGER_API Burger::FileManager::open_file ( const char * pFileName,
const char * pType )
staticnoexcept

Open a file using stdio.


Given a BurgerLib pathname, open a file as if fopen() supported BurgerLib pathnames,

This is a cross platform method for opening a standard "C" library file stream. As such, this pointer must eventually be closed with a call to fclose().

The second parameter is passed as is to a subsequent call to fopen(). See the docs on fopen() on valid input such as "rb" for read binary and "w" for write text file.

Parameters
pFileNamePointer to a "C" string of a BurgerLib path.
pTypePointer to a "C" string that will be passed to a call to fopen().
Returns
nullptr on error, a valid FILE * compatible with stdio.h file calls.
See also
File

◆ open_file() [2/2]

FILE *BURGER_API Burger::FileManager::open_file ( Filename * pFileName,
const char * pType )
staticnoexcept

Open a file using stdio.


Given a BurgerLib pathname, open a file as if fopen() supported BurgerLib pathnames.

This is a cross platform method for opening a standard "C" library file stream. As such, this pointer must eventually be closed with a call to fclose().

The second parameter is passed as is to a subsequent call to fopen(). See the docs on fopen() on valid input such as "rb" for read binary and "w" for write text file.

Parameters
pFileNamePointer to a "C" string of a BurgerLib path.
pTypePointer to a "C" string that will be passed to a call to fopen().
Returns
nullptr on error, a valid FILE * compatible with stdio.h file calls.
See also
File

◆ OpenResourceFile()

short BURGER_API Burger::FileManager::OpenResourceFile ( const char * pFileName,
char uPermission )
static

Open a MacOS resource fork.


Using a Burgerlib pathname, open a resource fork of the requested MacOS file using a call to HOpenResFile().

Note
This function is only available for Mac OS Carbon/Classic
Parameters
pFileNamePointer to a Burgerlib file name
uPermissionPermission value passed to HOpenResFile()
Returns
Error returned by HOpenResFile()

◆ operator=() [1/2]

FileManager & Burger::FileManager::operator= ( const FileManager & )
privatedelete

◆ operator=() [2/2]

FileManager & Burger::FileManager::operator= ( FileManager && )
privatedelete

◆ platform_setup()

void BURGER_API Burger::FileManager::platform_setup ( void )
protectednoexcept

Handle platform specific startup code.


Calls system functions to determine the version, state and several platform specific variables to allow the FileManager to run better by pre-caching relevant data.

For MS-DOS, it will determine the version and flavor of MS/DOS this application is running. It will also detect DosBox.

For Linux, it will scan all the mounted volumes for quick access to shared volumes.

For Android and consoles, it will check if there are mounted SD Cards or other external data storage devices so the application can be aware of them.

See also
platform_shutdown() or FileManager

◆ platform_shutdown()

void BURGER_API Burger::FileManager::platform_shutdown ( void )
protectednoexcept

Handle platform specific shutdown code.


Calls system functions to release cached values obtained from the platform's operating system.

See also
platform_setup() or FileManager

◆ pop_prefix()

Burger::eError BURGER_API Burger::FileManager::pop_prefix ( uint_t uPrefixNum)
staticnoexcept

Remove the last entry of a prefix.


Given a prefix number, pop off the last entry so that it effectively goes up one entry in a directory hierarchy. Imagine performing the operation "cd .." on the prefix.

This can force the prefix to become an empty string if the prefix is pointing to a root folder.

Examples:

  • ":foo:bar:temp:" = ":foo:bar:"
  • ":foo:bar:" = ":foo:"
  • ":foo:" = ""
Parameters
uPrefixNumIndex to the prefix to modify.
See also
get_prefix(Filename*, uint_t) or set_prefix(uint_t, const char*)

◆ queue_handler()

uintptr_t BURGER_API Burger::FileManager::queue_handler ( void * pData)
staticnoexcept

Queue thread.


Internal function to handle async file operations.

Note
This is called as a separate thread. Do not call directly.
Parameters
pDataPointer to the parent FileManager object.
Returns
0 or error code if shut down suddenly.

◆ rename_file() [1/2]

Burger::eError BURGER_API Burger::FileManager::rename_file ( const char * pNewName,
const char * pOldName )
staticnoexcept

Rename a file.


Given a BurgerLib formatted old pathname and new pathname, rename the file at the end of the pathname.

Note
The source and destination directories must be the same.
Parameters
pNewNamePointer to a "C" string of a BurgerLib path for the new name.
pOldNamePointer to a "C" string of a BurgerLib path for the current file name.
Returns
Zero if successful, non-zero on error.
See also
rename_file(Filename*, Filename*)

◆ rename_file() [2/2]

Burger::eError BURGER_API Burger::FileManager::rename_file ( Filename * pNewName,
Filename * pOldName )
staticnoexcept

Rename a file using Filename.


Given a Filename formatted old pathname and new pathname, rename the file at the end of the pathname.

Note
The source and destination directories must be the same.
Parameters
pNewNamePointer to a Filename for the new name.
pOldNamePointer to a Filename for the current file name.
Returns
Zero if successful, non-zero on error.
See also
rename_file(const cha *, const char*)

◆ save_file() [1/2]

Burger::eError BURGER_API Burger::FileManager::save_file ( const char * pFileName,
const void * pInput,
uintptr_t uLength )
staticnoexcept

Save a file.


Given a BurgerLib pathname and a buffer, save the contents of the buffer into a file and close the file.

This function is a quick and easy way to write a buffer from memory directly to disk (Or any other storage medium).

Parameters
pFileNamePointer to a "C" string of a BurgerLib path.
pInputPointer to an array of bytes to save
uLengthNumber of bytes in the buffer
Returns
TRUE if successful, FALSE on error.
See also
save_file(Filename*, const void*, uintptr_t)

◆ save_file() [2/2]

Burger::eError BURGER_API Burger::FileManager::save_file ( Filename * pFileName,
const void * pInput,
uintptr_t uLength )
staticnoexcept

Save a file using an OS native pathname.


Given an OS native pathname and a buffer, save the contents of the buffer into a file and close the file.

This function is a quick and easy way to write a buffer from memory directly to disk (Or any other storage medium).

Parameters
pFileNamePointer to a Filename object.
pInputPointer to an array of bytes to save
uLengthNumber of bytes in the buffer
Returns
TRUE if successful, FALSE on error.
See also
save_file(const char*, const void*, uintptr_t)

◆ save_text_file() [1/2]

Burger::eError BURGER_API Burger::FileManager::save_text_file ( const char * pFileName,
const void * pInput,
uintptr_t uLength )
staticnoexcept

Save a text file.


Given a BurgerLib pathname and a buffer, save the contents of the buffer into a file and close the file.

This function is a quick and easy way to write a buffer from memory directly to disk (Or any other storage medium).

Note
This differs from save_file(const char*, const void*, uintptr_t) in that all "\n" values will be translated to the proper line feeds for the target operating system. Unix and Linux, no change, Windows and MSDos, it's converted to a "\n\r", MacOS and MacOSX it's converted to "\r".
Parameters
pFileNamePointer to a "C" string of a BurgerLib path.
pInputPointer to an array of bytes to save as a text file.
uLengthNumber of bytes in the buffer
Returns
TRUE if successful, FALSE on error.
See also
save_text_file(Filename*, const void*, uintptr_t)

◆ save_text_file() [2/2]

Burger::eError BURGER_API Burger::FileManager::save_text_file ( Filename * pFileName,
const void * pInput,
uintptr_t uLength )
staticnoexcept

Save a text file using a Filename.


Given a Filename and a buffer, save the contents of the buffer into a file and close the file.

This function is a quick and easy way to write a buffer from memory directly to disk (Or any other storage medium).

Note
This differs from save_file(Filename*, const void *, uintptr_t) in that all "\n" values will be translated to the proper line feeds for the target operating system. Unix and Linux, no change, Windows and MSDos, it's converted to a "\n\r", MacOS and MacOSX it's converted to "\r".
Parameters
pFileNamePointer to a Filename object.
pInputPointer to an array of bytes to save as a text file.
uLengthNumber of bytes in the buffer
Returns
TRUE if successful, FALSE on error.
See also
save_text_file(const char*, const void*, uintptr_t), save_file(const char*, const void*, uintptr_t)

◆ set_creator_and_file_type() [1/2]

Burger::eError BURGER_API Burger::FileManager::set_creator_and_file_type ( const char * pFileName,
uint32_t uCreatorType,
uint32_t uFileType )
static

Set a file's type and creator codes.


On MacOS, a file has extended data which includes the file's type, which is independent of the filename, and the creator code of the application that owns this file. This function will set the 4 byte codes for the file.

On non MacOS platforms, this function will perform nothing.

Parameters
pFileNamePointer to a "C" string of a BurgerLib pathname
uCreatorTypeA uint32_t of the new file creator code.
uFileTypeA uint32_t of the new file type code.
Returns
Non-zero if the file doesn't exist, the function isn't implemented of if the file doesn't have extended information. Zero is returned on successful completion.
See also
get_creator_and_file_type(Filename*, uint32_t*, uint32_t*), get_file_type(const char*) or get_creator_type(const char*)

◆ set_creator_and_file_type() [2/2]

Burger::eError Burger::FileManager::set_creator_and_file_type ( Filename * pFileName,
uint32_t uCreatorType,
uint32_t uFileType )
static

Set a file's type and creator codes using a native filename.


On MacOS, a file has extended data which includes the file's type, which is independent of the filename, and the creator code of the application that owns this file. This function will set the 4 byte codes for the file.

On non MacOS platforms, this function will perform nothing.

Parameters
pFileNamePointer to a Filename of a native OS pathname
uCreatorTypeA uint32_t of the new file creator code.
uFileTypeA uint32_t of the new file type code.
Returns
Non-zero if the file doesn't exist, the function isn't implemented of if the file doesn't have extended information. Zero is returned on successful completion.
See also
get_creator_and_file_type(const char*, uint32_t*, uint32_t*), get_file_type(const char*) or get_creator_type(const char*)

◆ set_creator_type() [1/2]

Burger::eError BURGER_API Burger::FileManager::set_creator_type ( const char * pFileName,
uint32_t uCreatorType )
static

Set a file's creator code.


On MacOS, a file has extended data which includes the application code that owns the file. This function will set the 4 byte code for the file.

On non MacOS platforms, this function will perform nothing.

Parameters
pFileNamePointer to a "C" string of a BurgerLib pathname
uCreatorTypeFour byte character code to set.
Returns
Non-zero if the file doesn't exist, the function isn't implemented of if the file doesn't have extended information. Zero if successful.
See also
set_creator_type(Filename *,uint32_t), set_file_type( const char*, uint32_t) or set_creator_and_file_type( const char*, uint32_t, uint32_t)

◆ set_creator_type() [2/2]

Burger::eError BURGER_API Burger::FileManager::set_creator_type ( Filename * pFileName,
uint32_t uCreatorType )
static

Set a file's type code using a native filename.


On MacOS, a file has extended data which includes the file's type, which is independent of the filename. This function will set the 4 byte code for the file.

On non MacOS platforms, this function will perform nothing.

Parameters
pFileNamePointer to a Filename of a native OS pathname
uCreatorTypeFour byte character code to set.
Returns
Non-zero if the file doesn't exist, the function isn't implemented of if the file doesn't have extended information. Zero if successful.
See also
set_file_type(const char*, uint32_t), set_creator_type( const char*, uint32_t) or set_creator_and_file_type( const char*, uint32_t, uint32_t)

◆ set_default_prefixes()

Burger::eError BURGER_API Burger::FileManager::set_default_prefixes ( void )
staticnoexcept

Set the initial default prefixes for a power up state.


Sets these prefixes based on the current setup of the machine the application is running on.

  • "*:" = Boot volume
  • "$:" = System folder
  • "@:" = Preferences folder
  • "8:" = Default directory
  • "9:" = Application directory
See also
initialize(void), get_prefix(Filename*, uint_t) or set_prefix(uint_t, const char*)

◆ set_file_type() [1/2]

Burger::eError BURGER_API Burger::FileManager::set_file_type ( const char * pFileName,
uint32_t uFileType )
static

Set a file's type code.


On MacOS, a file has extended data which includes the file's type, which is independent of the filename. This function will set the 4 byte code for the file.

On non MacOS platforms, this function will perform nothing.

Parameters
pFileNamePointer to a "C" string of a BurgerLib pathname
uFileTypeFour byte character code to set.
Returns
Non-zero if the file doesn't exist, the function isn't implemented of if the file doesn't have extended information. Zero if successful.
See also
set_file_type(Filename*, uint32_t), set_creator_type( const char*, uint32_t) or set_creator_and_file_type( const char*, uint32_t, uint32_t)

◆ set_file_type() [2/2]

Burger::eError Burger::FileManager::set_file_type ( Filename * pFileName,
uint32_t uFileType )
static

Set a file's type code using a native filename.


On MacOS, a file has extended data which includes the file's type, which is independent of the filename. This function will set the 4 byte code for the file.

On non MacOS platforms, this function will perform nothing.

Parameters
pFileNamePointer to a Filename of a native OS pathname,
uFileTypeFour byte character code to set.
Returns
Non-zero if the file doesn't exist, the function isn't implemented of if the file doesn't have extended information. Zero if successful.
See also
set_file_type(const char*, uint32_t), set_creator_type( const char *,uint32_t) or set_creator_and_file_type( const char*, uint32_t, uint32_t)

◆ set_prefix() [1/2]

Burger::eError BURGER_API Burger::FileManager::set_prefix ( uint_t uPrefixNum,
const char * pPrefixName )
staticnoexcept

Set the contents of a prefix.


Given a prefix number and a "C" string to a new pathname, set that prefix to the new value. The prefix is expanded BEFORE it's applied, so if you set prefix 10 with "10:foo" and prefix 10 was already ":Work:Temp:", then prefix 10 will result in ":Work:Temp:foo:"

Passing an empty string or a nullptr will cause the prefix to be released and considered empty.

Parameters
uPrefixNumIndex to the requested prefix to obtain
pPrefixNamePointer to a "C" string of a new BurgerLib pathname
Returns
Zero if no error, non-zero if error (Usually out of memory or out of bounds)
See also
get_prefix(Filename*, uint_t)

◆ set_prefix() [2/2]

Burger::eError BURGER_API Burger::FileManager::set_prefix ( uint_t uPrefixNum,
const Filename * pPrefixName )
staticnoexcept

Set the contents of a prefix with a filename.


Given a prefix number and a Filename that has a new pathname, set that prefix to the new value. The prefix is expanded BEFORE it's applied, so if you set prefix 10 with "10:foo" and prefix 10 was already ":Work:Temp:", then prefix 10 will result in ":Work:Temp:foo:"

Passing an empty string or a nullptr will cause the prefix to be released and considered empty.

Parameters
uPrefixNumIndex to the requested prefix to obtain
pPrefixNamePointer to a Filename of a new BurgerLib pathname
Returns
Zero if no error, non-zero if error (Usually out of memory or out of bounds)
See also
get_prefix(Filename*, uint_t)

◆ shut_down()

void BURGER_API Burger::FileManager::shut_down ( void )
staticnoexcept

Shut down the global file system manager.


Call this function once on shutdown to the Burgerlib file manager. This function's primary purpose is to release all allocated memory and send out a report in case any files are still open on debug builds. The application is responsible for shutting down file usage before application shutdown.

See also
initialize(void)

◆ sync()

void BURGER_API Burger::FileManager::sync ( File * pFile)
noexcept

Wait until all pending file calls are processed.


Test all pending file calls and if any remain that affect the File object, then wait until they are processed.

Parameters
pFilePointer to the File object to test
See also
flush_IO() or wait_until_queue_has_space()

◆ unix_find_volumes_folder()

void BURGER_API Burger::FileManager::unix_find_volumes_folder ( String * pOutput)
staticnoexcept

Find the folder the has the mounted volumes.


Unix like operating systems can't agree on the name of the mount point for all mounted block devices. This function will invoke dark magic on the native linux platform to determine where the folder is located. It's usually /mnt, but for Ubuntu it's /media/<username> etc.

Note
This is only available on unix/posix compatible platforms
Parameters
pOutputString pointer to receive the folder name.
See also
g_VolumePrefixes or UnixGetFlavor()

◆ UnixFind_etc_mtab()

void BURGER_API Burger::FileManager::UnixFind_etc_mtab ( String & rOutput,
const char * pProcPath )
staticnoexcept

Find the location of /etc/mtab.


Checks for the location of /etc/mtab and if the application has permission to access it. Otherwise, it tries /proc/mounts, and then /proc/self/mounts

Note
This is only available on unix/posix compatible platforms
Parameters
rOutputString that will contain the filename for /etc/mtab
pProcPath"C" string containing the name of the /proc directory

◆ UnixFindProcFolder()

const char *BURGER_API Burger::FileManager::UnixFindProcFolder ( void )
staticnoexcept

Find the location of /proc.


Checks for the location of /proc and if the application has permission to access it. It will check for /proc first, then /proc/self, otherwise it will return nullptr.

Note
This is only available on unix/posix compatible platforms
Returns
Pointer to the name of the /proc folder.

◆ UnixParseFStab()

void BURGER_API Burger::FileManager::UnixParseFStab ( ClassArray< String > & rFSTabs)
staticnoexcept

Create the list of mounted volumes.


Parse /etc/fstab and generate a list of strings of all the valid mounted volumes

Note
This is only available on unix/posix compatible platforms
Parameters
rFSTabsArray to store all the parsed volumes

◆ UnixParseFSTypes()

void BURGER_API Burger::FileManager::UnixParseFSTypes ( ClassArray< String > & rFSTypes,
const char * pProcPath )
staticnoexcept

Create the list of file system types.


Parse /proc/filesystems and generate a list of strings of all the valid mounted file systems.

On Android, this function will likely fail due to strong permissions but will succeed on a rooted device. Android will always return the list at the minimum, ext3, ext4, vfat, msdos, sdfat, fuseblk, f2fs

Linux devices will always return at the minimum, zfs, wslfs, drvfs, smbfs

none, squashfs, and swap are always excluded.

Note
This is only available on unix/posix compatible platforms
Parameters
rFSTypesArray to store all the parsed file systems
pProcPath"C" string containing the name of the /proc directory

◆ UnixParseMTab()

void BURGER_API Burger::FileManager::UnixParseMTab ( ClassArray< String > & rVolumePaths,
const char * pEtcMtab,
const ClassArray< String > & rFSTypes )
staticnoexcept

Create the list of mounted volumes.


Parse /etc/mtab generate a list of strings of all the valid mounted volumes paths. The path /proc/mounts is an acceptable alternate.

Parameters
rVolumePathsArray to store all the parsed volumes
pEtcMtabPointer to "C" string path to /etc/mtab
rFSTypesArray of valid file systems

◆ wait_until_queue_has_space()

void BURGER_API Burger::FileManager::wait_until_queue_has_space ( void )
noexcept

Test if there is space in the queue.


If there is not room in the queue for a new entry, wait until a file operation completes so a new entry can be added to the end of the queue.

If there is room, return immediately.

See also
sync() or flush_IO()

Member Data Documentation

◆ g_pFileManager

Burger::FileManager * Burger::FileManager::g_pFileManager
static

Global instance of the file manager.

◆ kMaxQueue

const uint_t Burger::FileManager::kMaxQueue = 128
static

Maximum number of pending IO events(Power of 2)

◆ m_bLongNamesAllowed

uint8_t Burger::FileManager::m_bLongNamesAllowed
protected

True if MSDOS has long filename support (MSDOS Only)

◆ m_EtcMtab

String Burger::FileManager::m_EtcMtab
protected

Pointer to the /etc/mtab file.

◆ m_FSTabs

ClassArray<String> Burger::FileManager::m_FSTabs
protected

Array of strings from fstab.

◆ m_FSTypes

ClassArray<String> Burger::FileManager::m_FSTypes
protected

Array of strings of file system types.

◆ m_IOQueue

Queue_t Burger::FileManager::m_IOQueue[kMaxQueue]
protected

Queue of IO events.

◆ m_IOThreadSync

Semaphore Burger::FileManager::m_IOThreadSync
protected

Semaphore to get a reply from the IO thread for syncing.

◆ m_pBootName

char* Burger::FileManager::m_pBootName
protected

Boot volume name in the format ":FooBar" (Zero terminated) (Darwin only)

◆ m_pDOSName

const char* Burger::FileManager::m_pDOSName
protected

Name of the MSDos flavor being run.

◆ m_PingIOThread

Semaphore Burger::FileManager::m_PingIOThread
protected

Semaphore to ping the IO thread.

◆ m_Prefixes

String Burger::FileManager::m_Prefixes[kPrefixCount]
protected

Array of prefix strings.

◆ m_ProcPath

String Burger::FileManager::m_ProcPath
protected

Pointer to the /proc pathname or nullptr is no permission exists to access it.

◆ m_Thread

Thread Burger::FileManager::m_Thread
protected

Worker thread record pointer.

◆ m_uBootNameSize

uintptr_t Burger::FileManager::m_uBootNameSize
protected

Length of the boot volume name (Darwin only)

◆ m_uMSDOSTrueVersion

uint16_t Burger::FileManager::m_uMSDOSTrueVersion
protected

MSDOS TRUE version (MSDOS Only)

◆ m_uMSDOSVersion

uint16_t Burger::FileManager::m_uMSDOSVersion
protected

MSDOS version (MSDOS Only)

◆ m_uOEMFlavor

uint8_t Burger::FileManager::m_uOEMFlavor
protected

OEM number (MSDOS Only)

◆ m_uQueueEnd

volatile uint32_t Burger::FileManager::m_uQueueEnd
protected

Index to the end of the queue.

◆ m_uQueueStart

volatile uint32_t Burger::FileManager::m_uQueueStart
protected

Index to the queue start.

◆ m_VolumePaths

ClassArray<String> Burger::FileManager::m_VolumePaths
protected

Array of string of mounted volume paths.

◆ m_VolumePrefix

String Burger::FileManager::m_VolumePrefix
protected

Volume prefix for paths.