### Home Classes Methods

### In Files

- lib/chef/provider/file.rb

### Parent

Chef::Provider

### Methods

- #action_create
- #action_create_if_missing
- #action_delete
- #action_touch
- #backup
- #compare_content
- #define_resource_requirements
- #deploy_tempfile
- #diff_current
- #diff_current_from_content
- #is_binary?
- #load_current_resource
- #set_all_access_controls
- #set_content
- #setup_acl
- #update_new_file_state
- #whyrun_supported?

### Included Modules

- Chef::Mixin::EnforceOwnershipAndPermissions
- Chef::Mixin::Checksum
- Chef::Mixin::ShellOut

### Files

- LICENSE

### Class/Module Index

Quicksearch

- Chef
- Chef::ApiClient
- Chef::ApiClient::Registration
- Chef::Application
- Chef::Application::Apply
- Chef::Application::Client
- Chef::Application::Knife
- Chef::Application::Solo
- Chef::Application::Wakeup
- Chef::Application::WindowsService
- Chef::Checksum
- Chef::Checksum::Storage
- Chef::Checksum::Storage::Filesystem
- Chef::ChefFS
- Chef::ChefFS::CommandLine
- Chef::ChefFS::FilePattern
- Chef::ChefFS::FileSystem
- Chef::ChefFS::FileSystem::BaseFSDir
- Chef::ChefFS::FileSystem::BaseFSObject
- Chef::ChefFS::FileSystem::ChefRepositoryFileSystemEntry
- Chef::ChefFS::FileSystem::ChefRepositoryFileSystemRootDir
- Chef::ChefFS::FileSystem::ChefServerRootDir
- Chef::ChefFS::FileSystem::CookbookDir
- Chef::ChefFS::FileSystem::CookbookFile
- Chef::ChefFS::FileSystem::CookbookSubdir
- Chef::ChefFS::FileSystem::CookbooksDir
- Chef::ChefFS::FileSystem::DataBagDir
- Chef::ChefFS::FileSystem::DataBagItem
- Chef::ChefFS::FileSystem::DataBagsDir
- Chef::ChefFS::FileSystem::FileSystemEntry
- Chef::ChefFS::FileSystem::FileSystemError
- Chef::ChefFS::FileSystem::FileSystemRootDir
- Chef::ChefFS::FileSystem::MustDeleteRecursivelyError
- Chef::ChefFS::FileSystem::NodesDir
- Chef::ChefFS::FileSystem::NonexistentFSObject
- Chef::ChefFS::FileSystem::NotFoundError
- Chef::ChefFS::FileSystem::RestListDir
- Chef::ChefFS::FileSystem::RestListEntry
- Chef::ChefFS::Knife
- Chef::ChefFS::PathUtils
- Chef::Client
- Chef::Config
- Chef::Cookbook
- Chef::Cookbook::Chefignore
- Chef::Cookbook::CookbookVersionLoader
- Chef::Cookbook::FileSystemFileVendor
- Chef::Cookbook::FileVendor
- Chef::Cookbook::Metadata
- Chef::Cookbook::MinimalMetadata
- Chef::Cookbook::RemoteFileVendor
- Chef::Cookbook::SyntaxCheck
- Chef::Cookbook::SyntaxCheck::PersistentSet
- Chef::CookbookCacheCleaner
- Chef::CookbookCollection
- Chef::CookbookLoader
- Chef::CookbookSiteStreamingUploader
- Chef::CookbookSiteStreamingUploader::MultipartStream
- Chef::CookbookSiteStreamingUploader::StreamPart
- Chef::CookbookSiteStreamingUploader::StringPart
- Chef::CookbookSynchronizer
- Chef::CookbookUploader
- Chef::CookbookVersion
- Chef::DSL
- Chef::DSL::DataQuery
- Chef::DSL::IncludeAttribute
- Chef::DSL::IncludeRecipe
- Chef::DSL::PlatformIntrospection
- Chef::DSL::PlatformIntrospection::PlatformDependentValue
- Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue
- Chef::DSL::Recipe
- Chef::DSL::RegistryHelper
- Chef::Daemon
- Chef::DataBag
- Chef::DataBagItem
- Chef::Digester
- Chef::EncryptedDataBagItem
- Chef::EncryptedDataBagItem::DecryptionFailure
- Chef::EncryptedDataBagItem::Decryptor
- Chef::EncryptedDataBagItem::Decryptor::Version0Decryptor
- Chef::EncryptedDataBagItem::Decryptor::Version1Decryptor
- Chef::EncryptedDataBagItem::Encryptor
- Chef::EncryptedDataBagItem::UnsupportedCipher
- Chef::EncryptedDataBagItem::UnsupportedEncryptedDataBagItemFormat
- Chef::Environment
- Chef::EventDispatch
- Chef::EventDispatch::Base
- Chef::EventDispatch::Dispatcher
- Chef::Exceptions
- Chef::Exceptions::AmbiguousRunlistSpecification
- Chef::Exceptions::Application
- Chef::Exceptions::AttributeNotFound
- Chef::Exceptions::CannotDetermineNodeName
- Chef::Exceptions::CannotWritePrivateKey
- Chef::Exceptions::CommandTimeout
- Chef::Exceptions::ConfigurationError
- Chef::Exceptions::CookbookFrozen
- Chef::Exceptions::CookbookNotFound
- Chef::Exceptions::CookbookNotFoundInRepo
- Chef::Exceptions::CookbookVersionConflict
- Chef::Exceptions::CookbookVersionNameMismatch
- Chef::Exceptions::CookbookVersionSelection
- Chef::Exceptions::CookbookVersionSelection::InvalidRunListItems
- Chef::Exceptions::CookbookVersionSelection::UnsatisfiableRunListItem
- Chef::Exceptions::Cron
- Chef::Exceptions::DsclCommandFailed
- Chef::Exceptions::EnclosingDirectoryDoesNotExist
- Chef::Exceptions::Env
- Chef::Exceptions::ErlCall
- Chef::Exceptions::Exec
- Chef::Exceptions::FileNotFound
- Chef::Exceptions::Group
- Chef::Exceptions::GroupIDNotFound
- Chef::Exceptions::Ifconfig
- Chef::Exceptions::IllegalChecksumRevert
- Chef::Exceptions::ImmutableAttributeModification
- Chef::Exceptions::InsufficientPermissions
- Chef::Exceptions::InvalidCommandOption
- Chef::Exceptions::InvalidCookbookVersion
- Chef::Exceptions::InvalidDataBagItemID
- Chef::Exceptions::InvalidDataBagName
- Chef::Exceptions::InvalidDataBagPath
- Chef::Exceptions::InvalidEnvironmentRunListSpecification
- Chef::Exceptions::InvalidHomeDirectory
- Chef::Exceptions::InvalidPrivateKey
- Chef::Exceptions::InvalidRemoteFileURI
- Chef::Exceptions::InvalidRemoteGitReference
- Chef::Exceptions::InvalidResourceReference
- Chef::Exceptions::InvalidResourceSpecification
- Chef::Exceptions::InvalidVersionConstraint
- Chef::Exceptions::Link
- Chef::Exceptions::MissingLibrary
- Chef::Exceptions::MissingParentDirectory
- Chef::Exceptions::MissingRole
- Chef::Exceptions::Mount
- Chef::Exceptions::MultipleFailures
- Chef::Exceptions::ObsoleteDependencySyntax
- Chef::Exceptions::Override
- Chef::Exceptions::Package
- Chef::Exceptions::PrivateKeyMissing
- Chef::Exceptions::RecipeNotFound
- Chef::Exceptions::RedirectLimitExceeded
- Chef::Exceptions::RequestedUIDUnavailable
- Chef::Exceptions::ResourceNotFound
- Chef::Exceptions::RoleNotFound
- Chef::Exceptions::Route
- Chef::Exceptions::SearchIndex
- Chef::Exceptions::Service
- Chef::Exceptions::SolrConnectionError
- Chef::Exceptions::StaleAttributeRead
- Chef::Exceptions::UnresolvableGitReference
- Chef::Exceptions::UnsupportedAction
- Chef::Exceptions::User
- Chef::Exceptions::UserIDNotFound
- Chef::Exceptions::ValidationFailed
- Chef::Exceptions::Win32APIError
- Chef::Exceptions::Win32APIFunctionNotImplemented
- Chef::Exceptions::Win32NotWindows
- Chef::Exceptions::Win32RegArchitectureIncorrect
- Chef::Exceptions::Win32RegBadType
- Chef::Exceptions::Win32RegBadValueSize
- Chef::Exceptions::Win32RegDataMissing
- Chef::Exceptions::Win32RegHiveMissing
- Chef::Exceptions::Win32RegKeyMissing
- Chef::Exceptions::Win32RegNoRecursive
- Chef::Exceptions::Win32RegTypeDoesNotExist
- Chef::Exceptions::Win32RegTypesMismatch
- Chef::Exceptions::Win32RegValueExists
- Chef::Exceptions::Win32RegValueMissing
- Chef::Exceptions::WindowsNotAdmin
- Chef::FileAccessControl
- Chef::FileAccessControl::Unix
- Chef::FileAccessControl::Windows
- Chef::FileAccessControl::Windows::Security
- Chef::FileCache
- Chef::Formatters
- Chef::Formatters::APIErrorFormatting
- Chef::Formatters::Base
- Chef::Formatters::Doc
- Chef::Formatters::ErrorDescription
- Chef::Formatters::ErrorInspectors
- Chef::Formatters::ErrorInspectors::CompileErrorInspector
- Chef::Formatters::ErrorInspectors::CookbookResolveErrorInspector
- Chef::Formatters::ErrorInspectors::CookbookSyncErrorInspector
- Chef::Formatters::ErrorInspectors::NodeLoadErrorInspector
- Chef::Formatters::ErrorInspectors::RegistrationErrorInspector
- Chef::Formatters::ErrorInspectors::ResourceFailureInspector
- Chef::Formatters::ErrorInspectors::RunListExpansionErrorInspector
- Chef::Formatters::ErrorMapper
- Chef::Formatters::Minimal
- Chef::Formatters::NullFormatter
- Chef::Formatters::Outputter
- Chef::Formatters::UnknownFormatter
- Chef::Handler
- Chef::Handler::ErrorReport
- Chef::Handler::JsonFile
- Chef::JSONCompat
- Chef::Knife
- Chef::Knife::Bootstrap
- Chef::Knife::ClientBulkDelete
- Chef::Knife::ClientCreate
- Chef::Knife::ClientDelete
- Chef::Knife::ClientEdit
- Chef::Knife::ClientList
- Chef::Knife::ClientReregister
- Chef::Knife::ClientShow
- Chef::Knife::Configure
- Chef::Knife::ConfigureClient
- Chef::Knife::CookbookBulkDelete
- Chef::Knife::CookbookCreate
- Chef::Knife::CookbookDelete
- Chef::Knife::CookbookDownload
- Chef::Knife::CookbookList
- Chef::Knife::CookbookMetadata
- Chef::Knife::CookbookMetadataFromFile
- Chef::Knife::CookbookSCMRepo
- Chef::Knife::CookbookShow
- Chef::Knife::CookbookSiteDownload
- Chef::Knife::CookbookSiteInstall
- Chef::Knife::CookbookSiteList
- Chef::Knife::CookbookSiteSearch
- Chef::Knife::CookbookSiteShare
- Chef::Knife::CookbookSiteShow
- Chef::Knife::CookbookSiteUnshare
- Chef::Knife::CookbookSiteVendor
- Chef::Knife::CookbookTest
- Chef::Knife::CookbookUpload
- Chef::Knife::Core
- Chef::Knife::Core::BootstrapContext
- Chef::Knife::Core::GenericPresenter
- Chef::Knife::Core::NodeFormattingOptions
- Chef::Knife::Core::NodePresenter
- Chef::Knife::Core::ObjectLoader
- Chef::Knife::Core::ObjectLoader::ObjectType
- Chef::Knife::Core::TextFormatter
- Chef::Knife::DataBagCreate
- Chef::Knife::DataBagDelete
- Chef::Knife::DataBagEdit
- Chef::Knife::DataBagFromFile
- Chef::Knife::DataBagList
- Chef::Knife::DataBagShow
- Chef::Knife::Delete
- Chef::Knife::Diff
- Chef::Knife::Download
- Chef::Knife::EnvironmentCreate
- Chef::Knife::EnvironmentDelete
- Chef::Knife::EnvironmentEdit
- Chef::Knife::EnvironmentFromFile
- Chef::Knife::EnvironmentList
- Chef::Knife::EnvironmentShow
- Chef::Knife::Exec
- Chef::Knife::Help
- Chef::Knife::IndexRebuild
- Chef::Knife::List
- Chef::Knife::NodeBulkDelete
- Chef::Knife::NodeCreate
- Chef::Knife::NodeDelete
- Chef::Knife::NodeEdit
- Chef::Knife::NodeEditor
- Chef::Knife::NodeFromFile
- Chef::Knife::NodeList
- Chef::Knife::NodeRunListAdd
- Chef::Knife::NodeRunListRemove
- Chef::Knife::NodeShow
- Chef::Knife::Raw
- Chef::Knife::RecipeList
- Chef::Knife::RoleBulkDelete
- Chef::Knife::RoleCreate
- Chef::Knife::RoleDelete
- Chef::Knife::RoleEdit
- Chef::Knife::RoleFromFile
- Chef::Knife::RoleList
- Chef::Knife::RoleShow
- Chef::Knife::Search
- Chef::Knife::Show
- Chef::Knife::Ssh
- Chef::Knife::Status
- Chef::Knife::SubcommandLoader
- Chef::Knife::TagCreate
- Chef::Knife::TagDelete
- Chef::Knife::TagList
- Chef::Knife::UI
- Chef::Knife::Upload
- Chef::Knife::UserCreate
- Chef::Knife::UserDelete
- Chef::Knife::UserEdit
- Chef::Knife::UserList
- Chef::Knife::UserReregister
- Chef::Knife::UserShow
- Chef::Log
- Chef::Log::Formatter
- Chef::Mixin
- Chef::Mixin::Checksum
- Chef::Mixin::Command
- Chef::Mixin::Command::Unix
- Chef::Mixin::Command::Windows
- Chef::Mixin::ConvertToClassName
- Chef::Mixin::CreatePath
- Chef::Mixin::DeepMerge
- Chef::Mixin::DeepMerge::InvalidParameter
- Chef::Mixin::DeepMerge::InvalidSubtractiveMerge
- Chef::Mixin::DeprecatedLanguageModule
- Chef::Mixin::Deprecation
- Chef::Mixin::Deprecation::DeprecatedInstanceVariable
- Chef::Mixin::Deprecation::DeprecatedObjectProxyBase
- Chef::Mixin::EnforceOwnershipAndPermissions
- Chef::Mixin::FileClass
- Chef::Mixin::FromFile
- Chef::Mixin::GetSourceFromPackage
- Chef::Mixin::ParamsValidate
- Chef::Mixin::PathSanity
- Chef::Mixin::Securable
- Chef::Mixin::Securable::WindowsMacros
- Chef::Mixin::Securable::WindowsSecurableAttributes
- Chef::Mixin::ShellOut
- Chef::Mixin::Template
- Chef::Mixin::Template::ChefContext
- Chef::Mixin::Template::TemplateError
- Chef::Mixin::WhyRun
- Chef::Mixin::WhyRun::ConvergeActions
- Chef::Mixin::WhyRun::ResourceRequirements
- Chef::Mixin::WhyRun::ResourceRequirements::Assertion
- Chef::Mixin::WhyRun::ResourceRequirements::Assertion::AssertionFailure
- Chef::Mixin::XMLEscape
- Chef::Mixin::XMLEscape::FastXS
- Chef::Mixin::XMLEscape::PureRuby
- Chef::Node
- Chef::Node::AttrArray
- Chef::Node::Attribute
- Chef::Node::ImmutableArray
- Chef::Node::ImmutableMash
- Chef::Node::Immutablize
- Chef::Node::VividMash
- Chef::Platform
- Chef::Provider
- Chef::Provider::Breakpoint
- Chef::Provider::CookbookFile
- Chef::Provider::Cron
- Chef::Provider::Cron::Solaris
- Chef::Provider::Deploy
- Chef::Provider::Deploy::Revision
- Chef::Provider::Deploy::Timestamped
- Chef::Provider::Directory
- Chef::Provider::Env
- Chef::Provider::Env::Windows
- Chef::Provider::ErlCall
- Chef::Provider::Execute
- Chef::Provider::File
- Chef::Provider::Git
- Chef::Provider::Group
- Chef::Provider::Group::Aix
- Chef::Provider::Group::Dscl
- Chef::Provider::Group::Gpasswd
- Chef::Provider::Group::Groupadd
- Chef::Provider::Group::Groupmod
- Chef::Provider::Group::Pw
- Chef::Provider::Group::Suse
- Chef::Provider::Group::Usermod
- Chef::Provider::Group::Windows
- Chef::Provider::HttpRequest
- Chef::Provider::Ifconfig
- Chef::Provider::LWRPBase
- Chef::Provider::LWRPBase::InlineResources
- Chef::Provider::LWRPBase::InlineResources::ClassMethods
- Chef::Provider::Link
- Chef::Provider::Log
- Chef::Provider::Log::ChefLog
- Chef::Provider::Mdadm
- Chef::Provider::Mount
- Chef::Provider::Mount::Mount
- Chef::Provider::Mount::Windows
- Chef::Provider::Ohai
- Chef::Provider::Package
- Chef::Provider::Package::Apt
- Chef::Provider::Package::Dpkg
- Chef::Provider::Package::EasyInstall
- Chef::Provider::Package::Freebsd
- Chef::Provider::Package::Ips
- Chef::Provider::Package::Macports
- Chef::Provider::Package::Pacman
- Chef::Provider::Package::Portage
- Chef::Provider::Package::Rpm
- Chef::Provider::Package::Rubygems
- Chef::Provider::Package::Rubygems::AlternateGemEnvironment
- Chef::Provider::Package::Rubygems::CurrentGemEnvironment
- Chef::Provider::Package::Rubygems::GemEnvironment
- Chef::Provider::Package::SmartOS
- Chef::Provider::Package::Solaris
- Chef::Provider::Package::Yum
- Chef::Provider::Package::Yum::RPMDb
- Chef::Provider::Package::Yum::RPMDbPackage
- Chef::Provider::Package::Yum::RPMDependency
- Chef::Provider::Package::Yum::RPMPackage
- Chef::Provider::Package::Yum::RPMProvide
- Chef::Provider::Package::Yum::RPMRequire
- Chef::Provider::Package::Yum::RPMUtils
- Chef::Provider::Package::Yum::RPMVersion
- Chef::Provider::Package::Yum::YumCache
- Chef::Provider::Package::Zypper
- Chef::Provider::RegistryKey
- Chef::Provider::RemoteDirectory
- Chef::Provider::RemoteFile
- Chef::Provider::ResourceUpdate
- Chef::Provider::Route
- Chef::Provider::RubyBlock
- Chef::Provider::Script
- Chef::Provider::Service
- Chef::Provider::Service::Arch
- Chef::Provider::Service::Debian
- Chef::Provider::Service::Freebsd
- Chef::Provider::Service::Gentoo
- Chef::Provider::Service::Init
- Chef::Provider::Service::Insserv
- Chef::Provider::Service::Invokercd
- Chef::Provider::Service::Macosx
- Chef::Provider::Service::Redhat
- Chef::Provider::Service::Simple
- Chef::Provider::Service::Solaris
- Chef::Provider::Service::Systemd
- Chef::Provider::Service::Upstart
- Chef::Provider::Service::Windows
- Chef::Provider::Subversion
- Chef::Provider::Template
- Chef::Provider::TemplateFinder
- Chef::Provider::User
- Chef::Provider::User::Dscl
- Chef::Provider::User::Pw
- Chef::Provider::User::Useradd
- Chef::Provider::User::Windows
- Chef::REST
- Chef::REST::AuthCredentials
- Chef::REST::CookieJar
- Chef::REST::NoopInflater
- Chef::REST::RESTRequest
- Chef::Recipe
- Chef::ReservedNames
- Chef::ReservedNames::Win32
- Chef::ReservedNames::Win32::API
- Chef::ReservedNames::Win32::API::Error
- Chef::ReservedNames::Win32::API::File
- Chef::ReservedNames::Win32::API::File::BY_HANDLE_FILE_INFORMATION
- Chef::ReservedNames::Win32::API::File::FILETIME
- Chef::ReservedNames::Win32::API::File::REPARSE_DATA_BUFFER
- Chef::ReservedNames::Win32::API::File::REPARSE_DATA_BUFFER_GENERIC
- Chef::ReservedNames::Win32::API::File::REPARSE_DATA_BUFFER_MOUNT_POINT
- Chef::ReservedNames::Win32::API::File::REPARSE_DATA_BUFFER_SYMBOLIC_LINK
- Chef::ReservedNames::Win32::API::File::REPARSE_DATA_BUFFER_UNION
- Chef::ReservedNames::Win32::API::File::SECURITY_ATTRIBUTES
- Chef::ReservedNames::Win32::API::File::WIN32_FIND_DATA
- Chef::ReservedNames::Win32::API::Macros
- Chef::ReservedNames::Win32::API::Memory
- Chef::ReservedNames::Win32::API::PSAPI
- Chef::ReservedNames::Win32::API::PSAPI::PROCESS_MEMORY_COUNTERS
- Chef::ReservedNames::Win32::API::Process
- Chef::ReservedNames::Win32::API::Security
- Chef::ReservedNames::Win32::API::Security::ACE_HEADER
- Chef::ReservedNames::Win32::API::Security::ACE_WITH_MASK_AND_SID
- Chef::ReservedNames::Win32::API::Security::ACLStruct
- Chef::ReservedNames::Win32::API::Security::LUID
- Chef::ReservedNames::Win32::API::Security::LUID_AND_ATTRIBUTES
- Chef::ReservedNames::Win32::API::Security::TOKEN_PRIVILEGES
- Chef::ReservedNames::Win32::API::System
- Chef::ReservedNames::Win32::API::System::OSVERSIONINFOEX
- Chef::ReservedNames::Win32::API::Unicode
- Chef::ReservedNames::Win32::Error
- Chef::ReservedNames::Win32::File
- Chef::ReservedNames::Win32::File::Info
- Chef::ReservedNames::Win32::Handle
- Chef::ReservedNames::Win32::Memory
- Chef::ReservedNames::Win32::Process
- Chef::ReservedNames::Win32::Security
- Chef::ReservedNames::Win32::Security::ACE
- Chef::ReservedNames::Win32::Security::ACL
- Chef::ReservedNames::Win32::Security::SID
- Chef::ReservedNames::Win32::Security::SecurableObject
- Chef::ReservedNames::Win32::Security::SecurableObject::SecurityConst
- Chef::ReservedNames::Win32::Security::SecurityDescriptor
- Chef::ReservedNames::Win32::Security::Token
- Chef::ReservedNames::Win32::Unicode
- Chef::ReservedNames::Win32::Version
- Chef::Resource
- Chef::Resource::AptPackage
- Chef::Resource::Bash
- Chef::Resource::Breakpoint
- Chef::Resource::ChefGem
- Chef::Resource::Conditional
- Chef::Resource::CookbookFile
- Chef::Resource::Cron
- Chef::Resource::Csh
- Chef::Resource::Deploy
- Chef::Resource::DeployBranch
- Chef::Resource::DeployRevision
- Chef::Resource::Directory
- Chef::Resource::DpkgPackage
- Chef::Resource::EasyInstallPackage
- Chef::Resource::Env
- Chef::Resource::ErlCall
- Chef::Resource::Execute
- Chef::Resource::File
- Chef::Resource::FreebsdPackage
- Chef::Resource::GemPackage
- Chef::Resource::Git
- Chef::Resource::Group
- Chef::Resource::HttpRequest
- Chef::Resource::Ifconfig
- Chef::Resource::IpsPackage
- Chef::Resource::LWRPBase
- Chef::Resource::Link
- Chef::Resource::Log
- Chef::Resource::MacportsPackage
- Chef::Resource::Mdadm
- Chef::Resource::Mount
- Chef::Resource::Notification
- Chef::Resource::Ohai
- Chef::Resource::Package
- Chef::Resource::PacmanPackage
- Chef::Resource::Perl
- Chef::Resource::PlatformMap
- Chef::Resource::PortagePackage
- Chef::Resource::Python
- Chef::Resource::RegistryKey
- Chef::Resource::RemoteDirectory
- Chef::Resource::RemoteFile
- Chef::Resource::Route
- Chef::Resource::RpmPackage
- Chef::Resource::Ruby
- Chef::Resource::RubyBlock
- Chef::Resource::Scm
- Chef::Resource::Script
- Chef::Resource::Service
- Chef::Resource::SmartOSPackage
- Chef::Resource::SolarisPackage
- Chef::Resource::Subversion
- Chef::Resource::Template
- Chef::Resource::TimestampedDeploy
- Chef::Resource::User
- Chef::Resource::YumPackage
- Chef::ResourceCollection
- Chef::ResourceCollection::StepableIterator
- Chef::ResourceDefinition
- Chef::ResourceDefinitionList
- Chef::ResourceReporter
- Chef::ResourceReporter::ResourceReport
- Chef::Role
- Chef::RunContext
- Chef::RunContext::CookbookCompiler
- Chef::RunList
- Chef::RunList::RunListExpansion
- Chef::RunList::RunListExpansionFromAPI
- Chef::RunList::RunListExpansionFromDisk
- Chef::RunList::RunListItem
- Chef::RunList::VersionedRecipeList
- Chef::RunLock
- Chef::RunStatus
- Chef::Runner
- Chef::Sandbox
- Chef::ScanAccessControl
- Chef::Search
- Chef::Search::Query
- Chef::ShellOut
- Chef::StreamingCookbookUploader
- Chef::StreamingCookbookUploader::MultipartStream
- Chef::StreamingCookbookUploader::StreamPart
- Chef::StreamingCookbookUploader::StringPart
- Chef::User
- Chef::Util
- Chef::Util::FileEdit
- Chef::Util::Windows
- Chef::Util::Windows::NetGroup
- Chef::Util::Windows::NetUse
- Chef::Util::Windows::NetUser
- Chef::Util::Windows::Volume
- Chef::Version
- Chef::VersionConstraint
- Chef::Win32
- Chef::Win32::Registry
- Shell
- Shell::ClientSession
- Shell::DoppelGangerClient
- Shell::DoppelGangerSession
- Shell::Extensions
- Shell::Extensions::FalseClass
- Shell::Extensions::ObjectCoreExtensions
- Shell::Extensions::String
- Shell::Extensions::Symbol
- Shell::Extensions::TrueClass
- Shell::ModelWrapper
- Shell::NamedDataBagWrapper
- Shell::Options
- Shell::ShellREST
- Shell::ShellSession
- Shell::SoloSession
- Shell::StandAloneSession
- Net
- Net::HTTPError
- Net::HTTPFatalError
- Net::HTTPRetriableError
- Net::HTTPServerException
- FFI
- FFI::Pointer
- FileUtils
- FileUtils::Entry_
- ChefNetHTTPExceptionExtensions
- Dir
- FalseClass
- Mash
- Numeric
- Object
- Regexp
- String
- Symbol
- TrueClass

