98_deletefile.pm 926 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # $Id: 98_deletefile.pm 10673 2016-01-30 23:50:20Z betateilchen $
  2. package main;
  3. use strict;
  4. use warnings;
  5. sub Deletefile_Initialize($$) {
  6. $cmds{deletefile} = { Fn => "CommandDeletefile",
  7. Hlp=>"[filename],delete file"};
  8. }
  9. sub CommandDeletefile($$)
  10. {
  11. my ($cl, $param) = @_;
  12. return "It is not allowed to delete the configuration file fhem.cfg." if ($param =~ m/fhem.cfg/);
  13. my $file = FW_fileNameToPath($param);
  14. return "File $param not found." unless -f $file;
  15. eval { unlink $file; };
  16. return "Error: $@" if $@;
  17. return "File $file deleted.";
  18. }
  19. 1;
  20. =pod
  21. =item command
  22. =begin html
  23. <a name="deletefile"></a>
  24. <h3>deletefile</h3>
  25. <ul>
  26. <code>deletefile &lt;filename&gt;</code><br/>
  27. <br/>Delete a file in filesystem.<br/>
  28. <br/>
  29. <li>File must be listed in "Edit files"</li>
  30. <li>File fhem.cfg must not be deleted.</li>
  31. <li>Wildcards are not evaluated.</li>
  32. </ul>
  33. =end html
  34. =cut