rmdir.c

final_realms_fluffos_v1/lib/cmds/creator/rmdir.c · 951 B

From the archive final_realms_fluffos_v1.zip

Download the archive   « Back to the archive contents

#include <standard.h>
#include <cmd.h>
inherit CMD_BASE;

void setup(){

position = 1;
}



static int cmd(string str, object me) {
   string *filenames;
   int fsize, loop;

   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;
        }
   }
   write("Ok.\n");
  this_player()->set_trivial_action();
   return 1;
} /* removedir() */


Site Stats

Snippets: 1791
Codebases: 571