Пример #1
0
static void make_directories(void)
{
   MAKE_DIR(default_paths.port_dir);
   MAKE_DIR(default_paths.system_dir);
   MAKE_DIR(default_paths.savestate_dir);
   MAKE_DIR(default_paths.sram_dir);
   MAKE_DIR(default_paths.input_presets_dir);

   MAKE_FILE(default_paths.config_file);
}
Пример #2
0
static void get_environment_settings(int argc, char *argv[])
{
   (void)argc;
   (void)argv;

#ifdef HW_DOL
   chdir("carda:/retroarch");
#endif
   getcwd(default_paths.core_dir, MAXPATHLEN);
   char *last_slash = strrchr(default_paths.core_dir, '/');
   if (last_slash)
      *last_slash = 0;
   char *device_end = strchr(default_paths.core_dir, '/');
   if (device_end)
      snprintf(default_paths.port_dir, sizeof(default_paths.port_dir), "%.*s/retroarch", device_end - default_paths.core_dir, default_paths.core_dir);
   else
      strlcpy(default_paths.port_dir, "/retroarch", sizeof(default_paths.port_dir));
#ifdef IS_SALAMANDER
   snprintf(default_paths.config_path, sizeof(default_paths.config_path), "%s/retroarch.cfg", default_paths.port_dir);
#else
   snprintf(g_extern.config_path, sizeof(g_extern.config_path), "%s/retroarch.cfg", default_paths.port_dir);
#endif
   snprintf(default_paths.system_dir, sizeof(default_paths.system_dir), "%s/system", default_paths.port_dir);
   snprintf(default_paths.savestate_dir, sizeof(default_paths.savestate_dir), "%s/savestates", default_paths.port_dir);
   strlcpy(default_paths.filesystem_root_dir, "/", sizeof(default_paths.filesystem_root_dir));
   snprintf(default_paths.filebrowser_startup_dir, sizeof(default_paths.filebrowser_startup_dir), default_paths.filesystem_root_dir);
   snprintf(default_paths.sram_dir, sizeof(default_paths.sram_dir), "%s/sram", default_paths.port_dir);
   snprintf(default_paths.input_presets_dir, sizeof(default_paths.input_presets_dir), "%s/input", default_paths.port_dir);
   strlcpy(default_paths.executable_extension, ".dol", sizeof(default_paths.executable_extension));
   strlcpy(default_paths.salamander_file, "boot.dol", sizeof(default_paths.salamander_file));

#ifndef IS_SALAMANDER
   MAKE_DIR(default_paths.port_dir);
   MAKE_DIR(default_paths.system_dir);
   MAKE_DIR(default_paths.savestate_dir);
   MAKE_DIR(default_paths.sram_dir);
   MAKE_DIR(default_paths.input_presets_dir);

   MAKE_FILE(g_extern.config_path);
#endif
}
Пример #3
0
static void salamander_init_settings(void)
{
   char tmp_str[512] = {0};
   bool config_file_exists;

   if(!path_file_exists(default_paths.config_path))
   {
      FILE * f;
      config_file_exists = false;
      RARCH_ERR("Config file \"%s\" doesn't exist. Creating...\n", default_paths.config_path);
      MAKE_DIR(default_paths.port_dir);
      f = fopen(default_paths.config_path, "w");
      fclose(f);
   }
   else
      config_file_exists = true;

   //try to find CORE executable
   char core_executable[1024];
   snprintf(core_executable, sizeof(core_executable), "%s/CORE.dol", default_paths.core_dir);

   if(path_file_exists(core_executable))
   {
      //Start CORE executable
      snprintf(default_paths.libretro_path, sizeof(default_paths.libretro_path), core_executable);
      RARCH_LOG("Start [%s].\n", default_paths.libretro_path);
   }
   else
   {
      if(config_file_exists)
      {
         config_file_t * conf = config_file_new(default_paths.config_path);
         config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str));
         config_file_free(conf);
         snprintf(default_paths.libretro_path, sizeof(default_paths.libretro_path), tmp_str);
      }

      if(!config_file_exists || !strcmp(default_paths.libretro_path, ""))
         find_and_set_first_file();
      else
      {
         RARCH_LOG("Start [%s] found in retroarch.cfg.\n", default_paths.libretro_path);
      }

      if (!config_file_exists)
      {
         config_file_t *new_conf = config_file_new(NULL);
         config_set_string(new_conf, "libretro_path", default_paths.libretro_path);
         config_file_write(new_conf, default_paths.config_path);
         config_file_free(new_conf);
      }
   }
}
int
COPY_DIR (char * source, char * destination)
{
	ERR_NUMBER = 0;
	
	T_PATH	path;
	mode_t	mode;
	DIR *	dir;
	struct	stat		statbuff;
	struct	dirent	*	direntry;
	char	srcpath [PATH_MAX];
	char	despath [PATH_MAX];
	
	mode = FILE_EXIST (source);
	
	/* if FILE_EXIST function fail  */
	if (FAIL == mode)
	{
		return FAIL;
	}/* if (FAIL == mode) */
	/* if source isn't directory */
	else if (S_IFDIR != mode)
	{
		/* pass invalid argument to the function */
		ERR_NUMBER = EINVAL;
		return FAIL;
	}/* else if (S_IFDIR != mode) */
	
	dir = opendir (source);
	
	/* if opendir function cann't open source
	** or for any reason it's fail */
	if (NULL == dir)
	{
		ERR_NUMBER = errno;
		return FAIL;
	}/* if (NULL == dir) */
	
	if (-1 == chdir (source))
	{
		ERR_NUMBER = errno;
		return FAIL;
	}/* if (-1 == chdir (source)) */
	
	/* read next directory entry in this directory */
	while (NULL != (direntry = readdir (dir)))
	{
		if (-1 == stat (direntry->d_name, &statbuff))
		{
			ERR_NUMBER = errno;
			return FAIL;
		}/* if (-1 == stat (dir->d_name, &statbuff)) */
		
		if (S_ISDIR (statbuff.st_mode))
		{
			/* found directory but ignore . and .. */
			if (0 == strcmp (".", direntry->d_name) ||
			    0 == strcmp ("..", direntry->d_name))
			{
				continue;
			}/* if (0 == strcmp (".", direntry->d_name) || ... */
			
			strcpy (srcpath, source);
			strcat (srcpath, "/");
			strcat (srcpath, direntry->d_name);
			
			if (-1 == PATH_PARSE (&path, srcpath))
			{
				return FAIL;
			}/* if (-1 == PATH_PARSE (&path, srcpath)) */
			
			if (FAIL == MAKE_DIR (destination, path.dir_name))
			{
				return FAIL;
			}/* if (FAIL == MAKE_DIR (destination, path.dir_name)) */
			
			strcpy (despath, destination);
			strcat (despath, "/");
			strcat (despath, path.dir_name);
			
			if (FAIL == COPY_DIR (srcpath, despath))
			{
				return FAIL;
			}/* if (FIAL == COPY_DIR (srcpath, despath)) */
			
		}/* if (IS_DIR (statbuff.st_mode)) */
		/* if is regular file */
		else if (S_ISREG (statbuff.st_mode))
		{
			strcpy (srcpath, source);
			strcat (srcpath, "/");
			strcat (srcpath, direntry->d_name);
			
			if (FAIL == COPY_FILES (srcpath, destination))
			{
				return FAIL;
			}/* if (FAIL == COPY_FILES (source, destination)) */
			
		}/* else if (S_ISREG (statbuf.st_mode)) */
		
	}/* while (NULL != (direntry = readdir (dir))) */
	
	
	if (-1 == chdir (".."))
	{
		ERR_NUMBER = errno;
		return FAIL;
	}/* if (-1 == chdir (source)) */
	
	if (-1 == closedir (dir))
	{
		ERR_NUMBER = errno;
		return FAIL;
	}/* if (-1 == closedir (dir)) */
	
	return SUCCESS;

}/* COPY_DIR (char * source, char * destination) */