Nut/OS  4.10.3
API Reference
PHAT Utilities

General utility routines used by the PHAT file system. More...

Collaboration diagram for PHAT Utilities:

Functions

void GetDosTimeStamp (uint16_t *dostim, uint16_t *dosdat)
 Create a DOS timestamp of the current time and date.
int MakePhatName (CONST char *src, uint8_t *dst)
 Convert filename to a directory entry name.
void MakeVisibleName (CONST uint8_t *src, char *dst)
 Convert a directory entry name to a visible file name.
char * GetParentPath (CONST char *path, CONST char **comp)
 Chop off the last component of a path.
int IsFixedRootDir (NUTFILE *ndp)
 Test for PHAT12/PHAT16 root directory.
void PhatFilePosRewind (PHATFILE *fcb)
 Set file pointer back to zero.
int PhatFilePosSet (NUTFILE *nfp, uint32_t pos)
 Move file pointer to a specified position.

Detailed Description

General utility routines used by the PHAT file system.


Function Documentation

void GetDosTimeStamp ( uint16_t dostim,
uint16_t dosdat 
)

Create a DOS timestamp of the current time and date.

Parameters:
dostimReceives the time of day part.
dosdatReceives the calendar date part.

Definition at line 102 of file phatutil.c.

References localtime(), time(), _tm::tm_hour, _tm::tm_mday, _tm::tm_min, _tm::tm_mon, _tm::tm_sec, and _tm::tm_year.

Referenced by PhatDirEntryCreate(), and PhatFileWrite().

Here is the call graph for this function:

int MakePhatName ( CONST char *  src,
uint8_t dst 
)

Convert filename to a directory entry name.

Parameters:
srcOriginal name in the format 'name.ext'.
dstConverted name in the format 'name ext'.
Returns:
0 on success, 1 if the name contains wildcards or -1 if the name is malformed.

Definition at line 127 of file phatutil.c.

References memset(), PHAT_REM_DIRENT, PHAT_REM_NAMENT, strchr(), and toupper().

Here is the call graph for this function:

void MakeVisibleName ( CONST uint8_t src,
char *  dst 
)

Convert a directory entry name to a visible file name.

Parameters:
srcOriginal name in the format 'name ext'.
dstConverted name in the format 'name.ext'.
Returns:
0 on success, 1 if the name contains wildcards or -1 if the name is malformed.

Definition at line 212 of file phatutil.c.

References PHAT_REM_DIRENT, and PHAT_REM_NAMENT.

char* GetParentPath ( CONST char *  path,
CONST char **  comp 
)

Chop off the last component of a path.

Parameters:
pathFull path.
compPoints to a pointer which will be set to the last component within the full path.
Returns:
Pointer to a newly allocated string containing the parent path, or NULL in case of an error. The allocated buffer must be released by the caller.

Definition at line 249 of file phatutil.c.

References EINVAL, errno, malloc(), memcpy(), strlen(), and strrchr().

Referenced by PhatDirOpenParent().

Here is the call graph for this function:

int IsFixedRootDir ( NUTFILE ndp)

Test for PHAT12/PHAT16 root directory.

Parameters:
ndpHandle of an opened file to check.
Returns:
0 if the file is not a fixed root directory.

Definition at line 280 of file phatutil.c.

References _NUTDEVICE::dev_dcb, _NUTFILE::nf_dev, _NUTFILE::nf_fcb, and _PHATVOL::vol_type.

Referenced by PhatClusterSector(), PhatFilePosSet(), PhatFileRead(), and PhatFileWrite().

void PhatFilePosRewind ( PHATFILE fcb)

Set file pointer back to zero.

Parameters:
fcbSpecifies the file control block.

Definition at line 304 of file phatutil.c.

References _PHATDIRENT::dent_clust, _PHATDIRENT::dent_clusthi, _PHATFILE::f_clust, _PHATFILE::f_clust_pos, _PHATFILE::f_dirent, _PHATFILE::f_pos, and _PHATFILE::f_sect_pos.

Referenced by PhatDirCreate(), PhatDirEntryFind(), PhatDirOpen(), and PhatFilePosSet().

int PhatFilePosSet ( NUTFILE nfp,
uint32_t  pos 
)

Move file pointer to a specified position.

Moving beyond the current file size is not supported.

Parameters:
nfpFile descriptor.
posRequested file position.
Returns:
0 on success, -1 otherwise. In the latter case the position is unspecified.

Definition at line 329 of file phatutil.c.

References _PHATDIRENT::dent_attr, _PHATDIRENT::dent_fsize, _NUTDEVICE::dev_dcb, _PHATFILE::f_clust, _PHATFILE::f_clust_pos, _PHATFILE::f_clust_prv, _PHATFILE::f_dirent, _PHATFILE::f_pos, _PHATFILE::f_sect_pos, IsFixedRootDir(), _NUTFILE::nf_dev, _NUTFILE::nf_fcb, PHAT12CMASK, Phat12GetClusterLink(), PHAT16CMASK, Phat16GetClusterLink(), PHAT32CMASK, Phat32GetClusterLink(), PHAT_FATTR_DIR, PHATEOC, PhatFilePosRewind(), _PHATVOL::vol_clustsz, _PHATVOL::vol_rootsz, _PHATVOL::vol_sectsz, and _PHATVOL::vol_type.

Referenced by PhatFileOpen().

Here is the call graph for this function: