Sha256: 2f6bd68d8cca635be48fab776cfddfaa535732375463e817a97f081dd82e88fa

Contents?: true

Size: 886 Bytes

Versions: 16

Compression:

Stored size: 886 Bytes

Contents

/**
 * @file
 * Declares the scoped file resource for managing FILE pointers.
 */
#pragma once

#include <leatherman/util/scoped_resource.hpp>
#include <string>
#include <cstdio>

namespace facter { namespace util {

    /**
     * Represents a scoped file.
     * Automatically closes the file when it goes out of scope.
    */
    struct scoped_file : leatherman::util::scoped_resource<std::FILE*>
    {
        /**
         * Constructs a scoped_file.
         * @param path The path to the file.
         * @param mode The open mode.
         */
        explicit scoped_file(std::string const& path, std::string const& mode);

        /**
         * Constructs a scoped_file.
         * @param file The existing file pointer.
         */
        explicit scoped_file(std::FILE* file);

     private:
        static void close(std::FILE* file);
    };

}}  // namespace facter::util

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
facter-3.12.2.cfacter.20181217 ext/facter/facter/lib/inc/internal/util/scoped_file.hpp
facter-3.12.1.cfacter.20181031 ext/facter/facter/lib/inc/internal/util/scoped_file.hpp
facter-3.11.6.cfacter.20181031 ext/facter/facter/lib/inc/internal/util/scoped_file.hpp
facter-3.12.1.cfacter.20181023 ext/facter/facter/lib/inc/internal/util/scoped_file.hpp
facter-3.11.5.cfacter.20181022 ext/facter/facter/lib/inc/internal/util/scoped_file.hpp
facter-3.12.0.cfacter.20181004 ext/facter/facter/lib/inc/internal/util/scoped_file.hpp
facter-3.12.0.cfacter.20181001 ext/facter/facter/lib/inc/internal/util/scoped_file.hpp
facter-3.12.0.cfacter.20180918 ext/facter/facter/lib/inc/internal/util/scoped_file.hpp
facter-3.11.4.cfacter.20180821 ext/facter/facter/lib/inc/internal/util/scoped_file.hpp
facter-3.11.3.cfacter.20180716 ext/facter/facter/lib/inc/internal/util/scoped_file.hpp
facter-3.11.2.cfacter.20180612 ext/facter/facter/lib/inc/internal/util/scoped_file.hpp
facter-3.9.6.cfacter.20180612 ext/facter/facter/lib/inc/internal/util/scoped_file.hpp
facter-3.11.2.cfacter.20180606 ext/facter/facter/lib/inc/internal/util/scoped_file.hpp
facter-3.9.6.cfacter.20180606 ext/facter/facter/lib/inc/internal/util/scoped_file.hpp
facter-3.11.0.cfacter.20180319 ext/facter/facter/lib/inc/internal/util/scoped_file.hpp
cfacter-3.11.0.rc.20180314 ext/facter/facter/lib/inc/internal/util/scoped_file.hpp