Beispiel #1
0
void
set_config_dir(void)
{
	char *home_dir = getenv("HOME");

	if(home_dir)
	{
		FILE *f;
		char help_file[PATH_MAX];
		char rc_file[PATH_MAX];

		snprintf(rc_file, sizeof(rc_file), "%s/.vifm/vifmrc", home_dir);
		snprintf(help_file, sizeof(help_file), "%s/.vifm/vifm-help_txt", 
				home_dir);
		snprintf(cfg.config_dir, sizeof(cfg.config_dir), "%s/.vifm", home_dir);
		snprintf(cfg.trash_dir, sizeof(cfg.trash_dir), "%s/.vifm/Trash", home_dir);

		if(chdir(cfg.config_dir))
		{
			if(mkdir(cfg.config_dir, 0777))
				return;
			if(mkdir(cfg.trash_dir, 0777))
				return;
			if((f = fopen(help_file, "r")) == NULL)
				create_help_file();
			if((f = fopen(rc_file, "r")) == NULL)
				create_rc_file();
		}

	}
}
Beispiel #2
0
/* ensures existence of configuration directory */
static void
create_config_dir(void)
{
	LOG_FUNC_ENTER;

	/* ensure existence of configuration directory */
	if(!is_dir(cfg.config_dir))
	{
#ifndef _WIN32
		FILE *f;
		char help_file[PATH_MAX];
		char rc_file[PATH_MAX];

		if(make_dir(cfg.config_dir, 0777) != 0)
			return;

		snprintf(help_file, sizeof(help_file), "%s/" VIFM_HELP, cfg.config_dir);
		if((f = fopen(help_file, "r")) == NULL)
			create_help_file();
		else
			fclose(f);

		snprintf(rc_file, sizeof(rc_file), "%s/" VIFMRC, cfg.config_dir);
		if((f = fopen(rc_file, "r")) == NULL)
			create_rc_file();
		else
			fclose(f);
#else
		if(make_dir(cfg.config_dir, 0777) != 0)
			return;
#endif

		add_default_bookmarks();
	}
}
Beispiel #3
0
/* ensures existence of configuration directory */
static void
create_config_dir(void)
{
	LOG_FUNC_ENTER;

	/* ensure existence of configuration directory */
	if(!is_dir(cfg.config_dir))
	{
#ifndef _WIN32
		FILE *f;
		char help_file[PATH_MAX];
		char rc_file[PATH_MAX];

		if(make_dir(cfg.config_dir, 0777) != 0)
			return;

		snprintf(help_file, sizeof(help_file), "%s/" VIFM_HELP, cfg.config_dir);
		if((f = fopen(help_file, "r")) == NULL)
			create_help_file();
		else
			fclose(f);

		snprintf(rc_file, sizeof(rc_file), "%s/" VIFMRC, cfg.config_dir);
		if((f = fopen(rc_file, "r")) == NULL)
			create_rc_file();
		else
			fclose(f);

		/* This should be first start of Vifm, ensure that newly created sample
		 * vifmrc file is used right away. */
		env_set(MYVIFMRC_EV, rc_file);
#else
		if(make_dir(cfg.config_dir, 0777) != 0)
			return;
#endif

		add_default_bookmarks();
	}
}