summaryrefslogtreecommitdiffstats
path: root/samba_wizard
diff options
context:
space:
mode:
authorAntoine Ginies <aginies@mandriva.com>2004-07-30 02:56:58 +0000
committerAntoine Ginies <aginies@mandriva.com>2004-07-30 02:56:58 +0000
commit1acd2892cb4fb5c15801fd49a1cf0640b05b7b97 (patch)
treeffa0ef8cfe77101e9bec99345e718b8b939d3e89 /samba_wizard
parent854d45c753346a317c548cf45d64d7f97cd050f3 (diff)
downloaddrakwizard-1acd2892cb4fb5c15801fd49a1cf0640b05b7b97.tar
drakwizard-1acd2892cb4fb5c15801fd49a1cf0640b05b7b97.tar.gz
drakwizard-1acd2892cb4fb5c15801fd49a1cf0640b05b7b97.tar.bz2
drakwizard-1acd2892cb4fb5c15801fd49a1cf0640b05b7b97.tar.xz
drakwizard-1acd2892cb4fb5c15801fd49a1cf0640b05b7b97.zip
add option to create directory (thx Robert Vojta)
Diffstat (limited to 'samba_wizard')
-rwxr-xr-xsamba_wizard/Samba.pm34
1 files changed, 33 insertions, 1 deletions
diff --git a/samba_wizard/Samba.pm b/samba_wizard/Samba.pm
index db8f3fe1..c70c7bef 100755
--- a/samba_wizard/Samba.pm
+++ b/samba_wizard/Samba.pm
@@ -157,9 +157,15 @@ $o->{pages} = {
post => \&check_dir,
data => [
{ label => N("Shared directory:"), val => \$o->{var}{wiz_dir} },
+ { text => N("Create shared directory if it doesn't exists"), type => 'bool', val => \$o->{var}{create_missing_directory} },
],
next => 'ask_access'
},
+ error_in_create_missing_dir => {
+ name => N("Error.") . "\n\n" . N("Failed to create directory."),
+ ignore => 1,
+ next => 'ask_dir'
+ },
error_in_dir => {
name => N("Error.") . "\n\n" . N("The path you entered does not exist."),
ignore => 1,
@@ -261,8 +267,34 @@ sub check_services {
$o->{var}{wiz_do_printer_sharing} and return 'ask_printers';
}
+sub wiz_mkdir_p {
+ my ($dir) = @_;
+ if (-d $dir) {
+ # Do nothing, directory exists
+ } elsif (-e $dir) {
+ # Directory is file, we are not going to delete it
+ return 0;
+ } else {
+ # Create parent directory
+ wiz_mkdir_p(dirname($dir)) or return 0;
+
+ # Create our directory
+ mkdir($dir, 0755) or return 0;
+ }
+ 1;
+}
+
+
sub check_dir {
- -d ($o->{var}{wiz_dir}) or return 'error_in_dir'
+ if (! -d $o->{var}{wiz_dir})
+ {
+ if ($o->{var}{create_missing_directory}) {
+ wiz_mkdir_p($o->{var}{wiz_dir}) or return 'error_in_create_missing_dir';
+ } else {
+ return 'error_in_dir';
+ }
+ }
+ return 0;
}
# the "__" before comment is to avoid conflicts with possible "comment" variable