Ejemplo n.º 1
0
void scan_projects(const char *path, const char *projectsfile, repo_config_fn fn)
{
	struct strbuf line = STRBUF_INIT;
	FILE *projects;
	int err;

	projects = fopen(projectsfile, "r");
	if (!projects) {
		fprintf(stderr, "Error opening projectsfile %s: %s (%d)\n",
			projectsfile, strerror(errno), errno);
		return;
	}
	while (strbuf_getline(&line, projects, '\n') != EOF) {
		if (!line.len)
			continue;
		strbuf_insert(&line, 0, "/", 1);
		strbuf_insert(&line, 0, path, strlen(path));
		scan_path(path, line.buf, fn);
	}
	if ((err = ferror(projects))) {
		fprintf(stderr, "Error reading from projectsfile %s: %s (%d)\n",
			projectsfile, strerror(err), err);
	}
	fclose(projects);
	strbuf_release(&line);
}
Ejemplo n.º 2
0
void scan_projects(const char *path, const char *projectsfile, repo_config_fn fn)
{
	char line[MAX_PATH * 2], *z;
	FILE *projects;
	int err;

	projects = fopen(projectsfile, "r");
	if (!projects) {
		fprintf(stderr, "Error opening projectsfile %s: %s (%d)\n",
			projectsfile, strerror(errno), errno);
		return;
	}
	while (fgets(line, sizeof(line), projects) != NULL) {
		for (z = &lastc(line);
		     strlen(line) && strchr("\n\r", *z);
		     z = &lastc(line))
			*z = '\0';
		if (strlen(line))
			scan_path(path, fmt("%s/%s", path, line), fn);
	}
	if ((err = ferror(projects))) {
		fprintf(stderr, "Error reading from projectsfile %s: %s (%d)\n",
			projectsfile, strerror(err), err);
	}
	fclose(projects);
}
Ejemplo n.º 3
0
/* Look for a file along PATH. If we find it, look for an enclosing prefix.
 */
static char *
find_file( const char *name )
{
	const char *path = g_getenv( "PATH" );
	char *prefix;
	char full_path[PATH_MAX];

	if( !path )
		return( NULL );

#ifdef DEBUG
	printf( "vips_guess_prefix: g_getenv( \"PATH\" ) == \"%s\"\n", path );
#endif /*DEBUG*/

#ifdef OS_WIN32
	/* Windows always searches '.' first, so prepend cwd to path.
	 */
	vips_snprintf( full_path, PATH_MAX, "%s" G_SEARCHPATH_SEPARATOR_S "%s",
		get_current_dir(), path );
#else /*!OS_WIN32*/
	vips_strncpy( full_path, path, PATH_MAX );
#endif /*OS_WIN32*/

	if( (prefix = scan_path( full_path, name )) ) 
		return( prefix );

	return( NULL );
}
Ejemplo n.º 4
0
/**
 * Media Library Test Runner
 * - load a number of tests from json files
 * - by default, run tests as unit tests
 * - optionally run tests as performance tests, but then require a db directory
 */