No matching classes.

# Chef::Provider::File

### Public Instance Methods

action_create() click to toggle source

    # File lib/chef/provider/file.rb, line 217
    def action_create
      if !::File.exists?(@new_resource.path)
        description = []
        desc = "create new file #{@new_resource.path}"
        desc << " with content checksum #{short_cksum(new_resource_content_checksum)}" if new_resource.content
        description << desc
        description << diff_current_from_content(@new_resource.content)

        converge_by(description) do
          Chef::Log.info("entered create")
          ::File.open(@new_resource.path, "w+") {|f| f.write @new_resource.content }
          access_controls.set_all
          Chef::Log.info("#{@new_resource} created file #{@new_resource.path}")
          update_new_file_state
        end
      else
        set_content unless @new_resource.content.nil?
        set_all_access_controls
      end
    end

action_create_if_missing() click to toggle source

    # File lib/chef/provider/file.rb, line 248
    def action_create_if_missing
      if ::File.exists?(@new_resource.path)
        Chef::Log.debug("#{@new_resource} exists at #{@new_resource.path} taking no action.")
      else
        action_create
      end
    end

action_delete() click to toggle source

    # File lib/chef/provider/file.rb, line 256
    def action_delete
      if ::File.exists?(@new_resource.path)
        converge_by("delete file #{@new_resource.path}") do
          backup unless ::File.symlink?(@new_resource.path)
          ::File.delete(@new_resource.path)
          Chef::Log.info("#{@new_resource} deleted file at #{@new_resource.path}")
        end
      end
    end

