rmd_ir.c

skylib_fluffos_v3/mudlib/cmds/creator/rmd_ir.c · 1019 B

From the archive skylib_fluffos_v3.zip

Download the archive   « Back to the archive contents

/* rmdir command, trial out by Turrican for a commands daemon. */

inherit COMMAND_BASE;

mixed cmd(string str) {
   string *filenames;
   int fsize, loop;
 
   seteuid(geteuid(this_player()));
   if (!str || str == "") {
      notify_fail("Remove what dir?\n");
      return 0;
   }
   filenames = this_player()->get_files(str);
   if (!sizeof(filenames)) {
      notify_fail("No such directory : " + str + "\n");
      return 0;
   }
 
   for(loop = 0; loop < sizeof(filenames); loop++) {
      str = filenames[loop];
      fsize = file_size(str);
      if (fsize == -1) {
         notify_fail(str + " doesn't exist.\n");
         return 0;
      }
      if (fsize != -2) {
         notify_fail(str + " is not a directory.\n");
         return 0;
      }
      if (!rmdir(str)) {
         notify_fail("Couldn't remove dir : " + str + "\n");
         return 0;
      }
   }
   log_file( "RMED", ctime( time() ) + " : " + sprintf( "%-12s",
        TP -> query_name()) + str + "\n" ) ;
   write("Ok.\n");
   return 1;
}

Site Stats

Snippets: 1791
Codebases: 571