Unix File Interface

Unix File Interface
Slide Note
Embed
Share

This content provides an overview of key methods in Unix File Interface and Java I/O, including opening files, reading and writing data, seeking positions, and closing files. It also discusses shallow methods for data handling, modular design concepts, and interfaces for text classes. Additionally, pass-through methods for text documents and Unix `ioctl` for input/output control are explored, offering insights into handling file operations and data structures in Unix environments. The lecture slides illustrate these concepts with practical examples and visuals.

  • Unix File Interface
  • Java I/O Methods
  • Data Handling
  • Modular Design
  • Text Class Interfaces

Uploaded on Feb 23, 2025 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Unix File Interface int open(const char* path, int flags, mode_t permissions); ssize_t read(int fd, void* buffer, size_t count); ssize_t write(int fd, const void* buffer, size_t count); off_t lseek(int fd, off_t offset, int referencePosition); int close(int fd);

  2. Shallow Methods private void addNullValueForAttribute(String attribute) { data.put(attribute, "null"); } /* Updates the persistent data structures to reflect * the given friendship */ private void persist(FriendshipOp f) { recordStore.append(friendFile, f); } CS 190 Lecture Notes: Modular Design Slide 2

  3. Java I/O FileInputStream fileStream = new FileInputStream(fileName); BufferedInputStream bufferedStream = new BufferedInputStream(fileStream); ObjectInputStream objectStream = new ObjectInputStream(bufferedStream); CS 190 Lecture Notes: Modular Design Slide 3

  4. Interface for Text Class Special-purpose: void backspace(Cursor cursor); void delete(Cursor cursor); void deleteSelection(Selection selection); General-purpose: void insert(Position position, String newText); void delete(Position start, Position end); Position changePosition(Position position, int numChars); CS 190 Lecture Notes: Modular Design Slide 4

  5. Pass-Through Methods public class TextDocument ... { private TextArea textArea; private WeakReference<TextDocumentListener> listener; ... public Character getLastTypedCharacter() { return textArea.getLastTypedCharacter(); } public int getCursorOffset() { return textArea.getCursorOffset(); } public void insertString(String textToInsert, int offset) { textArea.insertText(textToInsert, offset); } public void willInsertString(String stringToInsert, int offset) { if (listener != null && listener.get() != null) { listener.get().willInsertString(this, stringToInsert, offset); } } ... } CS 190 Lecture Notes: Modular Design Slide 5

  6. UNIX ioctl int result = ioctl(int fd, int request, void* inBuffer, int inputSize, void* outBuffer, int outputSize); CS 190 Lecture Notes: Modular Design Slide 6

More Related Content