Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages | Examples

Directory Support
[PHAT File System]

Collaboration diagram for Directory Support:


Detailed Description

Routines for reading and writing directories.


Data Structures

struct  _PHATDIRENT
 Structure of a directory entry. More...
struct  _PHATXDIRENT
 Structure of an extended directory entry. More...
struct  _PHATFIND

Defines

#define PHAT_MAX_NAMELEN   255
 Maximum length of a base file name.
#define PHAT_REM_DIRENT   0xE5
#define PHAT_REM_NAMENT   0x05
#define PHAT_MAXDIRENT   65536
 Maximum number of directory entries.

Typedefs

typedef _PHATDIRENT PHATDIRENT
 Structure of a directory entry.
typedef _PHATXDIRENT PHATXDIRENT
 Structure of an extended directory entry.
typedef _PHATFIND PHATFIND

Functions

int PhatDirEntryCreate (NUTFILE *ndp, CONST char *name, int acc, PHATDIRENT *dirent)
 Create a new directory entry.
int PhatDirEntryUpdate (NUTFILE *nfp)
 Update directory entry of an opened file or directory.
int PhatDirEntryFind (NUTFILE *ndp, CONST char *spec, u_long attmsk, PHATFIND *srch)
 Find a directory entry with a specified name.
NUTFILEPhatDirOpenParent (NUTDEVICE *dev, CONST char *path, CONST char **basename)
 Open parent directory of a given path.
int PhatDirRenameEntry (NUTDEVICE *dev, CONST char *old_path, CONST char *new_path)
 Rename file.
int PhatDirReleaseChain (NUTDEVICE *dev, PHATDIRENT *dent)
 Release a cluster chain of a specified directory entry.
int PhatDirDelEntry (NUTDEVICE *dev, CONST char *path, u_long flags)
 Remove a directory entry.
NUTFILEPhatDirOpen (NUTDEVICE *dev, CONST char *dpath)
 Open a directory.
int PhatDirRead (DIR *dir)
 Read the next directory entry.
int PhatDirCreate (NUTDEVICE *dev, char *path)
 Create a new subdirectory.
int PhatDirRemove (NUTDEVICE *dev, char *path)
 Remove a specified subdirectory.
int PhatDirEntryStatus (NUTDEVICE *dev, CONST char *path, struct stat *stp)
 Retrieve status of a specified file.


Typedef Documentation

typedef struct _PHATDIRENT PHATDIRENT
 

Structure of a directory entry.

Once created, this structure will never change if it points to another directory. Except if the entry is removed.

typedef struct _PHATXDIRENT PHATXDIRENT
 

Structure of an extended directory entry.

Used for long filenames.


Function Documentation

int PhatDirEntryCreate NUTFILE ndp,
CONST char *  name,
int  acc,
PHATDIRENT dirent
 

Create a new directory entry.

Parameters:
ndp Handle to the parent directory.
name Name of the new entry.
acc Attributes of the new entry.
dirent Information structure of the new entry.
Returns:
0 on success. Otherwise -1 is returned.

int PhatDirEntryUpdate NUTFILE nfp  ) 
 

Update directory entry of an opened file or directory.

Parameters:
nfp File of which the directory entry will be updated.
Returns:
0 on success. Otherwise -1 is returned.

int PhatDirEntryFind NUTFILE ndp,
CONST char *  spec,
u_long  attmsk,
PHATFIND *  srch
 

Find a directory entry with a specified name.

Parameters:
ndp Pointer to a previously opened directory.
spec Name of the entry to retrieve.
attmsk Attribute mask. Entries with attributes not specified in this mask will be ignored.
srch Optional pointer to a structure which receives the search result.
Returns:
0 if an entry was found, otherwise -1 is returned.

NUTFILE* PhatDirOpenParent NUTDEVICE dev,
CONST char *  path,
CONST char **  basename
 

Open parent directory of a given path.

Parameters:
dev Specifies the file system device.
path Full path.
basename Points to a pointer which will be set to the last component within the full path.
Returns:
Pointer to a NUTFILE structure if successful or NUTFILE_EOF otherwise.

int PhatDirRenameEntry NUTDEVICE dev,
CONST char *  old_path,
CONST char *  new_path
 

Rename file.

Parameters:
dev Specifies the file system device.
old_path Old name and path of the file.
new_path New name and path of the file.
Returns:
0 on success, -1 otherwise.

int PhatDirReleaseChain NUTDEVICE dev,
PHATDIRENT dent
 

Release a cluster chain of a specified directory entry.

Parameters:
dev Specifies the file system device.
dent Directory entry.
Returns:
0 on success or -1 on failure.

int PhatDirDelEntry NUTDEVICE dev,
CONST char *  path,
u_long  flags
 

Remove a directory entry.

Allocated clusters are released.

Parameters:
dev Specifies the file system device.
path Name of the entry to remove.
flags Attributes of the entry to remove.
Returns:
0 if successful. Otherwise returns an error code.

NUTFILE* PhatDirOpen NUTDEVICE dev,
CONST char *  dpath
 

Open a directory.

Parameters:
dev Specifies the file system device.
dpath Full absolute pathname of the directory to open.
Returns:
Pointer to a NUTFILE structure if successful or NUTFILE_EOF otherwise.

int PhatDirRead DIR dir  ) 
 

Read the next directory entry.

Parameters:
dir Pointer to the internal directory information structure.
Returns:
0 on success, -1 otherwise.

int PhatDirCreate NUTDEVICE dev,
char *  path
 

Create a new subdirectory.

One cluster is allocated, initialized to zero and two directory entries are created, '.' and '..'.

Parameters:
dev Specifies the file system device.
path Full path to the directory.
Returns:
0 on success. Otherwise -1 is returned.

int PhatDirRemove NUTDEVICE dev,
char *  path
 

Remove a specified subdirectory.

Parameters:
dev Specifies the file system device.
path Full path to the directory.
Returns:
0 on success. Otherwise -1 is returned.

int PhatDirEntryStatus NUTDEVICE dev,
CONST char *  path,
struct stat stp
 

Retrieve status of a specified file.

Parameters:
dev File system device.
path Path name to the file to query.
stp Pointer to a structure which receives the result.
return 0 on success, -1 otherwise.


© 2000-2006 by egnite Software GmbH - visit http://www.ethernut.de/