# Directory Functions
[Operating System Abstraction]

Provides secure interprocess communication. More...

## Functions

GWENHYWFAR_API int | GWEN_Directory_Close (GWEN_DIRECTORYDATA *d)
GWENHYWFAR_API int | GWEN_Directory_Create (const char *path)
GWENHYWFAR_API int | GWEN_Directory_CreatePublic (const char *path)
GWENHYWFAR_API void | GWEN_Directory_free (GWEN_DIRECTORYDATA *d)
GWENHYWFAR_API int | GWEN_Directory_GetHomeDirectory (char *buffer, unsigned int size)
GWENHYWFAR_API int | GWEN_Directory_GetPath (const char *path, unsigned int flags)
GWENHYWFAR_API GWEN_DIRECTORYDATA * | GWEN_Directory_new ()
GWENHYWFAR_API int | GWEN_Directory_Open (GWEN_DIRECTORYDATA *d, const char *n)
GWENHYWFAR_API int | GWEN_Directory_OsifyPath (const char *path, GWEN_BUFFER *pbuf, int transformDriveElement)
GWENHYWFAR_API int | GWEN_Directory_Read (GWEN_DIRECTORYDATA *d, char *buffer, unsigned int len)
GWENHYWFAR_API int | GWEN_Directory_Rewind (GWEN_DIRECTORYDATA *d)

## Detailed Description

Provides secure interprocess communication.

Author:
  Martin Preuss<martin@libchipcard.de>

## Function Documentation

GWENHYWFAR_API int GWEN_Directory_Close | ( | GWEN_DIRECTORYDATA * | d | ) |

Closes a previously opened directory.

Author:
  Martin Preuss<martin@libchipcard.de>

Returns:
  0 if ok, !=0 on error

Parameters:

  | d | pointer to a directory data structure. This should be created by calling GWEN_Directory_new().

GWENHYWFAR_API int GWEN_Directory_Create | ( | const char * | path | ) |

| Creates a directory.

GWENHYWFAR_API int GWEN_Directory_CreatePublic | ( | const char * | path | ) |

| Creates a public directory (a folder which can be listed and entered by anyone)

GWENHYWFAR_API void GWEN_Directory_free | ( | GWEN_DIRECTORYDATA * | d | ) |

| Destructor

GWENHYWFAR_API int GWEN_Directory_GetHomeDirectory | ( | char * | buffer,
|  | unsigned int | size
| ) |

Get the current users home directory and copy it into the given buffer.

Returns:
  0 if ok, !=0 on error

GWENHYWFAR_API int GWEN_Directory_GetPath | ( | const char * | path,
|  | unsigned int | flags
| ) |

Gets a file path. It uses Paths to either create or check for the existence of a given path.

Returns:
  0 if ok, !=0 on error

Parameters:

  | path | path to inspect
  | flags | flags, please see GWEN_PATH_FLAGS_PATHMUSTEXIST et. al.

GWENHYWFAR_API GWEN_DIRECTORYDATA* GWEN_Directory_new | ( |  | ) |

| Constructor.

GWENHYWFAR_API int GWEN_Directory_Open | ( | GWEN_DIRECTORYDATA * | d,
|  | const char * | n
| ) |

Opens a directory. This allows calling "Directory_Read" to succeed.

Author:
  Martin Preuss<martin@libchipcard.de>

Returns:
  0 if ok, !=0 on error

Parameters:

  | d | pointer to a directory data structure. This should be created by calling GWEN_Directory_new().
  | n | path and name of the directory to open

GWENHYWFAR_API int GWEN_Directory_OsifyPath | ( | const char * | path,
|  | GWEN_BUFFER * | pbuf,
|  | int | transformDriveElement
| ) |

Takes a path and translates it into a path that the running platform can understand. This is needed for unix paths used on Windows. If transformDriveElement is !=0 on Windows platforms and the first element of the path is "/x" (with x being [a..z,A..Z]) then this element is translated into the corresponding drive letter sequence (x:). Slashes and backslashes are transformed as needed by the running platform. Duplicate slashes/backslashed are removed.

Parameters:

  | path | path to translate
  | pbuf | buffer to which the path is appended
  | transformDriveElemen | see above (ignored on non-win32 platforms)

GWENHYWFAR_API int GWEN_Directory_Read | ( | GWEN_DIRECTORYDATA * | d,
|  | char * | buffer,
|  | unsigned int | len
| ) |

Reads the next entry from a directory and stores the name of that entry in the given buffer. The entry returned is relative to the open directory.

Author:
  Martin Preuss<martin@libchipcard.de>

Returns:
  0 if ok, !=0 on error

Parameters:

  | d | pointer to a directory data structure. This should be created by calling GWEN_Directory_new().
  | buffer | pointer to a buffer to receive the name
  | len | size of the buffer

GWENHYWFAR_API int GWEN_Directory_Rewind | ( | GWEN_DIRECTORYDATA * | d | ) |

Rewinds the internal pointers, so that the next call to

Author:
  Martin Preuss<martin@libchipcard.de> GWEN_Directory_Read will return the first entry of the open directory.

Returns:
  0 if ok, !=0 on error

Parameters:

  | d | pointer to a directory data structure. This should be created by calling GWEN_Directory_new().