Книга: Practical Common Lisp
Binary Files
Binary Files
At a sufficiently low level of abstraction, all files are "binary" in the sense that they just contain a bunch of numbers encoded in binary form. However, it's customary to distinguish between text files, where all the numbers can be interpreted as characters representing human-readable text, and binary files, which contain data that, if interpreted as characters, yields nonprintable characters.[260]
Binary file formats are usually designed to be both compact and efficient to parse—that's their main advantage over text-based formats. To meet both those criteria, they're usually composed of on-disk structures that are easily mapped to data structures that a program might use to represent the same data in memory.[261]
The library will give you an easy way to define the mapping between the on-disk structures defined by a binary file format and in-memory Lisp objects. Using the library, it should be easy to write a program that can read a binary file, translating it into Lisp objects that you can manipulate, and then write back out to another properly formatted binary file.
- Binary Files
- Binary Format Basics
- Strings in Binary Files
- Composite Structures
- Designing the Macros
- Making the Dream a Reality
- Reading Binary Objects
- Writing Binary Objects
- Adding Inheritance and Tagged Structures
- Keeping Track of Inherited Slots
- Tagged Structures
- Primitive Binary Types
- The Current Object Stack
- Working with Files Using the File and FileInfo Classes
- 14. Files and File I
- 24. Practical: Parsing Binary Files
- Binary Image Builder Files
- Strings in Binary Files
- 5.1.2. The Directory Server Interface
- Usenet Network Newsgroups
- 6.1.2. File System Layout
- 13.6.3. strings
- 5.2.2. System Structure
- 10.3.2. Writing a Client and a Server
- Installing sendmail