gint
main (gint argc, gchar **argv)
{
	xmmsv_t *testcases, *databases;
	xmms_test_args_t args = { 0 };

	g_thread_init (0);

	xmms_log_init (0);

	parse_command_line (argc, argv, &args);

	g_log_set_default_handler (simple_log_handler, (gpointer) &args);

	g_debug ("Test variant: %s", args.variant == UNITTEST ? "unit test" : "performance test");
	g_debug ("Output format: %s", args.format == FORMAT_PRETTY ? "pretty" : "csv");
	g_debug ("Database path: %s", args.database_path);
	g_debug ("Testcase path: %s", args.testcase_path);

	testcases = scan_path (args.testcase_path, filter_testcase);

	if (args.variant == PERFORMANCE) {
		if (args.format == FORMAT_CSV)
			g_print ("\"dataset\",\"test\",\"success\",\"duration\"\n");
		else
			g_print (" - Running Performance Test -\n");

		databases = scan_path (args.database_path, filter_databases);
		run_performance_tests (databases, testcases, args.format);
		xmmsv_unref (databases);
	} else {
		if (args.format == FORMAT_CSV)
			g_print ("\"test\",\"success\"\n");
		else
			g_print (" - Running Unit Test -\n");
		run_tests (NULL, testcases, run_unit_test, args.format, NULL);
	}

	xmmsv_unref (testcases);

	return EXIT_SUCCESS;
}
Ejemplo n.º 5
0
void process( char *path )
{
    if( path == NULL ) {
        NORMAL( fprintf( stderr, "Process was passed a NULL string\n" ));
        return;
    }

    if( scan_path( path, 0 )) {
        VERBOSE( fprintf( stderr, "Failed to scan %s: %s\n", path, 
                    strerror(errno )));
    }
}
Ejemplo n.º 6
0
static void scan_path(const char *base, const char *path, repo_config_fn fn)
{
	DIR *dir = opendir(path);
	struct dirent *ent;
	struct strbuf pathbuf = STRBUF_INIT;
	size_t pathlen = strlen(path);
	struct stat st;

	if (!dir) {
		fprintf(stderr, "Error opening directory %s: %s (%d)\n",
			path, strerror(errno), errno);
		return;
	}

	strbuf_add(&pathbuf, path, strlen(path));
	if (is_git_dir(pathbuf.buf)) {
		add_repo(base, &pathbuf, fn);
		goto end;
	}
	strbuf_addstr(&pathbuf, "/.git");
	if (is_git_dir(pathbuf.buf)) {
		add_repo(base, &pathbuf, fn);
		goto end;
	}
	/*
	 * Add one because we don't want to lose the trailing '/' when we
	 * reset the length of pathbuf in the loop below.
	 */
	pathlen++;
	while ((ent = readdir(dir)) != NULL) {
		if (ent->d_name[0] == '.') {
			if (ent->d_name[1] == '\0')
				continue;
			if (ent->d_name[1] == '.' && ent->d_name[2] == '\0')
				continue;
			if (!ctx.cfg.scan_hidden_path)
				continue;
		}
		strbuf_setlen(&pathbuf, pathlen);
		strbuf_addstr(&pathbuf, ent->d_name);
		if (stat(pathbuf.buf, &st)) {
			fprintf(stderr, "Error checking path %s: %s (%d)\n",
				pathbuf.buf, strerror(errno), errno);
			continue;
		}
		if (S_ISDIR(st.st_mode))
			scan_path(base, pathbuf.buf, fn);
	}
end:
	strbuf_release(&pathbuf);
	closedir(dir);
}
Ejemplo n.º 7
0
static void scan_path(const char *base, const char *path, repo_config_fn fn)
{
	DIR *dir = opendir(path);
	struct dirent *ent;
	char *buf;
	struct stat st;

	if (!dir) {
		fprintf(stderr, "Error opening directory %s: %s (%d)\n",
			path, strerror(errno), errno);
		return;
	}
	if (is_git_dir(path)) {
		add_repo(base, path, fn);
		goto end;
	}
	if (is_git_dir(fmt("%s/.git", path))) {
		add_repo(base, fmt("%s/.git", path), fn);
		goto end;
	}
	while ((ent = readdir(dir)) != NULL) {
		if (ent->d_name[0] == '.') {
			if (ent->d_name[1] == '\0')
				continue;
			if (ent->d_name[1] == '.' && ent->d_name[2] == '\0')
				continue;
			if (!ctx.cfg.scan_hidden_path)
				continue;
		}
		buf = malloc(strlen(path) + strlen(ent->d_name) + 2);
		if (!buf) {
			fprintf(stderr, "Alloc error on %s: %s (%d)\n",
				path, strerror(errno), errno);
			exit(1);
		}
		sprintf(buf, "%s/%s", path, ent->d_name);
		if (stat(buf, &st)) {
			fprintf(stderr, "Error checking path %s: %s (%d)\n",
				buf, strerror(errno), errno);
			free(buf);
			continue;
		}
		if (S_ISDIR(st.st_mode))
			scan_path(base, buf, fn);
		free(buf);
	}
end:
	closedir(dir);
}
void VST_SoundPluginSource::scan_plugins() {
	
	for (int i=0;i<path_list.size();i++) {
		
		scan_path( path_list[i] );
	}
	
	Sorter sorter;
	std::sort(plugin_list.begin(),plugin_list.end(),sorter);	
	
	for (int i=0;i<plugin_list.size();i++) {
		
		SoundPluginList::get_singleton()->add_info(&plugin_list[i]->plugin_info);		
	}	
}
Ejemplo n.º 9
0
int main(int argc, char* argv[])
{
	std::vector<std::string> files;
	std::string path;
	int  ch;

	while ((ch = getopt(argc, argv, "hf:d:")) > 0)
	{
		switch (ch)
		{
		case 'h':
			usage(argv[0]);
			return 0;
		case 'f':
			files.push_back(optarg);
			break;
		case 'd':
			path = optarg;
			break;
		default:
			break;
		}
	}

	char buf[1024];
	if (getcwd(buf, sizeof(buf)) == NULL)
	{
		printf("getcwd error %s\r\n", acl::last_serror());
		return 1;
	}

	if (!path.empty())
	{
		if (chdir(path.c_str()) < 0)
		{
			printf("chdir to %s error %s\r\n", path.c_str(),
				acl::last_serror());
			return 1;
		}

		scan_path(files);
	}

	if (files.empty())
	{
		usage(argv[0]);
		return 1;
	}

	create_files(files);

	// return the saved working path
	if (chdir(buf) < 0)
	{
		printf("chdir to %s error %s\r\n", buf, acl::last_serror());
		return 1;
	}
	if(path.empty())
	{
		path = files.front();
		std::size_t pos = path.find_last_of('/');
		if (pos == std::string::npos)
			pos = path.find_last_of('\\');
		if (pos == std::string::npos)
			return 0;
		path = path.substr(0, pos);
		if(path.empty() == false)
			copy_files(path.c_str());
	}
	return 0;
}
Ejemplo n.º 10
0
void scan_tree(const char *path, repo_config_fn fn)
{
	scan_path(path, path, fn);
}