Files and Structured I/O

  1. Absolute and Relative File Paths

    An absolute path identifies a location from a filesystem root. A relative path needs a base directory supplied by the process or caller.

    Undergraduate
  2. Combining Path Components

    A path library can join a base folder and relative components under the rules of the target operating system.

    Undergraduate
  3. Opening a Text File with an Explicit Encoding

    Opening a file as text asks the runtime to decode bytes. Choosing the encoding explicitly makes the result independent of many environment defaults.

    Undergraduate
  4. Opening a File in Binary Mode

    A binary stream reads bytes and writes bytes. This preserves exact line endings and encoded data for a format parser or archive.

    Undergraduate
  5. File Modes for Reading, Writing, and Appending

    A file open mode determines which operations are permitted and whether an existing file is preserved, truncated, or extended.

    Undergraduate
  6. Closing Files with a Context Manager

    A context manager gives acquired file resources a scope. Exiting that scope closes the file whether ordinary processing finishes or an exception propagates.

    Undergraduate
  7. Reading a File Line by Line or All at Once

    A line-based reader can process records as they arrive. Reading the entire file is useful when evaluation needs a bounded whole document.

    Undergraduate
  8. Reading Fixed-Size Blocks from a Stream

    A bounded read requests at most some number of bytes. Depending on the interface, a short result can require handling instead of assuming a full record.

    Undergraduate
  9. File Positions and Seeking

    A seekable stream can move its position before the next read or write. Offset rules depend on the stream type.

    Undergraduate
  10. Detecting End of File Without Losing a Record

    An input API signals when no more data is available. Detect that signal separately from ordinary empty fields and short final records.

    Undergraduate
  11. Buffered Writes and Flushing

    A writer can hold bytes in a buffer before delivering them to the next layer. A flush asks that layer to receive the buffered output.

    Undergraduate
  12. Replacing a Generated File After a Complete Write

    A generated output can be written to a temporary file and then moved into place with an atomic replacement operation on a supported filesystem.

    Undergraduate
  13. Temporary Files and Their Lifetime

    A temporary file can hold intermediate data without committing a result to its long-term path. Define who owns it and when it is cleaned up.

    Undergraduate
  14. Processing Directory Entries in a Stable Order

    Filesystem enumeration need not return a useful sort order. Select a sort key when a result depends on the visitation sequence.

    Undergraduate
  15. File Metadata and File Content

    Metadata can describe an entry's name, permissions, size, or timestamps. Several of those values can change without an edit to the logical document.

    Undergraduate
  16. Reading Text from Standard Input

    A command can consume standard input supplied by a terminal, redirected file, or upstream program without choosing the path itself.

    Undergraduate
  17. Standard Output and Standard Error

    A process can emit ordinary output and diagnostics through separate streams, letting a caller capture or redirect them independently.

    Undergraduate
  18. Giving a File Import a Size Budget

    An importer can declare limits on bytes, records, and parsed expansion so it uses resources predictably on valid and invalid inputs.

    Undergraduate
  19. Parsing Text into Records in Stages

    A staged reader can separate decoding, record boundaries, field conversion, and domain validation so each failure has a location.

    Undergraduate
  20. Converting Records Without Loading the Entire File

    A stream-to-stream conversion can read one record, transform it, and write the output before reading the next.

    Undergraduate
  21. Distinguishing File Open, Read, and Decode Errors

    Opening a path, reading data, and interpreting what was read can fail for different reasons.

    Undergraduate
  22. Separating Read-Only Inputs from Writable Results

    Using an input stream for reading and a different output stream for writing makes file ownership and observed effects easier to review.

    Undergraduate
  23. Verifying a Written File at the Consumer Boundary

    Testing a file writer works best by reading its actual output under the expected consumer contract.

    Undergraduate
  24. Returning Typed Records and Diagnostics from a Reader

    A reader can expose parsed values together with source locations or reasons for rejected records, according to its error policy.

    Undergraduate
  25. Checking Metadata Before Reading Large Input

    File metadata can guide whether a reader attempts an operation, but actual bytes and filesystem state can change before or during the read.

    Undergraduate
  26. Reading a Small Configuration File

    Configuration should have a declared structure, visible defaults, and a clear reaction to invalid supplied values.

    Undergraduate
  27. When a Cached File Result Becomes Stale

    Caching a parsed result by path alone can return old data when the same path begins naming updated content.

    Undergraduate
  28. Files, Directories, and Other Directory Entries

    A directory can contain ordinary files, other directories, links, and other entry types supported by the platform.

    Undergraduate
  29. Writing a Final Newline Deliberately

    A record writer needs to decide whether every record ends with a newline or whether newlines only separate adjacent records.

    Undergraduate
  30. Making a Repeatable File Export

    A repeatable export from unchanged inputs gives the same logical contents or bytes, depending on its declared guarantee.

    Undergraduate