Saturday, November 21, 2009

2.1 The Possibilities



< BACK  NEXT >

[oR]

2.1
The Possibilities


Files are important in Windows because many different objects are accessed using the file routines. Certain techniques are used in the 32-bit API to open a file, read from it and write to it, and close the file. The API uses identical techniques to work with communications ports (Chapter 11), named pipes, and mailslots on the network (Chapter 8). Therefore, understanding how to work with files is central to understanding many communications task in Windows.



Files are quite interesting in Windows because of all the different capabilities built into the 32-bit API for working with them. For example:




  • As you would expect, you can open, read, and write files. (See Sections 2.3 and 2.7.)




  • You can also open and read compressed files without decompressing them. (See Section 2.10). If you happen to have a file type that is very large and that compresses very well, you can work with it in its compressed form and save quite a bit of disk space.




  • You can open files and read and write them asynchronously. (See Section 7.5.) This overlapping technique makes it possible to perform background I/O tasks without necessarily multi-threading your application. Overlapped I/O is also the basis for multi-threaded access to a named pipe, as discussed in Section 8.5.




  • You can access a great deal of status information about files through the 32-bit API. (See Section 2.4.)




  • You can map files into the virtual memory system to significantly improve their performance. (See Section 2.10.) This technique is also used for high-speed interprocess communication (See file mapping in Section 6.11.)




  • You can lock files or individual records of files. (See Section 2.9.)





A topic like file access that would be mundane in many other operating systems has a good bit of variety and interest in the 32-bit API.



Directories and disk drives are closely related to files, and are discussed in detail in the following two chapters. File security is covered in Chapter 13.





< BACK  NEXT >


No comments: