Method and system for providing a common name space for long and short file names in an operating system6286013Abstract An operating system provides a common name space for both long filenames and short filenames. In this common namespace, a long filename and a short filename are provided for each file. Each file has a short filename directory entry and may have at least one long filename directory entry associated with it. The number of long filename directory entries that are associated with a file depends on the number of characters in the long filename of the file. The long filename directory entries are configured to minimize compatibility problems with existing installed program bases. Claims We claim: Description TECHNICAL FIELD
stc ; set carry for error flag
; set registers here for the LFN function call
int 21h ; call the long filename function
jnc success ; call succeeded, continue processing
cmp ax, 7100h ; is the call really not supported?
jne failure ; yes, supported, but an error occurred
; set registers here for the MS-DOS function call
int 21h ; call the standard MS-DOS function
Application developers have to decide what to do when users save a file with a long filename to a down-level system. One approach is to imitate the behavior of COMMAND.COM and save the file using the alias name without informing the user. A different approach is to have the application inform the user that the file system does not support long filenames and allow the user to save the file with name in the standard 8.3 format. Long Command Lines The limit for environment variables and batch file lines in WINDOWS 95 is 1024 characters, whereas in previous versions of MS-DOS the limit is 128 characters. The limit for the keyboard buffer is still 128 characters. Although 1024 and 128 are the default values, users may configure their systems to lower these limits. In previous versions of MS-DOS, command-line arguments are located in the command tail of the program segment prefix (PSP). The command tail in the PSP is limited to 128 characters, including the leading byte that specifies the length of the command line and the trailing carriage return character. In WINDOWS 95, if the command line is less than or equal to 126 characters, it is set in the command tail of the PSP. If the command line is greater than 126 characters, the command line is set in the CMDLINE environment variable, and the command tail in the PSP just contains a carriage return character. Last Access Date The WINDOWS 95 last access date is intended to reflect the last time a file was accessed for the purpose for which it was created. This date is intended to provide a means for applications, users, or both to determine which files have not been used recently. The last access date should not be reset when a file is accessed by a program which has no understanding of its contents. For example, none of the following operations should affect the last access date: Backing up a file. Searching files for strings. Scanning for viruses. Applications should set the last access date in the following cases: Running a program should set the last access date for the .EXE file. Loading a dynamic-link library (DLL) should set the last access date for the .DLL file. Editing or printing a document should set the last access date for the document file. In general, any use of a document by an application that creates or modifies that type of document should set the last access date (unless the document is being opened only to decide whether it is to be used in a find operation). Application use of peripheral files (.INI files, and so on) should set the last access date. Win32-based applications can preserve the last access date by using the GetFileTime and SetFileTime functions. Applications written for MS-DOS or WINDOWS 3.x can use Get Last Access Date (Interrupt 21h Function 5704h) and Set Last Access Date (Interrupt 21h Function 5705h), or they can open the file with Create or Open File (Interrupt 21h Function 716Ch) using the OPEN_ACCESS_RO_NOMODLASTACCESS (0004h) access mode. Long Filename Functions The long filename functions match the operations provided by the Win32 file management functions.
Long filename function Win32 function
Interrupt 21h Function 5704h GetFileTime
Get Last Access Date and Time
Interrupt 21h Function 5705h SetFileTime
Set Last Access Date and Time
Interrupt 21h Function 5706h GetFileTime
Get Creation Date and Time
Interrupt 21h Function 5707h SetFileTime
Set Creation Date and Time
Interrupt 21h Function 7139h CreateDirectory
Make Directory
Interrupt 21h Function 713Ah RemoveDirectory
Remove Directory
Interrupt 21h Function 713Bh SetCurrentDirectory
Change Directory
Interrupt 21h Function 7141h DeleteFile
Delete File
Interrupt 21h Function 7143h GetFileAttributes, SetFileAttributes
Get or Set File Attributes
Interrupt 21h Function 7147h GetCurrentDirectory
Get Current Directory
Interrupt 21h Function 714Eh FindFirstFile
Find First File
Interrupt 21h Function 714Fh FindNextFile
Find Next File
Interrupt 21h Function 7156h MoveFile
Rename File
Interrupt 21h Function 7160h GetFullPathName
Get Full Path Name
Interrupt 21h Function 7160h GetShortPathName
Get Short Path Name
Interrupt 21h Function 716Ch No Win32 function equivalent.
Get Long Path Name
Interrupt 21h Function 716Ch CreateFile, OpenFile
Create or Open File
Interrupt 21h Function 71A0h GetVolumeInformation
Get Volume Information
Interrupt 21h Function 71A1h FindClose
Find Close
Interrupt 21h Function 71A6h GetFileInformationByHandle
Get File Info By Handle
Interrupt 21h Function 71A7h FileTimeToDOSDateTime
File Time To DOS Time
Interrupt 21h Function 71A7h DOSDateTimeToFileTime
DOS Time To File Time
Note that Interrupt 21h Functions 71A2h through 71A5h exist, but they are
for internal use by WINDOWS 95 only. Also, Extended Open/Create (Interrupt
21h Function 6Ch) has been enhanced in WINDOWS 95 to make use of the last
access date for a file.
Reference This section describes the long filename functions and structures. Functions Interrupt 21h Function 5704h Get Last Access Date and
mov ax, 5704h ; Get Last Access Date and Time
mov bx, Handle ; file handle
int 21h
jc error
mov [Date], dx ; last access date
mov [Time], cx ; currently not supported, always 0
Retrieves the last access date for the given file. If successful, clears the carry flag and sets the CX register to 0 and the DX register to these values:
Bits Contents
0-4 Day of the month (1-31)
5-8 Month (1 = January, 2 = February, and so on)
9-15 Year offset from 1980 (add 1980 to get the actual year)
Otherwise, sets the carry flag and sets the AX register to an error value. Handle File handle. It must have been previously retrieved by using Create or Open File (Interrupt 21h Function 716Ch) or Extended File Open (Interrupt 21h Function 6Ch). Interrupt 21h Function 5705h Set Last Access Date and Time
mov ax, 5705h ; Set Last Access Date and Time
mov bx, Handle ; file handle
mov cx, 0 ; time currently not supported, always 0
mov dx, AccessDate ; new access date
int 21h
jc error
Sets the last access date for the given file. If successful, clears the carry flag. Otherwise, sets the carry flag and sets the AX register to an error value. Handle File handle. It must have been previously retrieved by using Create or Open File (Interrupt 21h Function 716Ch) or Extended File Open (Interrupt 21h Function 6Ch). AccessDate New access date. The access date is a packed 16-bit value with the following form:
Bits Contents
0-4 Day of the month (1-31)
5-8 Month (1 = January, 2 = February, and so on)
9-15 Year offset from 1980 (add 1980 to get the actual year)
Interrupt 21h Function 5706h Get Creation Date and Time
mov ax, 5706h ; Get Creation Date and Time
mov bx, Handle ; file handle
int 21h
jc error
mov [Time], cx ; creation time
mov [Date], dx ; creation date
mov [MilliSeconds], si ; number of 10 ms intervals in 2 seconds
Retrieves the creation date and time for the given file. If successful, clears the carry flag and sets the CX, DX, and SI registers to these values:
Bits Contents
CX Creation time. The time is a packed 16-bit value with the following
form:
0-4 Second divided by 2
5-10 Minute (0-59)
11-15 Hour (0-23 on a 24-hour clock)
DX Creation date. The date is a packed 16-bit value with the following
form:
0-4 Day of the month (1-31)
5-8 Month (1 = January, 2 = February, and so on)
9-15 Year offset from 1980 (add 1980 to get the actual year)
SI Number of 10 millisecond intervals in 2 seconds to add to the
MS-DOS time. It can be a value in the range of 0 to 199.
Otherwise, sets the carry flag and sets the AX register to an error value. Handle File handle. It must have been previously retrieved by using Create or Open File (Interrupt 21h Function 716Ch) or Extended File Open (Interrupt 21h Function 6Ch). Interrupt 21h Function 5707h Set Creation Date and Time
mov ax, 5707h ; Set Creation Date and Time
mov bx, Handle ; file handle
mov cx, Time ; new creation time
mov dx, Date ; new creation date
mov si, MilliSeconds ; number of 10 ms intervals in 2 seconds
int 21h
jc error
Sets the creation date and time for the given file. If successful, clears the carry flag. Otherwise, sets the carry flag and sets the AX register to an error value. Handle File handle. It must have been previously retrieved by using Create or Open File (Interrupt 21h Function 716Ch) or Extended File Open (Interrupt 21h Function 6Ch). Time New creation time. The new creation time is a packed 16-bit value with the following form:
Bits Contents
0-4 Second divided by 2
5-10 Minute (0-59)
11-15 Hour (0-23 on a 24-hour clock)
Date New creation date. The new creation date is a packed 16-bit value with the following form:
Bits Contents
0-4 Day of the month (1-31)
5-8 Month (1 = January, 2 = February, and so on)
9-15 Year offset from 1980 (add 1980 to get the actual year)
MilliSeconds Number of 10 millisecond intervals in 2 seconds to add to the MS-DOS time. It can be a value in the range 0 to 199. Interrupt 21h Function 6Ch Extended Open/Create
mov ah, 6Ch ; Extended Open/Create
mov bx, ModeAndFlags ; access and sharing mode and open flags
mov cx, Attributes ; file attributes
mov dx, Action ; action to take
mov si, seg Filename ; address of 8.3 filename
mov ds, si
mov si, offset Filename
int 21h
jc error
mov [Handle], ax ; file handle
mov [ActionTaken], cx ; action taken to open file
Opens or creates a file having the given name and attributes. If successful, clears the carry flag, copies the file handle to the AX register, and sets CX to one of these values: ACTION_OPENED (0001h) ACTION_CREATED_OPENED (0002h) ACTION_REPLACED_OPENED (0003h) Otherwise, sets the carry flag and sets the AX register to one of these error values: ERROR_INVALID_FUNCTION (0001h) ERROR_FILE_NOT_FOUND (0002h) ERROR_PATH_NOT_FOUND (0003h) ERROR_TOO_MANY_OPEN_FILES (0004h) ERROR_ACCESS_DENIED (0005h) ModeAndFlags Combination of access mode, sharing mode, and open flags. It can be one value each from the access and sharing modes and any combination of open flags:
Access mode Meaning
OPEN_ACCESS_READONLY (0000h)
Opens the file for reading only.
OPEN_ACCESS_WRITEONLY (0001h)
Opens the file for writing only.
OPEN_ACCESS_READWRITE (0002h)
Opens the file for reading and writing.
0003h
Reserved, do not use.
OPEN_ACCESS_RO_NOMODLASTACCESS (0004h)
Opens the file for reading only without modifying the
file's last
access date.
Sharing mode Meaning
OPEN_SHARE_COMPATIBLE (0000h)
Opens the file with compatibility mode, allowing any
process on a
given computer to open the file any number of times.
OPEN_SHARE_DENYREADWRITE (0010h)
Opens the file and denies both read and write access
to other
processes.
OPEN_SHARE_DENYWRITE (0020h)
Opens the file and denies write access to other
processes.
OPEN_SHARE_DENYREAD (0030h)
Opens the file and denies read access to other
processes.
OPEN_SHARE_DENYNONE (0040h)
Opens the file without denying read or write access to
other
processes but no process may open the file for
compatibility
access.
Open flags Meaning
OPEN_FLAGS_NOINHERIT (0080h)
If this flag is set, a child process created with Load
and Execute
Program (Interrupt 21h Function 4B00h) does not
inherit the file
handle. If the handle is needed by the child process,
the parent
process must pass the handle value to the child
process. If this
flag is not set, child processes inherit the file
handle.
OPEN_FLAGS_NOCRITERR (2000h)
If a critical error occurs while MS-DOS is opening
this file,
Critical-Error Handler (Interrupt 24h) is not called.
Instead, MS-
DOS simply returns an error value to the program.
OPEN_FLAGS_COMMIT (4000h)
After each write operation, MS-DOS commits the file
(flushes the
contents of the cache buffer to disk).
Attributes Attributes for files that are created or truncated. They may be a combination of these values: FILE_ATTRIBUTE_NORMAL (0000h) The file can be read from or written to. This value is valid only if used alone. FILE_ATTRIBUTE_READONLY (0001h) The file can be read from but not written to or deleted. It can be renamed. FILE_ATTRIBUTE_HIDDEN (0002h) The file is hidden and does not appear in an ordinary directory listing. FILE_ATTRIBUTE_SYSTEM (0004h) The file is part of the operating system or is used exclusively by it. FILE_ATTRIBUTE_VOLUME (0008h) The name specified by Filename is used as the volume label for the current medium. FILE_ATTRIBUTE_ARCHIVE (0020h) The file is an archive file. Applications use this value to mark files for backup or removal. Action Action to take it the file exists or if it does not exist. It can be a combination of these values:
FILE_CREATE (0010h) Creates a new file if it does not already
exist.
FILE_OPEN (0001h) Opens the file. The function fails if the
file does not exist.
FILE_TRUNCATE (0002h) Opens the file and truncates it to zero
length (replaces the existing file). The
function fails if the file does not exist.
The only valid combinations are FILE_CREATE combined with FILE_OPEN or FILE_CREATE combined with FILE_TRUNCATE. Filename Address of a null-terminated string specifying the name of the file to be opened or created. The name must be in the standard MS-DOS 8.3 filename format. The string must be a valid path for the volume associated with the given drive. This function does not support long filenames. If the specified name is too long, this function truncates the name to a standard 8.3 format name following the same naming scheme that the system uses when creating an alias for a long filename. A file on a remote directory--that is, a directory on the network--cannot be opened, unless appropriate permissions for the directory exist. Interrupt 21h Function 7139h Make Directory
mov ax, 7139h ; Make Directory
mov dx, seg Name ; address of directory name
mov ds, dx
mov dx, offset Name
int 21h
jc error
Creates a new directory having the given name. If successful, clears the carry flag. Otherwise, sets the carry flag and sets the AX register to an error value. Name Address of a null-terminated string specifying the name of the directory to create. Long filenames are allowed. Interrupt 21h Function 713Ah Remove Directory
mov ax, 713Ah ; Remove Directory
mov dx, seg Name ; address of directory name
mov ds, dx
mov dx, offset Name
int 21h
jc error
Removes the given directory. The directory must be empty. If successful, clears the carry flag. Otherwise, sets the carry flag and sets the AX register to an error value. Name Address of a null-terminated string specifying the name of the directory to remove. Long filenames are allowed. The root directory can not be deleted. Interrupt 21h Function 713Bh Change Directory
mov ax, 713Bh ; Change Directory
mov dx, seg Path ; address of path for new directory
mov ds, dx
mov dx, offset Path
int 21h
jc error
Changes the current directory to the directory specified by the given path. If successful, clears the carry flag. Otherwise, sets the carry flag and sets the AX register to an error value. Path Address of a null-terminated string specifying the directory to change to. The path, which can include the drive letter, must be a valid path for the given volume. Long filenames are allowed. If a drive other than the default drive is specified as part of the new directory path, this function changes the current directory on that drive but does not change the default drive. Set Default Drive (Interrupt 21h Function 0Eh) can be used to change the default drive. Interrupt 21h Function 7141h Delete File
mov ax, 7141h ; Delete File
mov dx, seg Filename ; address of filename
mov ds, dx
mov dx, offset Filename
mov si, WildcardAndAttrs ; allow wildcards and match attributes
int 21h
jc error
Deletes the given file or files. If the specified filename contains a wildcard character, Delete File can delete multiple files that match the wildcard. If successful, clears the carry flag. Otherwise, sets the carry flag and sets the AX register to an error value. Filename Address of a null-terminated string specifying the name of the file to delete. If WildcardAndAttrs is 1, the "*" and "?" wildcard characters are permitted in the filename. Long filenames are allowed. WildcardAndAttrs Search criteria. The high byte must be one of these values:
0 Wildcard characters are not allowed in Filename. The attributes are
ignored.
1 Wildcard characters are allowed in Filename. Files with specified
attributes are marked.
If the high byte is 1, the low byte must specify the attributes that files must match to be deleted. They can be a combination of these values: FILE_ATTRIBUTE_NORMAL (0000h) The file can be read from or written to. This value is valid only if used alone. FILE_ATTRIBUTE_READONLY (0001h) The file can be read from but not written to or deleted. It can be renamed. FILE_ATTRIBUTE_HIDDEN (0002h) The file is hidden and does not appear in an ordinary directory listing. FILE_ATTRIBUTE_SYSTEM (0004h) The file is part of the operating system or is used exclusively by it. FILE_ATTRIBUTE_VOLUME (0008h) The name specified by Filename is used as the volume label for the current medium. It is not necessary to know the volume label name to delete it. If "*" is specified as the Filename, only this attribute flag, and no others, is used to delete the volume label. FILE_ATTRIBUTE_ARCHIVE (0020h) The file is an archive file. Applications use this value to mark files for backup or removal. Wildcard searches are more flexible in WINDOWS 95 than in MS-DOS. For example, *1 finds the filenames (both long filenames and aliases) that end in a 1 and *mid* finds filenames that contain the characters mid. In MS-DOS and in WINDOWS 95 searching on real-mode FAT directories, all characters after the first * are ignored. Interrupt 21h Function 7143h Get or Set File Attributes
mov ax, 7143h ; Get or Set File Attributes
mov bl, Action ; 0 to get attributes, 1 to set
mov cx, Attributes ; file attributes (used only if bl is 1)
mov dx, seg Filename ; address of filename
mov ds, dx
mov dx, offset Filename
int 21h
jc error
mov [Attributes], cx ; file attributes if BL was 0
Retrieves or sets the file attributes for the given file. If successful, clears the carry flag, and if the BL register was 0, sets the CX register to a combination of these values: FILE_ATTRIBUTE_NORMAL (0000h) FILE_ATTRIBUTE_READONLY (0001h) FILE_ATTRIBUTE_HIDDEN (0002h) FILE_ATTRIBUTE_SYSTEM (0004h) FILE_ATTRIBUTE_VOLUME (0008h) FILE_ATTRIBUTE_DIRECTORY (0010h) FILE_ATTRIBUTE_ARCHIVE (0020h) Otherwise, sets the carry flag and sets the AX register to an error value. Action Action to take. It can be 0 to retrieve attributes and 1 to set attributes. Attributes File attributes to set. They are used only if Action is 1. They can be a combination of these values: FILE_ATTRIBUTE_NORMAL (0000h) The file can be read from or written to. This value is valid only if used alone. FILE_ATTRIBUTE_READONLY (0001h) The file can be read from but not written to or deleted. It can be renamed. FILE_ATTRIBUTE_HIDDEN (0002h) The file is hidden and does not appear in an ordinary directory listing. FILE_ATTRIBUTE_SYSTEM (0004h) The file is part of the operating system or is used exclusively by it. FILE_ATTRIBUTE_ARCHIVE (0020h) The file is an archive file. Applications use this value to mark files for backup or removal. Filename Address of a null-terminated string specifying the name of the file to retrieve or set attributes for. Long filenames are allowed. Interrupt 21h Function 7147h Get Current Directory
mov ax, 7147h ; Get Current Directory
mov dl, Drive ; drive number
mov si, seg Buffer ; address of buffer for path
mov ds, si
mov si, offset Buffer
int 21h
jc error
Copies the path of the current directory for the given drive to the buffer. The copied path does not include the drive letter or the leading backslash. If successful, clears the carry flag and copies the path. Otherwise, sets the carry flag and sets the AX register to an error value. Drive Drive number. It can be 0 for current drive, 1 for A, 2 for B, and so on. Buffer Address of the buffer that receives the path. The buffer must be at least as big as the maximum allowed path for this volume as returned by Get Volume Information (Interrupt 21h Function 71A0h). Interrupt 21h Function 714Eh Find First File
mov ax, 714Eh ; Find First File
mov ch, MustMatchAttrs ; must match attributes
mov cl, SearchAttrs ; search attributes
mov dx, seg Filename ; file to search for
mov ds, dx
mov dx, offset Filename
mov di, seg FindData ; address of WIN32_FIND_DATA struct
mov es, di
mov di, offset FindData
mov si, DateTimeFormat ; format for returned date and time
int 21h
jc error
mov [Handle], ax ; search handle
mov [ConversionCode], cx ; UNICODE to OEM/ANSI conversion ok?
Searches a directory for the first file or directory whose name and attributes match the specified name and attributes. If successful, clears the carry flag, copies information about the file to the specified buffer, returns the search handle in the AX register, and sets the CX register to a combination of these values:
0x0000 All characters in the primary and alternate name members in the
structure specified by FindData were successfully converted
from UNICODE.
0x0001 The primary name returned in the structure specified by
FindData contains underscore characters in place of characters
that could not be converted from UNICODE.
0x0002 The alternate name returned in the structure specified by
FindData contains underscore characters in place of characters
that could not be converted from UNICODE.
Otherwise, sets the carry flag and sets the AX register to an error value. MustMatchAttrs An additional filter on the attributes specified in SearchAttrs. It can be a combination of these values: FILE_ATTRIBUTE_NORMAL (0000h) The file can be read from or written to. This value is valid only if used alone. FILE_ATTRIBUTE_READONLY (0001h) The file can be read from but not written to or deleted. It can be renamed. FILE_ATTRIBUTE_HIDDEN (0002h) The file is hidden and does not appear in an ordinary directory listing. FILE_ATTRIBUTE_SYSTEM (0004h) The file is part of the operating system or is used exclusively by it. FILE_ATTRIBUTE_VOLUME (0008h) The name specified by Filename is used as the volume label for the current medium. FILE_ATTRIBUTE_DIRECTORY (0010h) The name specified by Filename is used as a directory, not a file. FILE_ATTRIBUTE_ARCHIVE (0020h) The file is an archive file. Applications use this value to mark files for backup or removal. SearchAttrs File attributes to search for. They can be a combination of these values: FILE_ATTRIBUTE_NORMAL (0000h) FILE_ATTRIBUTE_READONLY (0001h) FILE_ATTRIBUTE_HIDDEN (0002h) FILE_ATTRIBUTE_SYSTEM (0004h) FILE_ATTRIBUTE_VOLUME (0008h) FILE_ATTRIBUTE_DIRECTORY (0010h) FILE_ATTRIBUTE_ARCHIVE (0020h) Filename Address of a null-terminated string specifying the name of the file or directory to search for. The name, which must be a valid filename or directory name, can include the "*" and "?" wildcard characters. Long filenames are allowed. FindData Address of a WIN32_FIND_DATA structure that receives information about the file. DateTimeFormat Date and time format to be returned. It must be one of these values:
0 Returns the date and time in 64-bit file time format.
1 Returns the MS-DOS date and time values.
Find First File and subsequent calls to Find Next File (Interrupt 21h Function 714Fh) use the following algorithm to match the attributes of a file or directory (referred to as Attributes in the algorithm) against MustMatchAttrs and SearchAttrs.
if ((((MustMatchAttrs & .about.Attributes) & 0x3F) == 0)
&& (((.about.SearchAttrs & Attributes) & 0x1E) == 0))
{
return the file or directory name
}
else
{
continue searching for the next name
}
The following table lists the MustMatchAttrs and SearchAttrs values for some common searches where the specified filename is "*.*". In the table, the word normal means that the read only, hidden, or system attributes have not been set. Parentheses are used to indicate that a file or directory has more than one attribute. For example, (hidden and system) indicates that a file or directory has both the hidden attribute and the system attribute.
MustMatchAttrs SearchAttrs Find results
10h 10h All normal directories
10h 12h All normal and hidden directories
10h 14h All normal and system directories
10h 16h All normal, hidden, system and (hidden
and system) directories
12h 12h All hidden directories
14h 14h All system directories
16h 16h All (hidden and system) directories
00h 00h All normal files
00h 01h All normal and read only files
00h 02h All normal and hidden files
00h 04h All normal and system files
00h 06h All normal, hidden, system, and (hidden
and system) files
00h 10h All normal files and directories
01h 01h All read only files
02h 02h All hidden files
02h 06h All hidden and (hidden and system)
files
This function can be used to return the volume label by specifying only FILE_ATTRIBUTE_VOLUME (0008h) in both MustMatchAttrs and the SearchAttrs. An application may use the handle returned in the AX register in subsequent calls to Find Next File (Interrupt 21h Function 714Fh). It is important to close the handle when it is no longer needed by calling Find Close (Interrupt 21h Function 71A1h). Wildcard searches are more flexible in WINDOWS 95 than in MS-DOS. For example, *1 finds the filenames (both long filenames and aliases) that end in a 1, and *mid* finds filenames that contain the characters mid. In MS-DOS and in WINDOWS 95 searching on real-mode FAT directories, all characters after the first * are ignored. Interrupt 21h Function 714Fh Find Next File
mov ax, 714Fh ; Find Next File
mov bx, Handle ; search handle from Find First File
mov di, seg FindData ; address of WIN32_FIND_DATA struct
mov es, di
mov di, offset FindData
mov si, DateTimeFormat ; format for returned date and time
int 21h
Searches for the next file in a directory, returning information about the file in the given buffer. If successful, clears the carry flag, copies information to the specified buffer, and sets the CX register to a combination of these values:
0x0000 All characters in the primary and alternate name member in the
structure specified by FindData were successfully converted
from UNICODE.
0x0001 The primary name returned in the structure specified by
FindData contains underscore characters in place of characters
that could not be converted from UNICODE.
0x0002 The alternate name returned in the structure specified by
FindData contains underscore characters in place of characters
that could not be converted from UNICODE.
Otherwise, sets the carry flag and sets the AX register to an error value. Handle Search handle. It must have been previously returned from Find First File (Interrupt 21h Function 714Eh). FindData Address of a WIN32_FIND_DATA structure that receives information about the file. DateTimeFormat Date and time format to be returned. It must be one of these values:
0 Returns the date and time in 64-bit file time format.
1 Returns the MS-DOS date and time values.
Interrupt 21h Function 7156h Rename File
mov ax, 7156h ; Rename File
mov dx, seg OldName ; address of filename or path
mov ds, dx
mov dx, offset OldName
mov di, seg NewName ; address of new filename or path
mov es, di
mov di, offset NewName
int 21h
jc error
Changes the name of the given file or directory to the new name. If successful, clears the carry flag. Otherwise, sets the carry flag and sets the AX register to an error values. OldName Address of a null-terminated string specifying the original name of the file or the directory to rename. Long filenames are allowed. NewName Address of a null-terminated string specifying the new name for the file or the directory. Rename File will fail if NewName specifies an existing file or directory. The new name must not specify a drive different than the original drive. Long filenames are allowed. Interrupt 21h Function 7160h Get Full Path Name
mov ax, 7160h
mov cx, 0 ; Get Full Path Name
mov si, seg SourcePath ; address of source string
mov ds, si
mov si, offset SourcePath
mov di, seg DestPath ; address of dest string
mov es, di
mov di, offset DestPath
int 21h
jc error
Retrieves the full path for the specified file or path. If successful, clears the carry flag, modifies the AX register, and returns the full path in the given buffer. Otherwise, sets the carry flag and sets the AX register to an error value. SourcePath Address of a null-terminated string that names the file or path to retrieve the full path for. Either the long filename or the standard 8.3 filename format is acceptable. DestPath Address of the buffer that receives the full path. The buffer should be large enough to contain the largest possible WINDOWS 95 path (260 characters, including the drive letter, colon, leading backslash, and terminating null character). When just a filename is specified, Get Full Path Name merges the name of the current drive and directory with the specified filename to determine the full path. Relative paths containing the characters "." and "." in the SourcePath are filly expanded. The function does no validation, so the specified filename or path does not need to exist. Interrupt 21h Function 7160h Get Short Path Name
mov ax, 7160h
mov cx, 1 ; Get Short Path Name
mov si, seg SourcePath ; address of source string
mov ds, si
mov si, offset SourcePath
mov di, seg DestPath ; address of dest string
mov es, di
mov di, offset DestPath
int 21h
jc error
Retrieves the full path in its short form (the standard 8.3 filename format) for the specified file or path. The function returns the 8.3 name for all directories in the path. If successful, clears the carry flag, modifies the AX register, and returns the full short path in the given buffer. Otherwise, sets the carry flag and sets the AX register to an error value. SourcePath Address of a null-terminated sting that names the file or path to retrieve the full short path for. Either the long filename or the short form is acceptable as the source string. DestPath Address of the buffer that receives the full path. The buffer should be large enough to contain the largest possible WINDOWS 95 path in the short form (260 characters, including drive letter, colon, leading backslash, and terminating null character). Relative paths containing the characters "." and ".." in the SourcePath are fully expanded. Since this function performs validation, SourcePath must contain either a valid filename or path. Interrupt 21h Function 7160h Get Long Path Name
mov ax, 7160h
mov cx, 2 ; Get Long Path Name
mov si, seg SourcePath ; address of source string
mov ds, si
mov si, offset SourcePath
mov di, seg DestPath ; address of dest string
mov es, di
mov di, offset DestPath
int 21h
jc error
Retrieves the full path in its long filename form for the specified file or path. The function returns the long name for all directories in the path. If successful, clears the carry flag, modifies the AX register, and returns the full long path in the given buffer. Otherwise, sets the carry flag and sets the AX register to an error value. SourcePath Address of a null-terminated string that names the file or path to retrieve the full long path for. Either the long filename or the short form is acceptable as the source string. DestPath Address of the buffer that receives the fill path. The buffer should be large enough to contain the largest possible WINDOWS 95 path (260 characters, including drive letter, colon, leading backslash, and terminating null character). Relative paths containing the characters "." and ".." in the SourcePath are fully expanded. Since this function performs validation, SourcePath must contain either a valid filename or path. Interrupt 21h Function 716Ch Create or Open File
mov ax, 716Ch ; Create or Open File
mov bx, ModeAndFlags ; access and sharing modes and flags
mov cx, Attributes ; file attributes
mov dx, Action ; action to take
mov si, seg Filename ; address of filename
mov ds, si
mov si, offset Filename
mov di, AliasHint ; numeric tail for file's short name
int 21h
jc error
mov [Handle], ax ; file handle
mov [ActionTaken], cx ; action taken to open file
Creates or opens a file. If successful, clears carry flag, copies the file handle to the AX register, and sets the CX register to one of these values: ACTION_OPENED (0001h) ACTION_CREATED_OPENED (0002h) ACTION_REPLACED_OPENED (0003h) Otherwise, sets the carry flag and sets the AX register to an error value. ModeAndFlags Combination of access mode, sharing mode, and open flags. It can be one value each from the access and sharing modes and any combination of open flags:
Access mode Meaning
OPEN_ACCESS_READONLY (0000h)
Opens the file for reading only.
OPEN_ACCESS_WRITEONLY (0001h)
Opens the file for writing only.
OPEN_ACCESS_READWRITE (0002h)
Opens the file for reading and writing.
0003h
Reserved; do not use.
OPEN_ACCESS_RO_NOMODLASTACCESS (0004h)
Opens the file for reading only without modifying
the file's last
access date.
Sharing mode Meaning
OPEN_SHARE_COMPATIBLE (0000h)
Opens the file with compatibility mode, allowing
any process on a
given computer to open the file any number of
times.
OPEN_SHARE_DENYREADWRITE (0010h)
Opens the file and denies both read and write
access to other
processes.
OPEN_SHARE_DENYWRITE (0020h)
Opens the file and denies write access to other
processes.
OPEN_SHARE_DENYREAD (0030h)
Opens the file and denies read access to other
processes.
OPEN_SHARE_DENYNONE (0040h)
Opens the file without denying read or write
access to other
processes but no process may open the file for
compatibility
access.
Open flags Meaning
OPEN_FLAGS_NOINHERIT (0080h)
If this flag is set, a child process created with
Load and Execute
Program (Interrupt 21h Function 4B00h) does not
inherit the file
handle. If the handle is needed by the child
process, the parent
process must pass the handle value to the child
process. If this
flag is not set, child processes inherit the file
handle.
OPEN_FLAGS_NO_BUFFERING (0100h)
The file is to be opened with no intermediate
buffering or caching
done by the system. Read and write operations
access the disk
directly. All reads and writes to the file must be
done at file
positions that are multiples of the disk sector
site and the number
of bytes read or written should also be a multiple
of the sector
size. Applications can determine the sector size
with the Get Disk
Free Space function (Interrupt 21h, Function 36h).
OPEN_FLAGS_NO_COMPRESS (0200h)
The file should not be compressed on a volume that
performs file
compression. If the volume does not perform file
compression,
this flag is ignored. This flag is valid only on
file creation and is
ignored on file open.
OPEN_FLAGS_ALIAS_HINT (0400h)
The number in the DI register is to be used as the
numeric tail for
the alias (short file name) if the default alias
is already used by
another file. For more information, see AliasHint
below.
OPEN_FLAGS_NOCRITERR (2000h)
If a critical error occurs while MS-DOS is opening
this file,
Critical-Error Handler (Interrupt 24h) is not
called. Instead, MS-
DOS simply returns an error value to the program.
OPEN_FLAGS_COMMIT (4000h)
After each write operation, MS-DOS commits the
file (flushes the
contents of the cache buffer to disk).
Attributes
Attributes for files that are created or truncated. They may be a
combination of these values:
FILE_ATTRIBUTE_NORMAL (0000h)
The file can be read from or written to. This
value is valid only if
used alone.
FILE_ATTRIBUTE_READONLY (0001h)
The file can be read from but not written to or
deleted. It can be
renamed.
FILE_ATTRIBUTE_HIDDEN (0002h)
The file is hidden and does not appear in an
ordinary directory
listing.
FILE_ATTRIBUTE_SYSTEM (0004h)
The file is part of the operating system or is
used exclusively by it.
FILE_ATTRIBUTE_VOLUME (0008h)
The name specified by Filename is used as the
volume label for
the current medium and is restricted to the
standard 8.3 format.
For information about an alternative way to set
the volume label,
see Set Media ID (Interrupt 21h Function 440Dh
Minor Code
46h) in the MS-DOS Programmer's Reference.
FILE_ATTRIBUTE_ARCHIVE (0020h)
The file is an archive file. Applications use this
value to mark files
for backup or removal.
Action
Action to take it the file exists or if it does not exist. It can be a
combination of these values:
FILE_CREATE (0010h) Creates a new file if it does not already exist.
FILE_OPEN (0001h) Opens the file. The function fails if the file
does
not exist.
FILE_TRUNCATE (0002h) Opens the file and truncates it to zero length
(replaces the existing file). The function fails
if
the file does not exist.
The only valid combinations are FILE_CREATE combined with FILE_OPEN or FILE_CREATE combined with FILE_TRUNCATE. Filename Address of a null-terminated string specifying the name of the file to be opened or created. The string must be a valid path for the volume associated with the given drive. Long filenames are allowed. AliasHint Number that is used in the numeric tail for the alias (short filename) if the default alias already exists. A numeric tail, which consists of the tilde character (.about.) followed a number, is appended to the end of a filename. If the default alias already exists, the system will construct the alias from the first few characters of the long filename followed by the numeric tail. The system starts with the number 1 in the numeric tail. If that filename is in use, it then uses the number 2. It continues in this fashion until a unique name is found. To override the default numbering scheme you must specify the flag OPEN_FLAGS_ALIAS_HINT when you create the file in addition to specifying this parameter. If a filename already exists with the specified numeric tail, the system uses the default numbering scheme. A file on a remote directory--that is, a directory on the network-cannot be opened, created or modified unless the appropriate permissions for the directory exist. Interrupt 21h Function 71A0h Get Volume Information
mov ax, 71A0h ; Get Volume Information
mov di, seg Buffer ; addr of buffer that receives file system
name
mov es, di
mov di, offset Buffer
mov cx, BufSize ; size of buffer, in bytes
mov dx, seg RootName ; address of root directory path
mov ds, dx
mov dx, offset RootName
int 21h
jc error
mov [Flags], bx ; file system flags
mov [MaxFilename], cx ; max. filename length including null
mov [MaxPath], dx ; max. path length including null
Returns information about the volume associated with the given root directory. If successful, clears the carry flag, copies the file system name to the buffer given by the ES:DI register pair, and sets the BX, CX, and DX registers to these values:
BX File system flags. It can be a combination of these values:
FS_CASE_SENSITIVE (0001h)
Specifies that searches are case-sensitive.
FS_CASE_IS_PRESERVED (0002h)
Preserves case in directory entries.
FS_UNICODE_ON_DISK (0004h)
Uses Unicode characters in file and directory names.
FS_LFN_APIS (4000h)
Supports new long filename functions.
FS_VOLUME_COMPRESSED (8000h)
Specifies that the volume is compressed.
CX Maximum allowed length, including terminating null character,
of a filename for this volume.
DX Maximum allowed length of a path for this volume, including
drive letter, colon, leading slash, and terminating null
character.
Otherwise, sets the carry flag and sets the AX register to an error value. Buffer Address of a buffer that receives a null-terminated string specifying the name of the file system. BuffSize Size, in bytes, of the buffer that receives the name. The buffer should include space for the terminating null character. RootName Address of a null-terminated string specifying the name of the root directory of the volume to check. This parameter must not be NULL, or the function will fail. The format for this parameter is: "C:.backslash.". This function accesses the disk the first time it is called, but subsequent calls do not access the disk. Interrupt 21h Function 71A1h Find Close
mov ax, 71A1h ; Find Close
mov bx, Handle ; search handle from Find First File
int 21h
jc error
Closes the file search referred to by Handle. If successful, clears the carry flag. Otherwise, sets the carry flag and sets the AX register to an error value. Handle Search handle. It must have been previously returned from Find First File (Interrupt 21h Function 714Eh). Interrupt 21h Function 71A6h Get File Info By Handle
mov ax, 71a6h ; Get File Info By Handle
mov bx, Handle ; handle of file
mov dx, seg lpFileInfo ; address of
mov ds, dx ; BY_HANDLE_FILE_INFORMATION
struct
mov dx, offset lpFileInfo
int 21h
Retrieves information about the specified file. If successful, clears the carry flag. Otherwise, sets the carry flag and sets the AX register to an error value. Handle File handle to retrieve information about. It must have been previously returned by using Create or Open File (Interrupt 21h Function 716Ch) or Extended File Open (Interrupt 21h Function 6Ch). lpFileInfo Address of a BY_HANDLE_FILE_INFORMATION structure that receives the file information. The structure can be used in subsequent calls to Get File Info By Handle to refer to the information about the file. Interrupt 21h Function 71A7h File Time To DOS Time
mov ax, 71A7h ; date and time format conversion
mov bl, 0 ; File Time To DOS Time
mov si, seg lpft ; address of FILETIME structure
mov ds, si
mov si, offset lpft
int 21h
jc error
mov [DOSTime], cx
mov [DOSDate], dx
mov [MilliSeconds], bh ; number of 10 ms intervals in 2 seconds
Converts a 64-bit file time to MS-DOS date and time values. If successful, clears the carry flag, and sets the BH, CX, and DX registers to these values:
Bits Contents
BH Number of 10 millisecond intervals in 2 seconds to add
to the MS-DOS time. It can be a value in the range 0 to
199.
CX MS-DOS time. The time is a packed 16-bit value with the
following form:
0-4 Second divided by 2
5-10 Minute (0-59)
11-15 Hour (0-23 on a 24-hour clock)
DX MS-DOS date. The date is a packed 16-bit value with the
following form:
0-4 Day of the month (1-31)
5-8 Month (1 = January, 2 = February, and so on)
9-15 Year offset from 1980 (add 1980 to get the actual year)
Otherwise, sets the carry flag and sets the AX register to an error value. lpft Address of a FILETIME structure containing the 64-bit file time to convert to the MS-DOS date and time format. The MS-DOS date format can represent only dates between 1/1/1980 and 12/31/2107; this conversion fails if the input file time is outside this range. Interrupt 21h Function 71A7h DOS Time To File Time
mov ax, 71A7h ; date and time format conversion
mov bl, 1 ; Dos Time To File Time
mov bh, MilliSeconds ; number of 10 ms intervals in 2 seconds
mov cx, DOSTime
mov dx, DOSDate
mov di, seg lpft ; address of FILETIME structure
mov es, di
mov di, offset lpft
int 21h
jc error
Converts MS-DOS date and time values to 64-bit file time. If successful, clears the carry flag and returns the 64-bit file time in the specified file time structure. Otherwise, sets the carry flag and sets the AX register to an error value. MilliSeconds Number of 10 millisecond intervals in 2 seconds to add to the MS-DOS time. It can be a value in the range 0 to 199. DOSTime MS-DOS time to convert. The time is a packed 16-bit value with the following form:
Bits Contents
0-4 Second divided by 2
5-10 Minute (0-59)
11-15 Hour (0-23 on a 24-hour clock)
DOSDate MS-DOS date to convert. The date is a packed 16-bit value with the following form:
Bits Contents
0-4 Day of the month (1-31)
5-8 Month (1 = January, 2 = February, and so on)
9-15 Year offset from 1980 (add 1980 to get the actual year)
lpft Address of a FILETIME structure to receive the converted 64-bit file time. Structures BY_HANDLE_FILE_INFORMATION
BY_HANDLE_FILE_INFORMATION struc
dwFileAttributes dd ? ; see below
ftCreationTime dd 2 dup(?) ; see below
ftLastAccessTime dd 2 dup(?) ; see below
ftLastWriteTime dd 2 dup(?) ; see below
dwVolumeSerialNumber dd ? ; see below
nFileSizeHigh dd ? ; see below
nFileSizeLow dd ? ; see below
nNumberOfLinks dd ? ; see below
nFileIndexHigh dd ? ; see below
nFileIndexLow dd ? ; see below
BY_HANDLE_FILE_INFORMATION ends
Contains file information retrieved by Get File Info By Handle (Interrupt 21h Function 71A6h). dwFileAttributes File attributes. It can be one or more of these values: FILE_ATTRIBUTE_NORMAL (00000000h) The file can be read from or written to. This value is valid only if used alone. FILE_ATTRIBUTE_READONLY (00000001h) The file can be read from but not written to or deleted. It can be renamed. FILE_ATTRIBUTE_HIDDEN (00000002h) The file is hidden and does not appear in an ordinary directory listing. FILE_ATTRIBUTE_SYSTEM (00000004h) The file is part of the operating system or is used exclusively by it. FILE_ATTRIBUTE_DIRECTORY (00000010h) The name specifies a directory, not a file. FILE_ATTRIBUTE_ARCHIVE (00000020h) The file is an archive file. Applications use this value to mark files for backup or removal. ftCreationTime Time that the file was created in 64-bit file time format. A value of 0,0 indicates that the file system containing the file does not support this member. ftLastAccessTime Time that the file was last accessed in 64-bit file time format. A value of 0,0 indicates that the file system containing the file does not support this member. ftLastWriteTime Time that the file was last written to in 64-bit file time format. All file systems support this member. If the underlying file system does not support the last write time, ftLastWriteTime is the time the file was created. dwVolumeSerialNumber Serial number of the volume that contains the file. nFileSizeHigh High-order word of the file size. nFileSizeLow Low-order word of the file size. nNumberOfLinks Number of links to this file. For FAT and HPFS file systems, this member is always 1. For NTFS, it may be more than 1. nFileIndexHigh High-order word of a unique identifier associated with the file. nFileIndexLow Low-order word of a unique identifier associated with the file. This identifier and the volume serial number uniquely identify a file. This number may change when the system is restarted or when the file is opened. After a process opens a file, the identifier is constant until the file is closed. An application can use this identifier and the volume serial number to determine whether two handles refer to the same file. The value returned by nFileIndexHigh and nFileIndexLow may be invalid on some file systems, such as real-mode network redirected file systems. In this case, an invalid index value will be returned. FILETIME FILETIME struc dwLowDateTime dd ?; see below dwHighDateTime dd ?; see below FILETIME ends Contains a 64-bit value specifying the number of 100-nanosecond intervals that have elapsed since 12:00 A.M. Jan. 1, 1901. dwLowDateTime Low-order 32 bits of the file time. dwHighDateTime High-order 32 bits of the file time. WIN32_FIND_DATA
WIN32_FIND_DATA struc
dwFileAttributes dd ? ; see below
ftCreationTime dd 2 dup(?) ; see below
ftLastAccessTime dd 2 dup(?) ; see below
ftLastWriteTime dd 2 dup(?) ; see below
nFileSizeHigh dd ? ; high word of
file size,
in bytes
nFileSizeLow dd ? ; low word of
file size,
in bytes
dwReserved0 dd 0 ; reserved;
do not use
dwReserved1 dd 0 ; reserved;
do not use
cFileName db MAX_PATH dup(?) ; see below
cAlternateFileName db 14 dup(?) ; see below
WIN32_FIND_DATA ends
Describes a file found by Find First File (Interrupt 21h Function 714Eh) or Find Next File (Interrupt 21h Function 714Fh). dwFileAttributes File attributes of the file found. They can be one or more of these values: FILE_ATTRIBUTE_NORMAL (00000000h) The file can be read from or written to. This value is valid only if used alone. FILE_ATTRIBUTE_READONLY (00000001h) The file can be read from but not written to or deleted. It can be renamed. FILE_ATTRIBUTE_HIDDEN (00000002h) The file is hidden and does not appear in an ordinary directory listing. FILE_ATTRIBUTE_SYSTEM (00000004h) The file is part of the operating system or is used exclusively by it. FILE_ATTRIBUTE_DIRECTORY (00000010h) The name specifies a directory, not a file. FILE_ATTRIBUTE_ARCHIVE (00000020h) The file is an archive file. Applications use this value to mark files for backup or removal. ftCreationTime Time that the file was created in 64-bit file time format. A value of 0,0 indicates that the file system containing the file does not support this member. ftLastAccessTime Time that the file was last accessed in 64-bit file time format. A value of 0,0 indicates that the file system containing the file does not support this member. ftLastWriteTime Time that the file was last written to in 64-bit file time format. All file systems support this member. cFileName Null-terminated string that is the name of the file. Since long filenames are allowed, the buffer size must be large enough for 256 characters, including the terminating null character. cAlternateFileName Null-terminated string, in standard 8.3 filename format, that is an alternate name of the file. If the cFileName member contains an 8.3-format name or the file system does not permit 8.3-format alternates, this member is set to 0.
|
| ||||||||||
