A short overview of the dir library contained in jlib.lib - created by John Findlay
library version 1.00
Current list and bookmarks for library functions
The library functions are clones of the POSIX library functions of the same names. They are used to gather information about directorys and files. The library functions are contained within the jlib.lib binary library.
syntax:
opendir opens the requested directory. The variable 'dirname' is a pointer to null terminated array of chars that designates a valid directory path and can contain wildcard characters, * and ?. This string must not exceed MAX_PATH characters.
Return values:
The return if successfull is a pointer to a DIR structure as defined in dirent.h
typedef struct tagDIR{
int
d_cnt;
// how many reads
HANDLE d_hdir;
// directory handle
char
*d_dirname; // directory name
unsigned int d_magic;
// magic cookie for verifying handle
WIN32_FIND_DATA d_fd;
// buffer for a single file
} DIR;
where:
d_cnt: contains the number of files found. This is updated each time readdir is called.
d_hdir: is the handle of specified directory.
d_dirname: is a pointer to the specified path name.
d_magic: contains a code. This is used to check that the passed structure is valid.
d_fc: a WIN32_FIND_DATA structure used in all operations for reading files.
If the function fails to find the path INVALID_HANDLE_VALUE is returned. If it fails for any other reason such as no name specified in variable 'dirname', NULL is returned.
syntax:
readdir reads entries from the directory opened with opendir. This function is called repeatedly until no more entries are found.
Return values:
The return if successfull is a pointer to a DIRENT structure as defined in dirent.h
typedef struct tagDIRENT{
char *d_name;
//
file name
unsigned int d_attrib;
// file
attribute
long long d_size;
// file size (note: long long)
FILETIME d_ftCreationTime;
FILETIME d_ftLastAccessTime;
FILETIME d_ftLastWriteTime;
}DIRENT;
The various members of this structure are used to read different attributes of each file as found.
d_name: pointer to the file name. This can be a directory or file name.
d_size: the size of a file. Note, this is a long long type.
A struct of type FILETIME that contains the creation time in 'Coordinated Universal Time' (UTC) format. These functions set the FILETIME members to zero if the file system containing the file does not support this time member. You can use the FileTimeToLocalFileTime function to convert from UTC to local time, and then use the FileTimeToSystemTime function to convert the local time to a SYSTEMTIME structure containing individual members for the month, day, year, weekday, hour, minute, second, and millisecond.
syntax:
Function rewinddir closes the directory handle and then re-opens it so that one can re-start from the beginning of the directory. Useful if any changes to the directory has been made.
Return values:
No return value.
syntax:
Function closedir closes the directory handle and frees any memory allocated when the handle was first created.
Return Values
If the function succeeds, the return value is nonzero.
syntax:
Displays the version of the dirent library
FileTimeToLocalFileTime (Windows API)
The FileTimeToLocalFileTime function converts a file time to a local file time.
BOOL FileTimeToLocalFileTime( CONST FILETIME *lpFileTime, // UTC file time to convert LPFILETIME lpLocalFileTime // converted file time );
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
FileTimeToLocalFileTime uses the current settings for the time zone and daylight saving time. Therefore, if it is daylight saving time, this function will take daylight saving time into account, even if the time you are converting is in standard time.
Windows NT/2000 or later: Requires Windows
NT 3.1 or later.
Windows 95/98/Me: Requires Windows 95 or later.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.
FileTimeToSystemTime (Windows API)
The FileTimeToSystemTime function converts a file time to system time format.
BOOL FileTimeToSystemTime( CONST FILETIME *lpFileTime, // file time to convert LPSYSTEMTIME lpSystemTime // receives system time );
This value must be less than 0x8000000000000000. Otherwise, the function fails.
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Windows NT/2000 or later: Requires Windows
NT 3.1 or later.
Windows 95/98/Me: Requires Windows 95 or later.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.