[ Home ]

file_unix.c File Reference

Handles non-portable file services [UNIX]. More...

#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <errno.h>
#include <stdio.h>
#include <dirent.h>
#include <unistd.h>
#include <string.h>
#include <glob.h>
#include "../../memory/memory.h"
#include "../../common/platform.h"
#include "../../common/common_utils.h"
#include "../../string/wtstring.h"
#include "../file.h"

Include dependency graph for file_unix.c:


Functions

PUBLIC wtBoolean FS_CreateDirectory (const char *dirname)
 Creates a new directory.
PUBLIC wtBoolean FS_ChangeCurrentDirectory (const char *path)
 Changes the current directory.
PUBLIC char * FS_GetCurrentDirectory (void)
 Gets the current working directory.
PUBLIC wtBoolean FS_RemoveDirectory (const char *pathname)
 Deletes an existing empty directory.
PUBLIC wtBoolean FS_DeleteFile (const char *filename)
 Deletes an existing file.
PUBLIC wtBoolean FS_GetFileAttributes (const char *filename, struct filestats *fs)
 Retrieves attributes for a specified file or directory.
PUBLIC wtBoolean FS_CompareFileAttributes (const char *path, W32 musthave, W32 canthave)
 Compare directory and file attributes.
PUBLIC char * FS_FindFirst (const char *path)
 Searches a directory for a file or subdirectory with a name that matches a specific name.
PUBLIC char * FS_FindNext (void)
 Continues a file search from a previous call to the FS_FindFirst function.
PUBLIC void FS_FindClose (void)
 Closes the search handle.

Variables

PRIVATE wtBoolean bFindOn = false
PRIVATE glob_t glob_results
PRIVATE W32 findCount = 0

Detailed Description

Handles non-portable file services [UNIX].

Author:
Michael Liebscher
Date:
2004-2009

Function Documentation

PUBLIC wtBoolean FS_ChangeCurrentDirectory ( const char *  path  ) 

Changes the current directory.

Parameters:
[in] path Pointer to a NUL-terminated string that specifies the path to the new directory.
Returns:
On success nonzero, otherwise zero.

PUBLIC wtBoolean FS_CompareFileAttributes ( const char *  path,
W32  musthave,
W32  canthave 
)

Compare directory and file attributes.

Parameters:
[in] path Specifies the path to compare file attributes.
[in] musthave File or directory must have these attributes.
[in] canthave File or directory can not have these attributes.
Returns:
On success true, otherwise false.

PUBLIC wtBoolean FS_CreateDirectory ( const char *  dirname  ) 

Creates a new directory.

Parameters:
[in] dirname Pointer to a NUL-terminated string that specifies the path of the directory to be created.
Returns:
On success true, otherwise false.

PUBLIC wtBoolean FS_DeleteFile ( const char *  filename  ) 

Deletes an existing file.

Parameters:
[in] filename Pointer to a NUL-terminated string that specifies the file to be deleted.
Returns:
If successful the return value is nonzero, otherwise zero.

PUBLIC char* FS_FindFirst ( const char *  path  ) 

Searches a directory for a file or subdirectory with a name that matches a specific name.

Parameters:
[in] path Pointer to a NUL-terminated string that specifies a valid directory or path and file name that can contain wildcard characters.
Returns:
On success string of file name or directory, otherwise NULL.
Note:
Caller is responsible for freeing allocated memory block by calling MM_FREE.

PUBLIC char* FS_FindNext ( void   ) 

Continues a file search from a previous call to the FS_FindFirst function.

Returns:
On success string of file name or directory, otherwise NULL.

PUBLIC char* FS_GetCurrentDirectory ( void   ) 

Gets the current working directory.

Returns:
If the function succeeds, a pointer to a NUL-terminated string. Otherwise NULL.
Note:
Caller is responsible for freeing allocated memory.

PUBLIC wtBoolean FS_GetFileAttributes ( const char *  filename,
struct filestats *  fs 
)

Retrieves attributes for a specified file or directory.

Parameters:
[in] filename Pointer to a NUL-terminated string that specifies a file or directory.
[in] fs Pointer to a filestats structure that receives the attribute information.
Returns:
On success true, otherwise false.

PUBLIC wtBoolean FS_RemoveDirectory ( const char *  pathname  ) 

Deletes an existing empty directory.

Parameters:
[in] dirname Pointer to a NUL-terminated string that specifies the directory to be deleted.
Returns:
If successful the return value is nonzero, otherwise zero.