action_touch() click to toggle source

    # File lib/chef/provider/file.rb, line 266
    def action_touch
      action_create
      converge_by("update utime on file #{@new_resource.path}") do
        time = Time.now
        ::File.utime(time, time, @new_resource.path)
        Chef::Log.info("#{@new_resource} updated atime and mtime to #{time}")
      end
    end

backup(file=nil) click to toggle source

    # File lib/chef/provider/file.rb, line 275
    def backup(file=nil)
      file ||= @new_resource.path
      if @new_resource.backup != false && @new_resource.backup > 0 && ::File.exist?(file)
        time = Time.now
        savetime = time.strftime("%Y%m%d%H%M%S")
        backup_filename = "#{@new_resource.path}.chef-#{savetime}"
        backup_filename = backup_filename.sub(/^([A-Za-z]:)/, "") #strip drive letter on Windows
        # if :file_backup_path is nil, we fallback to the old behavior of
        # keeping the backup in the same directory. We also need to to_s it
        # so we don't get a type error around implicit to_str conversions.
        prefix = Chef::Config[:file_backup_path].to_s
        backup_path = ::File.join(prefix, backup_filename)
        FileUtils.mkdir_p(::File.dirname(backup_path)) if Chef::Config[:file_backup_path]
        FileUtils.cp(file, backup_path, :preserve => true)
        Chef::Log.info("#{@new_resource} backed up to #{backup_path}")

        # Clean up after the number of backups
        slice_number = @new_resource.backup
        backup_files = Dir[::File.join(prefix, ".#{@new_resource.path}.chef-*")].sort { |a,b| b <=> a }
        if backup_files.length >= @new_resource.backup
          remainder = backup_files.slice(slice_number..-1)
          remainder.each do |backup_to_delete|
            FileUtils.rm(backup_to_delete)
            Chef::Log.info("#{@new_resource} removed backup at #{backup_to_delete}")
          end
        end
      end
    end

