This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DirectoryFile::DirectoryFile(const std::string &name, int permissions) | |
| : File(name, permissions) | |
| { | |
| } | |
| DirectoryFile::~DirectoryFile() | |
| { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| RegularFile::RegularFile(const std::string &name, int permissions) | |
| : File(name, permissions), _content("") | |
| { | |
| } | |
| RegularFile::~RegularFile() | |
| { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DirectoryFile : public File { | |
| public: | |
| DirectoryFile(const std::string &name, int permissions); | |
| ~DirectoryFile(); | |
| int get_file_type() const; | |
| std::string get_name() const; | |
| size_t get_size() const; | |
| int get_permissions() const; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class RegularFile : public File { | |
| public: | |
| RegularFile(const std::string &name, int permissions); | |
| ~RegularFile(); | |
| int get_file_type() const; | |
| std::string get_name() const; | |
| size_t get_size() const; | |
| int get_permissions() const; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum ReadWriteError { Invalid = -1 }; | |
| enum FileType { Regular, Directory }; | |
| class File { | |
| public: | |
| File(const std::string &name, const int permissions); | |
| virtual ~File(); | |
| virtual int get_file_type() const = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void read_cont_blocks(char *filename) | |
| { | |
| struct s1 one; | |
| struct s2 two; | |
| int three; | |
| float four; | |
| int num_read; | |
| FileHandle file_handle(filename, O_RDONLY | O_CREAT, S_IWUSR | S_IRUSR); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class FileHandle { | |
| private: | |
| int fd; | |
| public: | |
| FileHandle(const char *file_name, int flags, mode_t mode); | |
| ~FileHandle(); | |
| int read(void *buffer, size_t count); | |
| int write(void *buffer, size_t count); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void write_cont_blocks(char *filename) | |
| { | |
| struct iovec iov[4]; | |
| struct s1 one; | |
| struct s2 two; | |
| int three; | |
| float four; | |
| int num_written; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void read_cont_blocks(char *filename) | |
| { | |
| struct iovec iov[4]; | |
| struct s1 one; | |
| struct s2 two; | |
| int three; | |
| float four; | |
| int num_read; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void read_cont_blocks(char *filename) | |
| { | |
| struct iovec iov[4]; | |
| struct s1 one; | |
| struct s2 two; | |
| int three; | |
| float four; | |
| int num_read; |