Giter Club home page Giter Club logo

Comments (5)

GPMueller avatar GPMueller commented on August 25, 2024

Problematically, the code does not complain when a file cannot be written and just continues running. This is likely undesirable behaviour in most cases.

from spirit.

GPMueller avatar GPMueller commented on August 25, 2024

I think it is OK for the code to continue in case of an error, but maybe an input variable to set the level when the code should stop (i.e. warning, error or severe) would be a good idea?

Also, we could add an ifdef part which creates a folder using C++17, if available.

from spirit.

GPMueller avatar GPMueller commented on August 25, 2024

https://github.com/gulrak/filesystem could be used. It is absolutely sufficient for the use-cases of spirit and fortunately, it also works with emscripten 👍

If gulrak/filesystem should only be used when std::filesystem is not available, one can use the following code (though I would recommend against it because std::filesystem still requires some compiler flags depending on compiler versions, even in C++17 mode)

#if defined( __cplusplus ) && __cplusplus >= 201703L && defined( __has_include )
    #if __has_include( <filesystem>)
        #define GHC_USE_STD_FS
        #include <filesystem>
        namespace fs = std::filesystem;
    #endif
#endif
#ifndef GHC_USE_STD_FS
    #include <ghc/filesystem.hpp>
    namespace fs = ghc::filesystem;
#endif

from spirit.

GPMueller avatar GPMueller commented on August 25, 2024

https://github.com/gulrak/filesystem is already being used by the IMGUI on the feature-imgui branch. When the corresponding PR #583 is merged, it could be used by both ui-cpp and core (as is already done with fmt.

from spirit.

GPMueller avatar GPMueller commented on August 25, 2024

Improved file reading and writing with commits d1fe9f8 and 18bf5d4, respectively. There's now both a FilterFileHandle and OutFileHandle, for which it would make sense to use fs::exists, fs::is_directory/fs::is_regular_file, fs::create_directories.

One could even use fs::is_empty to detect when a file is being _over_written instead of just written.
Note that fs::current_path gives the current working directory and that fs::weakly_canonical can be used for paths that might not exist (it resolves the absolute path as far as possible and keeps the non-existent parts as well).

from spirit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.