1.3.9 File I/O Functions

The current Windows product contains a minimal set of file I/O functions that are just procedural versions of the corresponding DOS INT 21h functions. These functions are not portable and lack many of the necessary file system functions an application might need.

Lacking a set of file system functions, the current Windows environment requires that applications call DOS for some file I/O needs. Win32 has been extended in this area so that the DOS dependency can be removed from applications. The functions are similar to their DOS counterparts and provides the minimum services required to portably access the file system from a Win32 application.

When a process is created, it inherits the current directory from the application that starts it. An application can determine which directory is current by using the GetCurrentDirectory function. An application can change the current directory using the SetCurrentDirectory function. When accessing a file, filenames may be either absolute or relative to the current directory.

The file functions include:

Function Description

_lclose Closes a file
_lcreat Creates a new file or opens and truncates an existing file
_llseek Positions the pointer to a file
_lopen Opens an existing file
_lread Reads data from a file
_lwrite Writes data in a file
CompareFileTime Compares two 64-bit file times.
CopyFile Copies a file
CreateDirectory Creates a directory
CreateFile Creates or opens a file
DeleteFile Deletes a file
FindClose Finishes a file enumeration
FindFirstFile Finds the first file matching the specified name
FindNextFile Finds the next file after a FindFirstFile
FlushFileBuffers Flushes buffered file i/o
GetCurrentDirectory Returns the current directory
GetDiskFreeSpace Returns the current disk free space
GetDriveType Determines whether a disk drive is removable, fixed, or remote
GetFileAttributes Gets the attributes of the specified file
GetFileSize Returns the size of a file.
GetFileTime Gets the creation, last access, and last modified times of a file
GetFileType Determines the file type (disk,pipe,char)
GetFullPathName Returns the fully qualified pathname for the file
GetLogicalDrives Returns a bitmask of available drives.
GetLogicalDriveStrings Returns the names of available drives.
GetOverlappedResult Returns the result of the previous overlapped i/o
GetStdHandle Returns the handles for stdin, stdout, and stderr
GetSystemDirectory Retrieves the pathname of the Windows system subdirectory
GetTempFileName Creates a temporary filename
GetTempPath Returns the pathname for the temp directory
GetVolumeInformation Returns information for the specified volume
GetWindowsDirectory Retrieves the pathname of the Windows directory
LockFile Locks a file
MoveFile Renames a file
OpenFile Creates, opens, reopens, or deletes the specified file
OpenSystemFile Opens a system file.
ReadFile Reads from a file
RemoveDirectory Deletes a directory
SearchPath Searches for a file along the specified path
SetCurrentDirectory Sets the current directory
SetEndOfFile Sets the end of file location
SetFileAttributes Sets the attributes of a file
SetFilePointer Seeks to a new location in a file
SetFileTime Sets the time for a file
SetHandleCount Changes the number of file handles available to a task
SetStdHandle Sets the handles for stdin, stdout, and stderr
UnlockFile Unlocks a file
WriteFile Writes to a file