I study the voiced topic - I want to figure out how to view / rename / delete folders. At the moment, dug:

  1. fstream - as far as I understood, there is only functionality for reading / changing files, correct, if not right;
  2. direct.h - there are functions, but I suspect that this is a legacy of C - is it appropriate to use it for C-pluses? a little annoying, that attention quotation: "Delete and rename, you can only empty directory";
  3. there is still a sort of boost library, until it penetrates what it is ...

Advise experienced people where to dig further?

  • While there is no C ++ 20, use direct.h and do not bother if you can use the "legacy C". Or, if you want, use the API of a specific operating system at all, but this is still further from the standard and portable C ++ :) - Harry

2 answers 2

Reading / writing files has been supported for a very long time in STL http://en.cppreference.com/w/cpp/io/basic_ifstream . This should not cause any special difficulties, but renaming files, creating directories and renaming directories can be done in one of the following ways:

  1. File system support (file renaming, directory creation) in the STL should be in the C ++ 17 standard ( http://en.cppreference.com/w/cpp/experimental/fs ).
  2. You can also use the boost Filesystem Library ( https://www.boost.org/doc/libs/1_66_0/libs/filesystem/doc/index.htm ). Essentially, fs C ++ 17 is based on it.
  3. Or use the operating system API. For example, for Windows: https://msdn.microsoft.com/en-us/library/windows/desktop/aa363950(v=vs.85).aspx .
  4. You can use a third-party library, for example, Qt also has functions for working with directories and files, for example, QDir: http://doc.qt.io/qt-5/qdir.html

    C ++ to 11 standards did not exactly have built-in functions for working with directories / folders. There are only api target platforms. The fact that they are "similar" - do not worry.

    Now appeared filesystem . It was added in the 17th standard, but you need to look at which compilers support it. (in fact - gcc is only in the trunk - that is, the freshest 7.3 still does not support, clang - even does not support the trunk, 2017 the studio supports. The quality of support still needs to be tested).

    You can also use boost, it has ready-made wrappers - https://www.boost.org/doc/libs/1_66_0/libs/filesystem/doc/index.htm

    And you can not worry, and write your own or use the framework, the same Qt.

    • 2017 studio does not support. Support only experimental and curve, also in clang. Surprisingly, at the moment there is not a single compiler (a library from them) that would fully support the filesystem. - ixSci
    • supports just checked. at least version 15.6.5. Only need to use std::experimental::filesystem . - KoVadim
    • Well, what am I talking about? "Support is only experimental and curve." Those. we can say that there is no support at all, because to work fully with what is is impossible. - ixSci
    • I also wrote that support needs to be tested. - KoVadim