Config-Model
view release on metacpan or search on metacpan
lib/Config/Model/Backend/PlainFile.pm view on Meta::CPAN
@v = map { "$_\n" } $obj->fetch_all_values;
}
else {
$logger->debug("PlainFile write skipped $type $elt");
next;
}
if (@v) {
$logger->trace("PlainFile write opening $file to write $elt");
$file->spew_utf8(@v);
$file->chmod($args{file_mode}) if $args{file_mode};
}
elsif ($file->exists) {
$logger->trace("PlainFile delete $file");
$file->remove;
}
}
return 1;
}
lib/Config/Model/Backend/PlainFile.pm view on Meta::CPAN
file => '&element(-).&element',
file_mode => 0644, # optional
}
If the configuration is loaded with C<example string_a=something
string_b=else>, this backend writes "C<something>" in file
C<example.string_a> and C<else> in file C<example.string_b>.
C<file_mode> parameter can be used to set the mode of the written
file. C<file_mode> value can be in any form supported by
L<Path::Tiny/chmod>.
=head1 Methods
=head2 read_leaf
Parameters: C<(obj, elt, check, file, args)>
Called by L<read> method to read the file of a leaf element. C<args>
contains the arguments passed to L<read> method.
lib/Config/Model/BackendMgr.pm view on Meta::CPAN
return unless defined $file_path;
if ($error) {
# restore backup and display error
$logger->warn("Error during write, restoring backup data in $file_path" );
$file_path->append_utf8({ truncate => 1 }, $self->file_backup );
$error->rethrow if ref($error) and $error->can('rethrow');
die $error;
}
# TODO: move chmod in a backend role
$file_path->chmod($file_mode) if $file_mode;
# TODO: move in a backend role
# check file size and remove empty files
$file_path->remove if -z $file_path and not -l $file_path;
return;
}
sub is_auto_write_for_type ($self, $type) {
return $self->{auto_write}{$type} || 0;
lib/Config/Model/BackendMgr.pm view on Meta::CPAN
service # hash element
foo # hash index
nodeA # values of nodeA are stored in service.foo.conf
bar # hash index
nodeB # values of nodeB are stored in service.bar.conf
=item file_mode
C<file_mode> parameter can be used to set the mode of the written
file(s). C<file_mode> value can be in any form supported by
L<Path::Tiny/chmod>. Example:
file_mode => 0664,
file_mode => '0664',
file_mode => 'g+w'
=item os_config_dir
Specify alternate location of a configuration directory depending on the OS
(as returned by C<$^O>, see L<perlport/PLATFORMS>).
For instance:
lib/Config/Model/FuseUI.pm view on Meta::CPAN
return 0;
}
sub statfs { return 255, 1, 1, 1, 1, 2 }
my @methods = map { ( $_ => __PACKAGE__ . "::$_" ) }
qw/getattr readdir open read write statfs truncate unlink mkdir rmdir/;
# FIXME: flush release
# maybe also: readlink mknod symlink rename link chmod chown utime
sub run_loop {
my ( $self, %args ) = @_;
my $debug = $args{debug} || 0;
Filesys::Fuse3::main(
mountpoint => $self->mountpoint,
@methods,
debug => $debug || 0,
threaded => 0,
lib/Config/Model/models/Fstab/VfatOpt.pl view on Meta::CPAN
'value_type' => 'enum'
},
'time_offset',
{
'description' => 'Set offset for conversion of timestamps from local time used by FAT to UTC. I.e., minutes will be subtracted from each timestamp to convert it to UTC used internally by Linux. This is useful when the time zone set in the ker...
'type' => 'leaf',
'value_type' => 'integer'
},
'quiet',
{
'description' => 'Turn on the quiet flag. Attempts to chown or chmod files do not return errors, although they fail. Use with caution!',
'type' => 'leaf',
'value_type' => 'boolean'
},
'rodir',
{
'description' => "FAT has the ATTR_RO (read-only) attribute. On Windows, the ATTR_RO of the directory will just be ignored, and is used only by applications as a flag (e.g. it\x{2019}s set for the customized folder).
If you want to use ATTR_RO as read-only flag even for the directory, set this option.",
'type' => 'leaf',
'value_type' => 'boolean'
( run in 0.655 second using v1.01-cache-2.11-cpan-bbcb1afb8fc )