-
Notifications
You must be signed in to change notification settings - Fork 0
Program Development Working with Files
This page details the paradigm by which a command can access/write/operate on a file/files.
In order to perform any action on/with a file, a file must first be verified. In essence, file verification entails searching through the directory and locating the file requested. From here, a file can be loaded, renamed, rewritten, and properties can be retrieved/checked.
A file is verified through INT 0x7E/AH = 0x60, where SI is pointed at an X.3 filename in the form of a string.
Alternatively, a file can be verified straight from a parameter using INT 0x7E/AH = 0x2A, CX being the parameter number.
If file verification fails, KERNEL ERROR 0x0380 will be produced, and any system call requiring verification will use whatever file was last verified successfully.
By default, when a program starts, its own binary file is verified.
Files, like much other data, is loaded into the I/O buffer.
The last verified file can be loaded using INT 0x7E/AH = 0x61, or if an offset from the start of the buffer needs to be specified, INT 0x7E/AH = 0x66 with DI pointing to the offset.
Many different errors can be produced with regard to the filesystem or the disk.
A set of system calls for retrieving file data from the I/O buffer was created to be optimized for working with files specifically.
They can load bytes or lines, and they update the values of SI and DI as pointers, so if a total of seven bytes were retrieved, both registers would have incremented by seven.
There are also a set of calls for overwriting bytes/lines to the buffer specific to files.
A few of them treat the index registers similarly.
System calls INT 0x7E/AH = 0x68-0x6A overwrite bytes in the buffer, while calls INT 0x7E/AH = 0x6B-0x6D insert them, meaning bytes to the right of any new content is shifted rightwards.
The I/O buffer can be written to a file on disk using the system call INT 0x7E/AH = 0x6F.
In this system call, SI can either point to a filename string such as with verification, or it can be set to 0, in which case whatever file was last verified will be overwritten.
Additionally, CX must specify the file size in bytes.
A file of that size will be written from the contents in the I/O buffer, starting at the beginning.
The user must confirm before overwriting a file.
Various properties about the last verified file can be retrieved through system calls, including:
- File size (
INT 0x7E/AH = 0x70) - Creation date (
INT 0x7E/AH = 0x71) - Access date (
INT 0x7E/AH = 0x72) - Write date (
INT 0x7E/AH = 0x73) - Attributes
- Read-only (
INT 0x7E/AH = 0x74) - Visibility (
INT 0x7E/AH = 0x75) - System file (
INT 0x7E/AH = 0x76)
The last verified file can be renamed using the system call INT 0x7E/AH = 0x78, where SI points to a filename in the form of a string.
The file will be renamed to this filename.
An error will be produced if a file with the same name already exists.
The last verified file can be deleted using the system call INT 0x7E/AH = 0x79.
The last verified file can be hidden/revealed using the system call INT 0x7E/AH = 0x7A, where CF is set to reveal a file, or cleared to hide it.
All of these operations will fail if the file is read-only.
Any of the above file operations are temporary and only stored in memory until filesystem changes are applied.
This can be done with the system call INT 0x7E/AH = 0x7F.
The user must confirm before any changes are applied.
The opposite of an operation to apply filesystem changes, system call INT 0x7E/AH = 0x7E can be used to "rollback" to whatever is currently on the disk.
A comma-separated list of files can be obtained through system call INT 0x7E/AH = 0x77.
System call INT 0x7E/AH = 0x65 can be used to get the address of a specific line within the I/O buffer.
Finally, the entire I/O buffer can be cleared with system call INT 0x7E/AH = 0x6E.