compare_content() click to toggle source

Compare the content of a file. Returns true if they are the same, false if they are not.

    # File lib/chef/provider/file.rb, line 180
    def compare_content
      checksum(@current_resource.path) == new_resource_content_checksum
    end

define_resource_requirements() click to toggle source

    # File lib/chef/provider/file.rb, line 152
    def define_resource_requirements
      # this must be evaluated before whyrun messages are printed
      access_controls.requires_changes?

      requirements.assert(:create, :create_if_missing, :touch) do |a|
        # Make sure the parent dir exists, or else fail.
        # for why run, print a message explaining the potential error.
        parent_directory = ::File.dirname(@new_resource.path)

        a.assertion { ::File.directory?(parent_directory) }
        a.failure_message(Chef::Exceptions::EnclosingDirectoryDoesNotExist, "Parent directory #{parent_directory} does not exist.")
        a.whyrun("Assuming directory #{parent_directory} would have been created")
      end

      # Make sure the file is deletable if it exists. Otherwise, fail.
      requirements.assert(:delete) do |a|
        a.assertion do
          if ::File.exists?(@new_resource.path)
            ::File.writable?(@new_resource.path)
          else
            true
          end
        end
        a.failure_message(Chef::Exceptions::InsufficientPermissions,"File #{@new_resource.path} exists but is not writable so it cannot be deleted")
      end
    end

