@@ -27,20 +27,39 @@ process_refs(entry_ref directoryRef, BMessage* msg, void*)
2727{
2828	BPath path;
2929	entry_ref file_ref;
30+ 
3031	if  (msg->FindRef (" refs"  , &file_ref) == B_NO_ERROR) {
31- 		BEntry (&file_ref).GetPath (&path);
32- 		BString command (
33- 			" stat=$(curl -m 2 -s -I http://google.com | grep HTTP/1 | awk {'print $2'}) ; " 
34- 			" if [ -z  \" $stat\"  ] ; then "  	//  network up in general?
35- 				" clipboard -c \" %ERROR%\"  ; " 
36- 			" else " 
37- 				" curl -F'file=@'\" %FILENAME%\"  https://0x0.st | clipboard -i ; " 
38- 			" fi ; " 
39- 			" exit"  );
40- 		command.ReplaceAll (" %ERROR%"  ,
41- 			B_TRANSLATE (" Online upload service not available"  ));
42- 		command.ReplaceAll (" %FILENAME%"  , path.Path ());
43- 		system (command.String ());
32+ 		BEntry entry (&file_ref);
33+ 		if  (entry.IsDirectory ()) {
34+ 			BString text (B_TRANSLATE (
35+ 				" UploadIt only works on a single file, no folders"  ));
36+ 			ssize_t  textLen = text.Length ();
37+ 			BMessage* message = (BMessage *)NULL ;
38+ 
39+ 			if  (be_clipboard->Lock ()) {
40+ 				be_clipboard->Clear ();
41+ 				if  ((message = be_clipboard->Data ())) {
42+ 					message->AddData (" text/plain"  , B_MIME_TYPE, text.String (),
43+ 						textLen);
44+ 					be_clipboard->Commit ();
45+ 				}
46+ 				be_clipboard->Unlock ();
47+ 			}
48+ 		} else  {
49+ 			entry.GetPath (&path);
50+ 			BString command (
51+ 				" stat=$(curl -m 2 -s -I http://google.com | grep HTTP/1 | awk {'print $2'}) ; " 
52+ 				" if [ -z  \" $stat\"  ] ; then "  	//  network up in general?
53+ 					" clipboard -c \" %ERROR%\"  ; " 
54+ 				" else " 
55+ 					" curl -F'file=@'\" %FILENAME%\"  https://0x0.st | clipboard -i ; " 
56+ 				" fi ; " 
57+ 				" exit"  );
58+ 			command.ReplaceAll (" %ERROR%"  ,
59+ 				B_TRANSLATE (" Online upload service not available"  ));
60+ 			command.ReplaceAll (" %FILENAME%"  , path.Path ());
61+ 			system (command.String ());
62+ 		}
4463	}
4564}
4665
0 commit comments