Ejemplo n.º 1
0
static int ctl_load_files_and_play(argc_argv_t *argc_argv, int playflag)
{
    StringTable st;
    int i, n, len;
    char buffer[BUFSIZ];
    char **files;
    int prevnfiles;

    if(argc_argv==NULL)
        return RC_NONE;

    w32g_get_playlist_index(NULL, &prevnfiles, NULL);

    init_string_table(&st);
    n = argc_argv->argc;
    for(i = 0; i < n; i++)
    {
        strcpy(buffer,(argc_argv->argv)[i]);
        if(is_directory(buffer))
            directory_form(buffer);
        len = strlen(buffer);
        put_string_table(&st, buffer, strlen(buffer));
    }
#if 1
    for(i=0; i<argc_argv->argc; i++) {
        free(argc_argv->argv[i]);
    }
    free(argc_argv->argv);
    argc_argv->argv = NULL;
    argc_argv->argc = 0;
#endif
    if((files = make_string_array(&st)) == NULL)
        n = 0;
    else
    {
        n = w32g_add_playlist(n, files, 1,
                              ctl.flags & CTLF_AUTOUNIQ,
                              ctl.flags & CTLF_AUTOREFINE);
        free(files[0]);
        free(files);
    }
    if(n > 0)
    {
        ctl_panel_refresh();
        if(playflag)
        {
            w32g_goto_playlist(prevnfiles, !(ctl.flags & CTLF_NOT_CONTINUE));
            return RC_LOAD_FILE;
        }
    }
    return RC_NONE;
}
Ejemplo n.º 2
0
static int ctl_drop_file(HDROP hDrop)
{
    StringTable st;
    int i, n, len;
    char buffer[BUFSIZ];
    char **files;
    int prevnfiles;

    w32g_get_playlist_index(NULL, &prevnfiles, NULL);

    init_string_table(&st);
    n = DragQueryFile(hDrop,0xffffffffL, NULL, 0);
    for(i = 0; i < n; i++)
    {
        DragQueryFile(hDrop, i, buffer, sizeof(buffer));
        if(is_directory(buffer))
            directory_form(buffer);
        len = strlen(buffer);
        put_string_table(&st, buffer, strlen(buffer));
    }
    DragFinish(hDrop);

    if((files = make_string_array(&st)) == NULL)
        n = 0;
    else
    {
        n = w32g_add_playlist(n, files, 1,
                              ctl.flags & CTLF_AUTOUNIQ,
                              ctl.flags & CTLF_AUTOREFINE);
        free(files[0]);
        free(files);
    }
    if(n > 0)
    {
        ctl_panel_refresh();
        if(ctl.flags & CTLF_DRAG_START)
        {
            w32g_goto_playlist(prevnfiles, !(ctl.flags & CTLF_NOT_CONTINUE));
            return RC_LOAD_FILE;
        }
    }
    return RC_NONE;
}
Ejemplo n.º 3
0
static int ctl_load_file(char *fileptr)
{
    StringTable st;
    int len, n;
    char **files;
    char buffer[BUFSIZ];
    char *basedir;

    init_string_table(&st);
    n = 0;
    basedir = fileptr;
    fileptr += strlen(fileptr) + 1;
    while(*fileptr)
    {
        snprintf(buffer, sizeof(buffer), "%s\\%s", basedir, fileptr);
        if(is_directory(buffer))
            directory_form(buffer);
        len = strlen(buffer);
        put_string_table(&st, buffer, len);
        n++;
        fileptr += strlen(fileptr) + 1;
    }

    if(n == 0)
    {
        put_string_table(&st, basedir, strlen(basedir));
        n++;
    }

    files = make_string_array(&st);
    n = w32g_add_playlist(n, files, 1,
                          ctl.flags & CTLF_AUTOUNIQ,
                          ctl.flags & CTLF_AUTOREFINE);
    free(files[0]);
    free(files);

    if(n > 0)
        ctl_panel_refresh();
    w32g_lock_open_file = 0;
    return RC_NONE;
}
Ejemplo n.º 4
0
void ScanDirectoryFiles(char *basedir,
						int (* file_proc)(char *pathname, /* (const) */
										  void *user_val),
						void *user_val)
{
	char baselen;
	URL dir;

	static int depth = 0;
    static int stop_flag;	/* Stop scanning if true */
    static int error_disp;	/* Whether error is displayed or not */
	static char pathbuf[MAXPATH]; /* pathname buffer */

	if(depth == 0) /* Initialize variables at first recursive */
	{
		stop_flag = 0;
		error_disp = 0;
		strcpy(pathbuf, basedir);
	}
	else if(depth > SCANDIR_MAX_DEPTH) /* Avoid infinite recursive */
	{
		if(!error_disp)
		{
			/* Display this message at once */
			ctl->cmsg(CMSG_WARNING, VERB_NORMAL,
					  "%s: Directory is too deep",
					  basedir);
			error_disp = 1;
		}
		return; /* Skip scanning this directory */
	}

	directory_form(pathbuf);
	baselen = strlen(pathbuf);
	if(baselen > sizeof(pathbuf) - 16)
	{
		/* Ignore too long file name */
		return;
	}

	if((dir = url_dir_open(pathbuf)) == NULL)
	{
	    ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: Can't open directory", pathbuf);
		return;
	}

	if(file_proc(pathbuf, user_val))
	{
	    stop_flag = 1; /* Terminate */
		return;
	}

	while(!stop_flag &&
		  url_gets(dir, pathbuf + baselen, sizeof(pathbuf) - baselen - 1))
	{
		if(strcmp(pathbuf + baselen, ".") == 0 ||
		   strcmp(pathbuf + baselen, "..") == 0)
			continue;
		if(file_proc(pathbuf, user_val))
		{
			stop_flag = 1; /* Terminate */
			break;
		}
		if(is_directory(pathbuf))
		{
			/* into subdirectory */
			depth++;
			ScanDirectoryFiles(pathbuf, file_proc, user_val);
			depth--;
		}
	}
	url_close(dir);
}