deploy_tempfile() click to toggle source

    # File lib/chef/provider/file.rb, line 304
    def deploy_tempfile
      Tempfile.open(::File.basename(@new_resource.name)) do |tempfile|
        yield tempfile

        temp_res = Chef::Resource::CookbookFile.new(@new_resource.name)
        temp_res.path(tempfile.path)
        ac = Chef::FileAccessControl.new(temp_res, @new_resource, self)
        ac.set_all!
        FileUtils.mv(tempfile.path, @new_resource.path)
      end
    end

diff_current(temp_path) click to toggle source

    # File lib/chef/provider/file.rb, line 70
    def diff_current(temp_path)
      suppress_resource_reporting = false

      return [ "(diff output suppressed by config)" ] if Chef::Config[:diff_disabled]
      return [ "(no temp file with new content, diff output suppressed)" ] unless ::File.exists?(temp_path)  # should never happen?

      # solaris does not support diff -N, so create tempfile to diff against if we are creating a new file
      target_path = if ::File.exists?(@current_resource.path)
                      @current_resource.path
                    else
                      suppress_resource_reporting = true  # suppress big diffs going to resource reporting service
                      tempfile = Tempfile.new('chef-tempfile')
                      tempfile.path
                    end

      diff_filesize_threshold = Chef::Config[:diff_filesize_threshold]
      diff_output_threshold = Chef::Config[:diff_output_threshold]

      if ::File.size(target_path) > diff_filesize_threshold || ::File.size(temp_path) > diff_filesize_threshold
        return [ "(file sizes exceed #{diff_filesize_threshold} bytes, diff output suppressed)" ]
      end

      # MacOSX(BSD?) diff will *sometimes* happily spit out nasty binary diffs
      return [ "(current file is binary, diff output suppressed)"] if is_binary?(target_path)
      return [ "(new content is binary, diff output suppressed)"] if is_binary?(temp_path)

      begin
        # -u: Unified diff format
        result = shell_out("diff -u #{target_path} #{temp_path}" )
      rescue Exception => e
        # Should *not* receive this, but in some circumstances it seems that
        # an exception can be thrown even using shell_out instead of shell_out!
        return [ "Could not determine diff. Error: #{e.message}" ]
      end

      # diff will set a non-zero return code even when there's
      # valid stdout results, if it encounters something unexpected
      # So as long as we have output, we'll show it.
      if not result.stdout.empty?
        if result.stdout.length > diff_output_threshold
          [ "(long diff of over #{diff_output_threshold} characters, diff output suppressed)" ]
        else
          val = result.stdout.split("\n")
          val.delete("\\ No newline at end of file")
          @new_resource.diff(val.join("\\n")) unless suppress_resource_reporting
          val
        end
      elsif not result.stderr.empty?
        [ "Could not determine diff. Error: #{result.stderr}" ]
      else
        [ "(no diff)" ]
      end
    end

