Browse Source

Added linux RequestDir.

Mark Sibly 9 years ago
parent
commit
cdb0eeeda7
1 changed files with 23 additions and 3 deletions
  1. 23 3
      modules/mojo/requesters/native/requesters.cpp

+ 23 - 3
modules/mojo/requesters/native/requesters.cpp

@@ -173,18 +173,20 @@ bbString bbRequesters::RequestDir( bbString title,bbString dir ){
 	bbString str;
 	
 	if( ITEMIDLIST *idlist=SHBrowseForFolderW( &bi ) ){
+	
 		SHGetPathFromIDListW( idlist,buf );
 		str=bbString( buf );
+		
 		//SHFree( idlist );	//?!?
+		
+		str=str.replace( "\\","/" );
+		if( !str.endsWith( "/" ) ) str+="/";
 	}
 	
 	endPanel();
 	
 	free( (void*)bi.lpszTitle );
 
-	str=str.replace( "\\","/" );
-	if( !str.endsWith( "/" ) ) str+="/";
-
 	return str;
 }
 
@@ -210,4 +212,22 @@ bbString bbRequesters::RequestFile( bbString title,bbString exts,bbBool save,bbS
 	return bbString::fromCString( buf,n );
 }
 
+bbString bbRequesters::RequestDir( bbString title,bbString dir ){
+
+	bbString cmd=BB_T("zenity --title=\"")+title+BB_T("\" --file-selection --directory");
+
+	FILE *f=popen( cmd.c_str(),"r" );
+	if( !f ) return "";
+	
+	char buf[PATH_MAX];
+	int n=fread( buf,1,PATH_MAX,f );
+	pclose( f );
+	
+	if( n<0 || n>PATH_MAX ) return "";
+	
+	while( n && buf[n-1]<=32 ) --n;
+	
+	return bbString::fromCString( buf,n );
+}
+
 #endif