示例#1
0
int main(int argc, char** argv)
{
  try {
    bool found_file = false;

    for ( int n=1; n<argc; ++n ) {
      if ( argv[n][0] == '-' ) {
        help();
        continue;
      }
      
      found_file = true;
      machine_t m;
      m.load_image(fileptr(fopen(argv[n], "rb")));
      m.run();
    }

    if ( !found_file ) {
      machine_t m;
      m.load_image(stdin);
      m.run();
    }

    return 0;
  }
  catch(const std::exception& e) {
    fprintf(stderr, "%s\n", e.what());
    return 1;
  }
}
示例#2
0
文件: datfile.cpp 项目: bmunger/mame
//---------------------------------------------------------
//  parseopen - Open up file for reading
//---------------------------------------------------------
datfile_manager::fileptr datfile_manager::parseopen(const char *filename)
{
	emu_file file(m_options.history_path(), OPEN_FLAG_READ);
	if (file.open(filename) != osd_file::error::NONE)
		return fileptr(nullptr, &std::fclose);

	std::string const fullpath = file.fullpath();
	file.close();
	fileptr result(std::fopen(fullpath.c_str(), "rb"), &std::fclose);

	fgetc(result.get());
	fseek(result.get(), 0, SEEK_SET);
	return result;
}
示例#3
0
int main(int argc, char** argv)
{
  try {
    if ( argc == 1 ) // by default, read standard input
      compile_and_run(stdin);
  
    for ( int n=1; n<argc; ++n )
      if ( argv[n][0]=='-' ) {
        if ( argv[n][1] == '\0' )
          compile_and_run(stdin);
        else
          help();
      } else
        compile_and_run(fileptr(fopen(argv[n], "rt")));

    return 0;
  }
  catch(const std::exception& e) {
    error(e.what());
  }
}
示例#4
0
int main(int argc, char** argv)
{
  try {
    for ( int n=1; n<argc; ++n ) {
      if ( argv[n][0] == '-' ) {
        if ( argv[n][1] != '\0' )
          help();
        continue;
      }

      machine_t m;
      m.load_image(fileptr(fopen(argv[n], "rb")));
      printf("; File %s --- %lu bytes\n", argv[n], m.size());
      disassemble(m);
    }
    return 0;
  }
  catch(const std::exception& e) {
    error(e.what());
  }
}