diff_current_from_content(new_content) click to toggle source

    # File lib/chef/provider/file.rb, line 50
    def diff_current_from_content(new_content)
      result = nil
      Tempfile.open("chef-diff") do |file|
        file.write new_content
        file.close
        result = diff_current file.path
      end
      result
    end

is_binary?(path) click to toggle source

    # File lib/chef/provider/file.rb, line 60
    def is_binary?(path)
      ::File.open(path) do |file|

        buff = file.read(Chef::Config[:diff_filesize_threshold])
        buff = "" if buff.nil?
        return buff !~ /^[\r[:print:]]*$/
      end
    end

load_current_resource() click to toggle source

    # File lib/chef/provider/file.rb, line 128
    def load_current_resource
      # Every child should be specifying their own constructor, so this
      # should only be run in the file case.
      @current_resource ||= Chef::Resource::File.new(@new_resource.name)
      @new_resource.path.gsub!(/\\/, "/") # for Windows
      @current_resource.path(@new_resource.path)
      if !::File.directory?(@new_resource.path)
        if ::File.exist?(@new_resource.path)
          if @action != :create_if_missing
            @current_resource.checksum(checksum(@new_resource.path))
          end
        end
      end
      setup_acl

      @current_resource
    end

set_all_access_controls() click to toggle source

    # File lib/chef/provider/file.rb, line 238
    def set_all_access_controls
      if access_controls.requires_changes?
        converge_by(access_controls.describe_changes) do
          access_controls.set_all
          #Update file state with new access values
          update_new_file_state
        end
      end
    end

