コード例 #1
0
ファイル: settings.c プロジェクト: Nebuleon/ReGBA
bool ReGBA_SaveSettings(char *cfg_name, bool PerGame)
{
	char fname[MAX_PATH + 1];
	if (strlen(main_path) + strlen(cfg_name) + 5 /* / .cfg */ > MAX_PATH)
	{
		ReGBA_Trace("E: Somehow you hit the filename size limit :o\n");
		return false;
	}
	sprintf(fname, "%s/%s.cfg", main_path, cfg_name);
	FILE_TAG_TYPE fd;

	ReGBA_ProgressInitialise(PerGame ? FILE_ACTION_SAVE_GAME_SETTINGS : FILE_ACTION_SAVE_GLOBAL_SETTINGS);

	FILE_OPEN(fd, fname, WRITE);
	if(FILE_CHECK_VALID(fd)) {
		Menu_SaveIterateRecurse(fd, PerGame ? MainMenu.AlternateVersion : &MainMenu);
		ReGBA_ProgressUpdate(1, 1);
		ReGBA_ProgressFinalise();
	}
	else
	{
		ReGBA_Trace("E: Couldn't open file %s for writing.\n", fname);
		ReGBA_ProgressFinalise();
		return false;
	}

	FILE_CLOSE(fd);
	return true;
}
コード例 #2
0
ファイル: gui.c プロジェクト: Gaku1503/ReGBA
s32 save_config_file()
{
  u8 config_path[512];
    sprintf(config_path, "%s/%s", main_path, GPSP_CONFIG_FILENAME);

  FILE_OPEN(config_file, config_path, write);

  save_game_config_file();

  if(FILE_CHECK_VALID(config_file))
  {
    u32 file_options[23];
    u32 i;

    file_options[0] = screen_scale;
    file_options[1] = screen_filter;
    file_options[2] = global_enable_audio;
    file_options[3] = audio_buffer_size_number;
    file_options[5] = global_enable_analog;
    file_options[6] = analog_sensitivity_level;

    for(i = 0; i < 16; i++)
    {
      file_options[7 + i] = gamepad_config_map[i];
    }

    FILE_WRITE_ARRAY(config_file, file_options);
    FILE_CLOSE(config_file);

    return 0;
  }

  return -1;
}
コード例 #3
0
ファイル: file_utils.c プロジェクト: InstaMsg/instamsg-c
void sg_readFile(const char *filePath, char *buffer, int maxBufferLength)
{
    FILE_STRUCT *fp = NULL;
    int i = 0;
    int ch;

    fp = FILE_OPEN(filePath, "r");
    if(fp != NULL)
    {
        memset(buffer, 0, maxBufferLength);
        while(1)
        {
            ch = FILE_GETC(fp);
            if(ch != FILE_END_ID)
            {
                buffer[i++] = (char)ch;
            }
            else
            {
                break;
            }
        }

        FILE_CLOSE(fp);
    }
    else
    {
        sg_sprintf(LOG_GLOBAL_BUFFER, "Could not open file [%s] in read-mode", filePath);
        error_log(LOG_GLOBAL_BUFFER);

        return;
    }
}
コード例 #4
0
ファイル: gui.c プロジェクト: Gaku1503/ReGBA
s32 save_game_config_file()
{
  u8 game_config_filename[512];
  u32 i;

  change_ext(gamepak_filename, game_config_filename, ".cfg");

  FILE_OPEN(game_config_file, game_config_filename, write);

  if(FILE_CHECK_VALID(game_config_file))
  {
    u32 file_options[14];

    file_options[0] = current_frameskip_type;
    file_options[1] = frameskip_value;
    file_options[2] = random_skip;
    file_options[3] = clock_speed;

    for(i = 0; i < 10; i++)
    {
      file_options[4 + i] = cheats[i].cheat_active;
    }

    FILE_WRITE_ARRAY(game_config_file, file_options);
    FILE_CLOSE(game_config_file);

    return 0;
  }

  return -1;
}
コード例 #5
0
ファイル: file_utils.c プロジェクト: InstaMsg/instamsg-c
int write_singular_line_into_file(const char *filePath, const char *buffer)
{
    int rc = FAILURE;

    FILE_STRUCT *fp = NULL;
    unsigned int i;

    fp = FILE_OPEN(filePath, "w");
    if(fp != NULL)
    {
        for(i = 0; i < strlen(buffer); i++)
        {
            FILE_PUTC(buffer[i], fp);
        }

        FILE_CLOSE(fp);

        rc = SUCCESS;
    }
    else
    {
        sg_sprintf(LOG_GLOBAL_BUFFER, "Could not open file %s in write-mode", filePath);
        error_log(LOG_GLOBAL_BUFFER);
    }

    return rc;
}
コード例 #6
0
ファイル: gui.c プロジェクト: Gaku1503/ReGBA
s32 load_config_file()
{
  u8 config_path[512];
    sprintf(config_path, "%s/%s", main_path, GPSP_CONFIG_FILENAME);

  FILE_OPEN(config_file, config_path, read);

  if(FILE_CHECK_VALID(config_file))
  {
    u32 file_size = FILE_LENGTH(config_file);

    // Sanity check: File size must be the right size
    if(file_size == 92)
    {
      u32 file_options[file_size / 4];
      u32 i;
      s32 menu_button = -1;
      file_read_array(config_file, file_options);

      screen_scale = file_options[0] % 2;
      screen_filter = file_options[1] % 2;
      global_enable_audio = file_options[2] % 2;
#ifdef ZAURUS
      audio_buffer_size_number = file_options[3] % 4;
#else
      audio_buffer_size_number = file_options[3] % 11;
#endif
      global_enable_analog = file_options[5] % 2;
      analog_sensitivity_level = file_options[6] % 8;

      // Sanity check: Make sure there's a MENU or FRAMESKIP
      // key, if not assign to triangle

      for(i = 0; i < 16; i++)
      {
        gamepad_config_map[i] = file_options[7 + i] %
         (BUTTON_ID_NONE + 1);

        if(gamepad_config_map[i] == BUTTON_ID_MENU)
        {
          menu_button = i;
        }
      }

      if(menu_button == -1)
      {
        gamepad_config_map[0] = BUTTON_ID_MENU;
      }
    }

    FILE_CLOSE(config_file);

    return 0;
  }

  return -1;
}
コード例 #7
0
ファイル: gui.c プロジェクト: Gaku1503/ReGBA
s32 load_game_config_file()
{
  u8 game_config_filename[512];
  u32 file_loaded = 0;
  u32 i;
  change_ext(gamepak_filename, game_config_filename, ".cfg");

  FILE_OPEN(game_config_file, game_config_filename, read);

  if(file_check_valid(game_config_file))
  {
    u32 file_size = FILE_LENGTH(game_config_file);

    // Sanity check: File size must be the right size
    if(file_size == 56)
    {
      u32 file_options[file_size / 4];

      FILE_READ_ARRAY(game_config_file, file_options);
      current_frameskip_type = file_options[0] % 3;
      frameskip_value = file_options[1];
      random_skip = file_options[2] & 1;
      clock_speed = global_cycles_per_instruction = file_options[3];

      if(frameskip_value < 0)
        frameskip_value = 0;

      if(frameskip_value > 99)
        frameskip_value = 99;


      file_loaded = 1;
    }
    FILE_CLOSE(game_config_file);
  }

  if(file_loaded)
    return 0;

  current_frameskip_type = auto_frameskip;
  frameskip_value = 4;
  random_skip = 0;
  clock_speed = 4;

  for(i = 0; i < 10; i++)
  {
    cheats[i].cheat_active = 0;
  }

  return -1;
}
コード例 #8
0
ファイル: file_utils.c プロジェクト: InstaMsg/instamsg-c
void read_singular_line_from_file(const char *filePath, const char *content, char *buffer, int maxbufferlength)
{
    FILE_STRUCT *fp = FILE_OPEN(filePath, "r");
    if(fp != NULL)
    {
        sg_readLine(fp, buffer, maxbufferlength);
        FILE_CLOSE(fp);
    }
    else
    {
        sg_sprintf(LOG_GLOBAL_BUFFER, PROSTR("File [%s] does not exist, so %s cannot be read"), filePath, content);
        error_log(LOG_GLOBAL_BUFFER);
    }
}
コード例 #9
0
ファイル: gui.c プロジェクト: Gaku1503/ReGBA
void get_savestate_snapshot(u8 *savestate_filename)
{
	/* Unimplemented. Need to figure out a way to show this screenshot on a
	 * 320x240 screen first. - Neb, 2013-08-19 */
#if 0
  u16 snapshot_buffer[240 * 160];
  u8 savestate_timestamp_string[80];

  FILE_OPEN(savestate_file, savestate_filename, read);

  if(FILE_CHECK_VALID(savestate_file))
  {
    u8 weekday_strings[7][11] =
    {
      "Sunday", "Monday", "Tuesday", "Wednesday",
      "Thursday", "Friday", "Saturday"
    };
    time_t savestate_time_flat;
    struct tm *current_time;
    file_read_array(savestate_file, snapshot_buffer);
    file_read_variable(savestate_file, savestate_time_flat);

    file_close(savestate_file);

    current_time = localtime(&savestate_time_flat);
    sprintf(savestate_timestamp_string,
     "%s  %02d/%02d/%04d  %02d:%02d:%02d                ",
     weekday_strings[current_time->tm_wday], current_time->tm_mon + 1,
     current_time->tm_mday, current_time->tm_year + 1900,
     current_time->tm_hour, current_time->tm_min, current_time->tm_sec);

    savestate_timestamp_string[40] = 0;
    print_string(savestate_timestamp_string, COLOR_HELP_TEXT, COLOR_BG,
     10, 40);
  }
  else
  {
    memset(snapshot_buffer, 0, 240 * 160 * 2);
    print_string_ext("No savestate exists for this slot.",
     0xFFFF, 0x0000, 15, 75, snapshot_buffer, 240, 0);
    print_string("---------- --/--/---- --:--:--          ", COLOR_HELP_TEXT,
     COLOR_BG, 10, 40);
  }
#endif
}
コード例 #10
0
ファイル: file_utils.c プロジェクト: InstaMsg/instamsg-c
int sg_createEmptyFile(const char *filePath)
{
    int rc = FAILURE;

    FILE_STRUCT *fp = NULL;
    fp = FILE_OPEN(filePath, "w");
    if(fp != NULL)
    {
        FILE_CLOSE(fp);

        rc = SUCCESS;
    }
    else
    {
        sg_sprintf(LOG_GLOBAL_BUFFER, "Could not open file %s in write-mode", filePath);
        error_log(LOG_GLOBAL_BUFFER);
    }

    return rc;
}
コード例 #11
0
ファイル: file_utils.c プロジェクト: InstaMsg/instamsg-c
void sg_writeFile(const char *filePath, char *buffer)
{
    FILE_STRUCT *fp = NULL;
    unsigned int i = 0;

    fp = FILE_OPEN(filePath, "w");
    if(fp != NULL)
    {
        for(i = 0; i < strlen(buffer); i++)
        {
            FILE_PUTC(buffer[i], fp);
        }

        FILE_CLOSE(fp);
    }
    else
    {
        sg_sprintf(LOG_GLOBAL_BUFFER, "Could not open file [%s] in write-mode", filePath);
        error_log(LOG_GLOBAL_BUFFER);

        return;
    }
}
コード例 #12
0
ファイル: zip.c プロジェクト: idaohang/gpsp-kai
// ZIPで圧縮されたRONのロード
// 返り値:-2=一時ファイルを作成/-1=エラー/その他=ROMのサイズ
// もし、ROMのサイズ>ROMバッファのサイズ の場合は一時ファイルを作成
s32 load_file_zip(char *filename)
{
  struct SZIPFileHeader data;
  char tmp[MAX_PATH];
  s32 retval = -1;
  u8 *buffer = NULL;
  u8 *cbuffer;
  char *ext;
  FILE_ID fd;
  FILE_ID tmp_fd;
  u32 zip_buffer_size;
  u32 write_tmp_flag = NO;
  u32 use_vram;

  use_vram = NO;

  zip_buffer_size = 16 * 1024 * 1024;
  cbuffer = malloc(zip_buffer_size);

  while(cbuffer == NULL)
  {
    zip_buffer_size -= (256 * 1024);
    if(zip_buffer_size == 0) break;
    cbuffer = malloc(zip_buffer_size);
  }

  if(zip_buffer_size == 0)
  {
    use_vram = YES;
    zip_buffer_size = ZIP_BUFFER_SIZE;
    cbuffer = (u8 *)UNIVERSAL_VRAM_ADDR; // 汎用フレームバッファを使用
  }

  chdir(rom_path);
  FILE_OPEN(fd, filename, READ);

  if(!FILE_CHECK_VALID(fd))
    return -1;

  {
    FILE_READ(fd, &data, sizeof(struct SZIPFileHeader));

    // EDIT: Check if this is a zip file without worrying about endian
    // It checks for the following: 0x50 0x4B 0x03 0x04 (PK..)
    // Used to be: if(data.Sig != 0x04034b50) break;
	if( data.Sig[0] != 0x50 || data.Sig[1] != 0x4B ||
		data.Sig[2] != 0x03 || data.Sig[3] != 0x04 )
	{
		goto outcode;
	}

    FILE_READ(fd, tmp, data.FilenameLength);
    tmp[data.FilenameLength] = 0; // end string

    if(data.ExtraFieldLength)
      FILE_SEEK(fd, data.ExtraFieldLength, SEEK_CUR);

    if(data.GeneralBitFlag & 0x0008)
    {
      FILE_READ(fd, &data.DataDescriptor,
       sizeof(struct SZIPFileDataDescriptor));
    }

    ext = strrchr(tmp, '.') + 1;

    // file is too big
    if(data.DataDescriptor.UncompressedSize > gamepak_ram_buffer_size)
      {
        write_tmp_flag = YES; // テンポラリを使用するフラグをONに
        FILE_OPEN(tmp_fd, ZIP_TMP, WRITE);
      }
    else
      write_tmp_flag = NO;

    if(!strncasecmp(ext, "bin", 3) || !strncasecmp(ext, "gba", 3))
    {
      buffer = gamepak_rom;

      // ok, found
      switch(data.CompressionMethod)
      {
        case 0: //無圧縮
          retval = data.DataDescriptor.UncompressedSize;
          FILE_READ(fd, buffer, retval);

          goto outcode;

        case 8: //圧縮
        {
          z_stream stream = {0};
          s32 err;

          /*
           *   z.next_in = 入力ポインタ;
           *   z.avail_in = 入力データの残量;
           *   z.next_out = 出力ポインタ;
           *   z.avail_out = 出力バッファの残量;
           */

          stream.next_in = (Bytef*)cbuffer;
          stream.avail_in = (u32)zip_buffer_size;

          stream.next_out = (Bytef*)buffer;

          if(write_tmp_flag == NO)
            {
              stream.avail_out = data.DataDescriptor.UncompressedSize;
              retval = (u32)data.DataDescriptor.UncompressedSize;
            }
          else
            {
              stream.avail_out = gamepak_ram_buffer_size;
              retval = -2;
            }

          stream.zalloc = (alloc_func)0;
          stream.zfree = (free_func)0;
          stream.opaque = (voidpf)0;

          err = inflateInit2(&stream, -MAX_WBITS);

          FILE_READ(fd, cbuffer, zip_buffer_size);
          sceKernelDcacheWritebackAll();

          if(err == Z_OK)
          {
            while(err != Z_STREAM_END)
            {
              err = inflate(&stream, Z_SYNC_FLUSH);
              if(err == Z_BUF_ERROR)
              {
                stream.avail_in = (u32)zip_buffer_size;
                stream.next_in = (Bytef*)cbuffer;
                FILE_READ(fd, cbuffer, zip_buffer_size);
                sceKernelDcacheWritebackAll();
              }

              if((write_tmp_flag == YES) && (stream.avail_out == 0)) /* 出力バッファが尽きれば */
                {
                  FILE_WRITE(tmp_fd, buffer, gamepak_ram_buffer_size);
                  stream.next_out = buffer; /* 出力ポインタを元に戻す */
                  stream.avail_out = gamepak_ram_buffer_size; /* 出力バッファ残量を元に戻す */
                }
            }

            if((write_tmp_flag == YES) && ((gamepak_ram_buffer_size - stream.avail_out) != 0))
                FILE_WRITE(tmp_fd, buffer, gamepak_ram_buffer_size - stream.avail_out);

            err = Z_OK;
            inflateEnd(&stream);
          }
          goto outcode;
        }
      }
    }
  }

outcode:
  FILE_CLOSE(fd);

  if(write_tmp_flag == YES)
    FILE_CLOSE(tmp_fd);

  if(use_vram == NO)
    free(cbuffer);

  chdir(main_path);
  return retval;
}
コード例 #13
0
ファイル: settings.c プロジェクト: Nebuleon/ReGBA
void ReGBA_LoadSettings(char *cfg_name, bool PerGame)
{
	char fname[MAX_PATH + 1];
	if (strlen(main_path) + strlen(cfg_name) + 5 /* / .cfg */ > MAX_PATH)
	{
		ReGBA_Trace("E: Somehow you hit the filename size limit :o\n");
		return;
	}
	sprintf(fname, "%s/%s.cfg", main_path, cfg_name);

	FILE_TAG_TYPE fd;

	ReGBA_ProgressInitialise(PerGame ? FILE_ACTION_LOAD_GAME_SETTINGS : FILE_ACTION_LOAD_GLOBAL_SETTINGS);

	FILE_OPEN(fd, fname, READ);

	if(FILE_CHECK_VALID(fd)) {
		char line[257];

		while(fgets(line, 256, fd))
		{
			line[256] = '\0';

			char* opt = NULL;
			char* arg = NULL;

			char* cur = line;

			// Find the start of the option name.
			while (*cur == ' ' || *cur == '\t')
				cur++;
			// Now find where it ends.
			while (*cur && !(*cur == ' ' || *cur == '\t' || *cur == '='))
			{
				if (*cur == '#')
					continue;
				else if (opt == NULL)
					opt = cur;
				cur++;
			}
			if (opt == NULL)
				continue;
			bool WasEquals = *cur == '=';
			*cur++ = '\0';
			if (!WasEquals)
			{
				// Skip all whitespace before =.
				while (*cur == ' ' || *cur == '\t')
					cur++;
				if (*cur != '=')
					continue;
				cur++;
			}
			// Find the start of the option argument.
			while (*cur == ' ' || *cur == '\t')
				cur++;
			// Now find where it ends.
			while (*cur)
			{
				if (*cur == '#')
				{
					*cur = '\0';
					break;
				}
				else if (arg == NULL)
					arg = cur;
				cur++;
			}
			if (arg == NULL)
				continue;
			cur--;
			while (*cur == ' ' || *cur == '\t' || *cur == '\n' || *cur == '\r')
			{
				*cur = '\0';
				cur--;
			}

			struct MenuEntry* entry = Menu_FindByPersistentName(PerGame ? MainMenu.AlternateVersion : &MainMenu, opt);
			if (entry == NULL)
			{
				ReGBA_Trace("W: Option '%s' not found; ignored", opt);
			}
			else
			{
				MenuPersistenceFunction LoadFunction = entry->LoadFunction;
				if (LoadFunction == NULL) LoadFunction = &DefaultLoadFunction;
				(*LoadFunction)(entry, arg);
			}
		}
		ReGBA_ProgressUpdate(1, 1);
	}
	else
	{
		ReGBA_Trace("W: Couldn't open file %s for loading.\n", fname);
	}
	FixUpSettings();
	ReGBA_ProgressFinalise();
}
コード例 #14
0
ファイル: TopoBrite.cpp プロジェクト: alexbikfalvi/SimNet
	void TopoBrite::Read(const char* fileName)
	{
		// Open file
		FILE* file = NULL;
		if(FILE_OPEN(file, fileName, "r")) throw ExceptionIo(__FILE__, __LINE__, "TopoBrite::Read : cannot open file %s.", fileName);

		// Read header
	#ifdef _MSC_VER
		if(fscanf_s(file, "Topology: ( %u Nodes, %u Edges )\n", &this->numNodes, &this->numEdges) != 2)
			throw ExceptionIo(__FILE__, __LINE__, "TopoBrite::Read : cannot read topology line.");
		if(fscanf_s(file, "Model (%u - %s  ",
			&this->model,
			this->modelName,
			32) != 2)
			throw ExceptionIo(__FILE__, __LINE__, "TopoBrite::Read : cannot read model line.");
	#else
		if(fscanf(file, "Topology: ( %u Nodes, %u Edges )\n", &this->numNodes, &this->numEdges) != 2)
			throw ExceptionIo(__FILE__, __LINE__, "TopoBrite::Read : cannot read model line.");
		if(fscanf(file, "Model (%u - %s  ",
			&this->model,
			this->modelName) != 2)
			throw ExceptionIo(__FILE__, __LINE__, "TopoBrite::Read : cannot read model line.");
	#endif

		uint numNodes;

		double bwMin;
		double bwMax;

		switch(model)
		{
		case TOPO_BRITE_MODEL_WAXMAN:
	#ifdef _MSC_VER
			if(fscanf_s(file, "%u %u %u %u %u %lf %lf %u %u %lf %lf \n\n",
				&numNodes,
				&this->hs,
				&this->ls,
				&this->nodePlacement,
				&this->nodeLinks,
				&this->alpha,
				&this->beta,
				&this->growthType,
				&this->bwDist,
				&bwMin,
				&bwMax) != 11) throw ExceptionIo(__FILE__, __LINE__, "TopoBrite::Read : cannot read topology line.");
	#else
			if(fscanf(file, "%u %u %u %u %u %lf %lf %u %u %lf %lf \n\n",
				&numNodes,
				&this->hs,
				&this->ls,
				&this->nodePlacement,
				&this->nodeLinks,
				&this->alpha,
				&this->beta,
				&this->growthType,
				&this->bwDist,
				&bwMin,
				&bwMax) != 11) throw ExceptionIo(__FILE__, __LINE__, "TopoBrite::Read : cannot read topology line.");
	#endif
			break;
		default: throw ExceptionUnsupported(__FILE__, __LINE__, "TopoBrite::Read : model %u not supported.", model);
		}
		assert(this->numNodes == numNodes);

		this->bwMax = (__bitrate)ceil(bwMax);
		this->bwMin = (__bitrate)ceil(bwMin);

		// Read nodes
	#ifdef _MSC_VER
		if(fscanf_s(file, "Nodes: ( %u )\n", &numNodes) != 1) throw ExceptionIo(__FILE__, __LINE__, "TopoBrite::Read : cannot read nodes line.");
	#else
		if(fscanf(file, "Nodes: ( %u )\n", &numNodes) != 1) throw ExceptionIo(__FILE__, __LINE__, "TopoBrite::Read : cannot read nodes line.");
	#endif
		assert(this->numNodes == numNodes);

		this->nodes = alloc TopoBriteNode*[this->numNodes];
		assert(this->nodes);

		uint id;
		uint xpos;
		uint ypos;
		uint inDegree;
		uint outDegree;
		int as;
		char type[16];

		for(uint index = 0; index < this->numNodes; index++)
		{
	#ifdef _MSC_VER
			if(fscanf_s(file, "%u %u %u %u %u %d %s\n", &id, &xpos, &ypos, &inDegree, &outDegree, &as, type, 16) != 7) throw ExceptionIo(__FILE__, __LINE__, "TopoBrite::Read : cannot read node line.");
	#else
			if(fscanf(file, "%u %u %u %u %u %d %s\n", &id, &xpos, &ypos, &inDegree, &outDegree, &as, type) != 7) throw ExceptionIo(__FILE__, __LINE__, "TopoBrite::Read : cannot read node line.");
	#endif
			assert(id == index);
			assert(inDegree == outDegree);

			this->nodes[index] = alloc TopoBriteNode(
				index,
				xpos,
				ypos,
				inDegree
				);
			assert(this->nodes[index]);
		}

		// Read edges
		uint numEdges;
	#ifdef _MSC_VER
		if(fscanf_s(file, "\n\nEdges: ( %u )\n", &numEdges) != 1) throw ExceptionIo(__FILE__, __LINE__, "TopoBrite::Read : cannot read edges line.");
	#else
		if(fscanf(file, "\n\nEdges: ( %u )\n", &numEdges) != 1) throw ExceptionIo(__FILE__, __LINE__, "TopoBrite::Read : cannot read edges line.");
	#endif
		assert(this->numEdges == numEdges);

		this->edges = alloc TopoBriteEdge*[this->numEdges];
		assert(this->edges);

		uint from;
		uint to;
		double length;
		double delay;
		double bw;
		int asFrom;
		int asTo;
		char val;

		for(uint index = 0; index < this->numEdges; index++)
		{
	#ifdef _MSC_VER
			if(fscanf_s(file, "%u %u %u %lf %lf %lf %d %d %s %c\n", &id, &from, &to, &length, &delay, &bw, &asFrom, &asTo, type, 16, &val) != 10)
				throw ExceptionIo(__FILE__, __LINE__, "TopoBrite::Read : cannot read edge line.");
	#else
			if(fscanf(file, "%u %u %u %lf %lf %lf %d %d %s %c\n", &id, &from, &to, &length, &delay, &bw, &asFrom, &asTo, type, &val) != 10)
				throw ExceptionIo(__FILE__, __LINE__, "TopoBrite::Read : cannot read edge line.");
	#endif
			assert(id == index);

			if(bw > this->bwMax) bw = (double)this->bwMax;
			if(bw < this->bwMin) bw = (double)this->bwMin;

			// Set the edge for the nodes
			uint entryFrom = this->nodes[from]->SetEdge(index);
			uint entryTo = this->nodes[to]->SetEdge(index);

			// Create the edge
			this->edges[index] = alloc TopoBriteEdge(index, from, to, entryFrom, entryTo, length, delay / 1000, (__bitrate)ceil(bw));
		}

		// Close file
		fclose(file);
	}