コード例 #1
0
ファイル: browser.c プロジェクト: gentoo/pornview
void
browser_select_dir (gchar * path)
{
    gchar  *title;
    char    buf[PATH_MAX];

    if (!strcmp (browser->last_path->str, path))
	return;

#ifdef ENABLE_MOVIE
    videoplay_clear ();
#endif
    comment_view_clear (commentview);
    thumbview_stop ();
    imageview_stop ();

    viewtype_set (VIEWTYPE_IMAGEVIEW);

    g_string_assign (browser->last_path, path);
    g_string_assign (browser->current_path, path);

    thumbview_clear ();

    file_list_create (browser->filelist, path);

    title = g_strconcat ("PornView - ", g_basename (path), NULL);
    gtk_window_set_title (GTK_WINDOW (browser->window), title);
    g_free (title);

    snprintf (buf, PATH_MAX, "  %d", browser->filelist->num);
    gtk_statusbar_pop (GTK_STATUSBAR (BROWSER_STATUS_DIR), 1);
    gtk_statusbar_push (GTK_STATUSBAR (BROWSER_STATUS_DIR), 1, buf);

    thumbview_add (browser->filelist);
}
コード例 #2
0
ファイル: tuifs.c プロジェクト: AreaScout/vice
static struct file_list *file_list_read_nolfn(const char *path, const char *pattern)
{
    char *cwd = ioutil_current_dir();
    struct file_list *fl = NULL;
    struct find_t f;

    if (cwd == NULL) {
        return NULL;
    }

    if (ioutil_chdir(path) < 0) {
        goto end;
    }

    if (_dos_findfirst("*.*", (_A_NORMAL | _A_RDONLY | _A_HIDDEN | _A_SYSTEM | _A_SUBDIR | _A_ARCH), &f)) {
        goto end;
    }

    fl = file_list_create();

    /* (We skip `.' here.) */

    while (!_dos_findnext(&f)) {
        strlwr(f.name);
        if (pattern == NULL || (f.attrib & _A_SUBDIR)) {
            file_list_add_item(fl, f.name, (f.attrib & _A_SUBDIR) ? FT_DIR : FT_NORMAL);
            continue;
        }
        {
            char *p = lib_stralloc(pattern);
            char *element;

            element = strtok(p, ";");
            do {
                if (fnmatch(element, f.name, FNM_NOCASE) == 0) {
                    file_list_add_item(fl, f.name, (f.attrib & _A_SUBDIR) ? FT_DIR : FT_NORMAL);
                }
                element = strtok(NULL, ";");
            } while (element != NULL);
            lib_free(p);
        }
    }

    file_list_sort(fl);

end:
    ioutil_chdir(cwd);
    return fl;
}
コード例 #3
0
/**
 * Check the commandline arguments
 * @param argc number of commandline args+1
 * @param argv array of arguments, first is program name
 * @return 1 if they were OK, 0 otherwise
 */
static int check_args( int argc, char **argv )
{
	int sane = 1;
	markup_files = NULL;
    css_files = NULL;
    text_file = NULL;
	if ( argc < 7 )
		sane = 0;
	else
	{
		int i;
		for ( i=1;i<argc;i++ )
		{
			if ( strlen(argv[i])==2 && argv[i][0]=='-' )
			{
				switch ( argv[i][1] )
				{
					case 'v':
						fprintf( stderr, "formatter version 2.0 (c) "
								"Desmond Schmidt 2011\n");
						doing_help = 1;
						break;
					case 'h':
						print_help();
						doing_help = 1;
						break;
					case 'f':
						if ( i < argc-1 )
							format_name = argv[i+1];
						else
							sane = 0;
						break;
					case 'l':
						printf("%s",master_list());
						doing_help = 1;
						break;
					case 'c':
						if ( i < argc-1 )
                            css_files = file_list_create( argv[i+1] );
						else
							sane = 0;
						break;
					case 'm':
						if ( i < argc-1 )
                            markup_files = file_list_create( argv[i+1] );
						else
							sane = 0;
						break;
					case 't':
						if ( i < argc-1 )
							text_file = file_list_create( argv[i+1] );
						else
							sane = 0;
						break;
				}
			}
			if ( !sane )
				break;
		}
		if ( !doing_help )
		{
			if ( text_file==NULL||markup_files==NULL||css_files==NULL)
				sane = 0;
			else
			{
                char *missing;
				if ( !file_list_check(css_files,&missing) )
					warning("can't find css file %s\n",missing );
				if ( !file_list_check(markup_files,&missing) )
					warning("can't find markup file %s\n",missing );
                if ( !file_list_check(text_file,&missing) )
					warning("can't find text file %s\n",missing );
                if ( !file_list_contains(css_files,argv[argc-1])
                    && !file_list_contains(text_file,argv[argc-1])
                    && !file_list_contains(markup_files,argv[argc-1]) )
                    strncpy( html_file_name, argv[argc-1], FILE_NAME_LEN );
                else
                    strncpy( html_file_name, DEFAULT_HTML_FILE, 
                        FILE_NAME_LEN );
			}
		}
	}
	return sane;
}
コード例 #4
0
ファイル: tuifs.c プロジェクト: AreaScout/vice
/* XXX: Assumes `path' ends with a slash.  */
static struct file_list *file_list_read_lfn(const char *path, const char *pattern)
{
    struct dirent *d;
    struct file_list *fl;
    DIR *ds;
    int pathlen = strlen(path);

    if (path == NULL || *path == '\0') {
        ds = opendir(".");
    } else {
        ds = opendir(path);
    }

    if (ds == NULL) {
        return NULL;
    }

    fl = file_list_create();

    /* Skip ".".  */
    readdir(ds);

    {
        unsigned short old_djstat = _djstat_flags;

        /* This makes `stat()' faster.  FIXME: but it's still too slow
           imo...  */
        _djstat_flags = (_STAT_INODE | _STAT_EXEC_EXT | _STAT_EXEC_MAGIC | _STAT_DIRSIZE | _STAT_ROOT_TIME | _STAT_WRITEBIT);

        while ((d = readdir(ds)) != NULL) {
            struct stat s;
            int type;
            /* Warning: Assumes `path' has a trailing '/'.  */
            char *name = alloca(d->d_namlen + pathlen + 1);

            memcpy(name, path, pathlen);
            strcpy(name + pathlen, d->d_name);

            if (stat(name, &s) != -1) {
                type = S_ISDIR(s.st_mode) ? FT_DIR : FT_NORMAL;
                if (pattern == NULL || type == FT_DIR) {
                    file_list_add_item(fl, d->d_name, type);
                    continue;
                }
                {
                    char *p = lib_stralloc(pattern);
                    char *element;

                    element = strtok(p, ";");
                    do {
                        if (fnmatch(element, d->d_name, FNM_NOCASE) == 0) {
                            file_list_add_item(fl, d->d_name, type);
                        }
                        element = strtok(NULL, ";");
                    } while (element != NULL);
                    lib_free(p);
                }
            }
        }

        _djstat_flags = old_djstat;
    }

    file_list_sort(fl);
    closedir(ds);

    return fl;
}