[ Home ]

file_win.c File Reference

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

#include <windows.h>
#include <time.h>
#include "../file.h"
#include "../../string/wtstring.h"
#include "../../common/platform.h"
#include "../../common/common_utils.h"
#include "../../memory/memory.h"

Include dependency graph for file_win.c:


Defines

#define leap(y)   (((y) % 4 == 0 && (y)% 100 != 0) || (y) % 400 == 0)
#define nleap(y)   (((y) - 1969) / 4 - ((y) - 1901) / 100 + ((y) - 1601) / 400)

Functions

PRIVATE W32 FS_FileTimeToUnixTime (FILETIME *ft)
 Converts file time to UNIX time format.
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_CreateDirectory (const char *dirname)
 Creates a new directory.
PUBLIC wtBoolean FS_RemoveDirectory (const char *pathname)
 Deletes an existing empty directory.
PUBLIC char * FS_GetCurrentDirectory (void)
 Gets the current working directory.
PUBLIC wtBoolean FS_ChangeCurrentDirectory (const char *path)
 Changes the current directory.
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.
PUBLIC wtBoolean FS_CompareFileAttributes (const char *path, W32 musthave, W32 canthave)
 Compare directory and file attributes.

Variables

PRIVATE char findFile [MAX_PATH]
PRIVATE HANDLE FindHandle

Detailed Description

Handles non-portable file services [Windows].

Author:
Michael Liebscher
Date:
2004-2007

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.

Here is the caller graph for this function:

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.

Here is the caller graph for this function:

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.

Here is the caller graph for this function:

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.

Here is the caller graph for this function:

PRIVATE W32 FS_FileTimeToUnixTime ( FILETIME *  ft  ) 

Converts file time to UNIX time format.

Parameters:
[in] ft Pointer to a FILETIME structure containing the file time to convert to UNIX date and time format.
Returns:
On success nonzero, otherwise zero.

Here is the caller graph for this function:

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.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Here is the caller graph for this function: