+void OpenDirectory( GtkCList *clist, char *psz_dir )
+{
+ intf_thread_t *p_intf = GtkGetIntf( clist );
+ gchar *ppsz_text[2];
+ int row=0;
+
+ char* dir_path;
+ DIR* dir;
+ struct dirent* entry=NULL;
+ char entry_path[PATH_MAX+1];
+ size_t path_len;
+
+ if (psz_dir)
+ dir_path = psz_dir;
+ else
+ dir_path = ".";
+
+ strncpy( &entry_path[0], dir_path, sizeof(entry_path) );
+ /* always force end of string */
+ entry_path[PATH_MAX+1]='\0';
+ path_len = strlen(dir_path);
+ /* Make sure we do not run over our buffer here */
+ if (path_len > PATH_MAX)
+ path_len = PATH_MAX;
+ /* Add backslash to directory path */
+ if (entry_path[path_len-1] != '/')
+ {
+ entry_path[path_len] = '/';
+ entry_path[path_len+1] = '\0';
+ ++path_len;
+ }
+ printf( "path_len=%d\n", path_len );
+ printf( "entry_path=%s\n", entry_path);
+
+ if( p_intf->p_sys->p_clist == NULL )
+ intf_ErrMsg("OpenDirectory - ERROR p_intf->p_sys->p_clist == NULL");
+ gtk_clist_freeze( p_intf->p_sys->p_clist );
+ gtk_clist_clear( p_intf->p_sys->p_clist );
+
+ dir = opendir(dir_path);
+ if (!dir) perror("opendir");
+ while( (entry = readdir(dir))!=NULL )
+ {
+ if (!entry) perror("readdir");
+ printf( "sizeof(entry->d_name)=%d\n",sizeof(&(entry)->d_name[0]) );
+ printf( "entry->d_name=%s\n",&(entry->d_name)[0] );
+
+ strncpy( entry_path + path_len, &(entry)->d_name[0], sizeof(entry_path) - path_len );
+ /* always force end of string */
+ entry_path[PATH_MAX+1]='\0';
+ /* This is a list of strings. */
+ ppsz_text[0] = &(entry)->d_name[0];
+ ppsz_text[1] = get_file_perm(entry_path);
+ printf( "%-18s %s\n", ppsz_text[1], &(entry)->d_name[0] );
+// gtk_clist_insert( p_intf->p_sys->p_clist, row, ppsz_text );
+ row++;
+ }
+ closedir(dir);
+
+ gtk_clist_thaw( p_intf->p_sys->p_clist );
+}
+
+char* get_file_perm(const char *path)