rm.c

gurba-0.40/lib/cmds/wiz/rm.c · 618 B

From the archive gurba.tgz

Download the archive   « Back to the archive contents

void main( string arg ) {
  string file;

  if( arg == "" ) {
    write( "Please specify filename to rm." );
    return;
  }

  file = normalize_path( arg, this_player()->query_env("cwd") );
  if( file == "" ) {
    write( arg + ": Permission denied.\n" );
    return;
  }

  if( file_exists( file ) == -1 ) {
    if( remove_dir( file ) == 0 ) {
      write( arg + ": Not empty.\n" );
    } else {
      write( "Deleted.\n" );
    }
  } else if( file_exists( file ) != 0 ) {
    if( remove_file( file ) == 0 ) {
      write( arg + ": Unable to delete.\n" );
    }
  } else {
    write( arg + ": Not found.\n" );
  }
}

Site Stats

Snippets: 1791
Codebases: 571