Projects for CSE687 - Object Oriented Design and CSE775 - Distributed Objects often require us to find, using C++ code, files on specific directory paths that match a specified pattern. So not having file and directory management libraries means we get to write a lot of low-level code using platform specific APIs or interoperate with code developed in languages that do provide that library support, like C#. While that is not that difficult to do, it would be very convenient to have native C++ libraries that provide such support.
For the second major project each student selects from a list of suggestions. Most of these projects explore some interesting platfrom that will require student research to learn a new, for them, technology. They then propose development of an application, they will develop, that illustrates how the technology works and will be technically interesting for the rest of the class. Many of these projects are expected to create applications that run on both Windows and Linux or that have components that interoperate across these platforms.
Building common Graphical User Interfaces (GUI)s provide an interesting challenge which we will discuss in a future Blog page.
The FileSystem library contains four main classes: Directory, Path, FileInfo, and File, with another public helper class Block and private helper class FileSystemSearch. The main classes are modeled after similar classes in the .Net System.IO namespace.
Directory is composed of static member functions for manipulating directories and files. For example, Directory::getFiles(...) returns a std::vector<string> containing the names of files on a specified path that match a specified pattern.
Path supports parsing fully qualified file specifications into path, file name, and extension and composing those parts into a file specification. Its function getFullFileSpec(...) supports converting a relative path into an absolute path.
The FileInfo class provides facilities for retrieving directory properties about a directory entry, like date of last modification, size, and whether it is a file or directory. The class also supports comparing properties of two specified files.
The File class supports opening, reading lines or blocks of bytes, writing lines or blocks of bytes, and testing FileStream state.
Finally, the Block class wraps an array of bytes for read and write operations on instances of the File class. Blocks are most useful for file transfers with chunking - breaking a file into pieces for transmission over a socket-based channel.
This code bears a copyright © that grants all rights to users except the right to publish and requires retention of the copyright notice.