ed.NOPE

final_realms_fluffos_v1/lib/cmds/creator/ed.NOPE · 1.7 KB

From the archive final_realms_fluffos_v1.zip

Download the archive   « Back to the archive contents

/* In order for this to be externalized, it has to be cloned 
   rather than loaded.  Why?  the exit command from ed is called on
  this_object().  That would be this command.  so you continue
  to edit eternally.  Makes much more sense to leave it internal. 
*/
#include <standard.h>
#include <cmd.h>
inherit CMD_BASE;

void setup(){

position = 1;
}

static int cmd(string str, object me) {
  string *filenames, spam, bing;
  object *things;
  int egg;


  if (!str) {
    this_player()->set_in_editor("(hidden)");
    ed("frog", "fini_editor");
    return 1;
  }
  /* dodgy idea, but allows 'ed here' or 'ed strawberry' */
  if (sizeof(things = this_player()->wiz_present(str, this_player()))) {
    spam = file_name(things[0]);
    sscanf(spam, "%s#%d", spam, egg);
    if (file_size(spam) < 0)
      filenames = ({ spam+".c" });
    else
      filenames = ({ spam });
  } else
    filenames = this_player()->get_files(str);
  if (!sizeof(filenames)) {
    str = this_player()->get_path(str);
  } else {
    if (sizeof(filenames) > 0) {
      str = filenames[0];
      if (sizeof(filenames) > 1) {
        int loop;

        loop = 0;
        while(loop < sizeof(filenames) && file_size(filenames[loop]) < 0)
          loop++;
        if(loop >= sizeof(filenames)) {
          write("No such file.\n");
          return 0;
        }
        else {
          str = filenames[loop];
        }

       write("Ambiguous, using : " + str + "\n");
      }
    }
  }
  if (file_size(str) == -2) {
    write("directory\n");
    return 1;
  }
  this_player()->set_in_editor(str);
  if (!MASTER->valid_write(str, geteuid(), "frog"))

    write("[read only] ");
  ed(str, "fini_editor");
  return 1;
} /* edit() */


Site Stats

Snippets: 1791
Codebases: 571