Maestro Audio Framework  v 1.0
NXP Semiconductors
osa_dir.h File Reference

Contains file and directory function prototypes for libosa. More...

Data Structures

struct  OsaDirMount
 Directory mount structure. More...
 
struct  OsaDirEnt
 Directory entry structure. More...
 

Macros

#define OSA_OWNER_READ   0x0400
 Bit masks that define properties of a file or directory.
 
#define OSA_OWNER_WRITE   0x0200
 
#define OSA_OWNER_EXECUTE   0x0100
 
#define OSA_GROUP_READ   0x0040
 
#define OSA_GROUP_WRITE   0x0020
 
#define OSA_GROUP_EXECUTE   0x0010
 
#define OSA_OTHER_READ   0x0004
 
#define OSA_OTHER_WRITE   0x0002
 
#define OSA_OTHER_EXECUTE   0x0001
 
#define OSA_PERM_ALL   0x0777
 

Typedefs

typedef void OsaDir
 Abstract type to represent a directory handle.
 

Enumerations

enum  OsaDirEntType {
  OSA_DT_DIR ,
  OSA_DT_FILE ,
  OSA_DT_UNKNOWN
}
 Type field for OsaDirEnt structure. More...
 

Functions

int osa_mkdir (const char *path, int mode)
 Create a new directory. More...
 
int osa_chdir (const char *path)
 Change current working directory. More...
 
OsaDirosa_opendir (const char *dirname)
 Open a directory for reading. More...
 
int osa_closedir (OsaDir *dirp)
 Close a directory. More...
 
int osa_readdir (OsaDir *dirp, OsaDirEnt *entry)
 Read contents of a directory. More...
 
int osa_unlink (const char *path)
 Remove a directory entry. More...
 

Enumeration Type Documentation

◆ OsaDirEntType

Enumerator
OSA_DT_FILE 

Entry is a directory.

OSA_DT_UNKNOWN 

Entry is a regular file.

Entry is unknown type (Linux only)

Function Documentation

◆ osa_mkdir()

int osa_mkdir ( const char *  path,
int  mode 
)

Create a directory at the given 'path' with the given 'mode'. The path can be a full path including device/mount point, or it can be a relative path. On Linux, the current path will be based on where the application is executed from. On MQX the current path will be the root of the device unless a call to osa_chdir() is made to change it. Current paths can be different for each process on Linux and each thread on MQX.

Parameters
pathThe path and name of the directory to make
modeThe directory mode. This should be a combination of bit modes defined above.
Return values
ERRCODE_NO_ERRORFunction succeeded
ERRCODE_OUT_OF_MEMORYOut of memory (MQX only)
ERRCODE_PERMISSION_DENIEDPermission denied
ERRCODE_PARAMETER_EXISTSDirectory exists
ERRCODE_OUT_OF_SPACENo space left on device
ERRCODE_INVALID_ARGUMENTInvalid input parameters
ERRCODE_GENERAL_ERRORAn error occurred creating the directory

◆ osa_chdir()

int osa_chdir ( const char *  path)

Change the current working directory for the executing process or thread to 'path'. On Linux, this directory can be unique for the entire process (all threads) and on MQX it can be unique for each thread.

Parameters
pathThe directory path to change to
Warning
This function has non-expected behavior on MQX and should be avoided until corrected.
Return values
ERRCODE_NO_ERRORFunction succeeded
ERRCODE_OUT_OF_MEMORYOut of memory (MQX only)
ERRCODE_PERMISSION_DENIEDPermission denied
ERRCODE_INVALID_ARGUMENTInvalid input parameters
ERRCODE_GENERAL_ERRORAn error occurred creating the directory

◆ osa_opendir()

OsaDir* osa_opendir ( const char *  dirname)

Open a directory at path 'dirname' and return a pointer to an object for reading.

Parameters
dirnameThe path and name of the directory to open. This can be absolute or relative to current working directory.
Returns
Valid pointer on success or NULL on failure.

◆ osa_closedir()

int osa_closedir ( OsaDir dirp)

Close the pointer object to an open directory and release any memory associated with it.

Parameters
dirpDirectory pointer
Return values
ERRCODE_NO_ERRORFunction succeeded
ERRCODE_INVALID_ARGUMENTInvalid input parameter

◆ osa_readdir()

int osa_readdir ( OsaDir dirp,
OsaDirEnt entry 
)

Read a single directory entry for the directory object pointed to by 'dirp' and return the data in 'entry'.

Parameters
dirpDirectory pointer
entryOutput parameter to store directory entry contents. This must be a valid pointer to an object.
Return values
ERRCODE_NO_ERRORFunction succeeded
ERRCODE_END_OF_DIRECTORYEnd of directory reached
ERRCODE_GENERAL_ERRORAn error occurred reading the directory

◆ osa_unlink()

int osa_unlink ( const char *  path)

Remove a file or directory from the filesystem.

Parameters
pathPath to the file or directory
Return values
ERRCODE_NO_ERRORFunction succeeded
ERRCODE_PERMISSION_DENIEDPermission Denied
ERRCODE_BUSYEntry is being accessed
ERRCODE_NOT_FOUNDEntry name not found
ERRCODE_INVALID_ARGUMENTThe path did not contain a valid device
ERRCODE_GENERALAn error occurred deleting the entry