Exemple #1
0
int	create_file(char *name)
{
  int	fd;
  char *new_name;

  new_name = my_strdup(name);
  new_name = modify_extension(new_name);
  if ((fd = open(new_name, O_CREAT | O_WRONLY | O_TRUNC,
		 S_IRUSR | S_IWUSR)) == -1)
    {
      my_printf("Corewar: Can't open file <");
      my_putstr(name);
      my_putstr(">.\n");
      exit(0);
    }
  if (new_name != NULL)
    free(new_name);
  return (fd);
}
Exemple #2
0
string Cartridge::get_filename(const char *source, const char *extension, const char *path) const {
  return filepath(modify_extension(source, extension), path);
}