Executing FS operations with C++
With C++17 FS operations that are closer to the system programming are facilitated. The FS library allows the C++ developer to distinguish between the Linux fs types and perform certain operations with them. Let’s take a look at an exemplary interface:
bool is_directory(const std::filesystem::path& p)
This method checks whether a given pathname is a directory. In a similar fashion, we can do the other type checks – is_fifo()
, is_regular_file()
, is_socket()
, and is_symlink()
. Can you tell why we don’t have the is_hardlink()
method? That’s right – if two files with different character names point to a single inode, then both of them provide access to the same content. It doesn’t matter whether the inode’s hard link counter is higher than one, although we could get it through the hard_link_count()
method.
As the C++ language is compilable on multiple OSes, the FS functions are also dependent...