set_content() click to toggle source

Set the content of the file, assuming it is not set correctly already.

    # File lib/chef/provider/file.rb, line 185
    def set_content
      unless compare_content
        description = []
        description << "update content in file #{@new_resource.path} from #{short_cksum(@current_resource.checksum)} to #{short_cksum(new_resource_content_checksum)}"
        description << diff_current_from_content(@new_resource.content)
        converge_by(description) do
          backup @new_resource.path if ::File.exists?(@new_resource.path)
          ::File.open(@new_resource.path, "w") {|f| f.write @new_resource.content }
          Chef::Log.info("#{@new_resource} contents updated")
        end
      end
    end

setup_acl() click to toggle source

    # File lib/chef/provider/file.rb, line 146
    def setup_acl
      return if Chef::Platform.windows?
      acl_scanner = ScanAccessControl.new(@new_resource, @current_resource)
      acl_scanner.set_all!
    end

update_new_file_state(path=@new_resource.path) click to toggle source

if you are using a tempfile before creating, you must override the default with the tempfile, since the file at @new_resource.path will not be updated on converge

    # File lib/chef/provider/file.rb, line 201
    def update_new_file_state(path=@new_resource.path)
      if !::File.directory?(path)
        @new_resource.checksum(checksum(path))
      end

      if Chef::Platform.windows?
        # TODO: To work around CHEF-3554, add support for Windows
        # equivalent, or implicit resource reporting won't work for
        # Windows.
        return
      end

      acl_scanner = ScanAccessControl.new(@new_resource, @new_resource)
      acl_scanner.set_all!
    end

whyrun_supported?() click to toggle source

    # File lib/chef/provider/file.rb, line 124
    def whyrun_supported?
      true
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.