After Dragging the file, only file name is returned

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

After Dragging the file, only file name is returned

Postby sgaitonde » Thu Sep 21, 2023 5:58 am

We are using cef 110 build on mac and windows for a desktop in a C++ app. On mac, After we receive the call back, when we run the GetFileNames() on the dragData (dragData->GetFileNames(fileNames)), we are getting only the file name but not the path. On windows we get the full path.

Code: Select all
void OnDragEnter(CefRefPtr<CefBrowser> browser, CefRefPtr<CefDragData> dragData, CefDragHandler::DragOperationsMask mask)
{
       if(dragData)
       {
              dragData->GetFileNames(fileNames);
              for(const auto& fileName : fileNames)
              {
                        std::cout<< fileName;
              }
       }
}


Same piece of code prints full path in windows and in mac only file with extention is printed. We need to get the full path of the file dragged into the browser.

Any help will be appreciated
sgaitonde
Newbie
 
Posts: 3
Joined: Mon Sep 04, 2023 6:33 am

Re: After Dragging the file, only file name is returned

Postby magreenblatt » Thu Sep 21, 2023 8:41 am

The code is here, I suggest stepping through with a debugger to see what's going on.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: After Dragging the file, only file name is returned

Postby ndesktop » Thu Sep 21, 2023 9:03 am

Maybe content::DropData display_name on Windows is empty and it returns path, while on macOS is not empty and therefore it returns the display name?
ndesktop
Master
 
Posts: 756
Joined: Thu Dec 03, 2015 10:10 am

Re: After Dragging the file, only file name is returned

Postby sgaitonde » Thu Sep 21, 2023 9:12 am

ndesktop wrote:Maybe content::DropData display_name on Windows is empty and it returns path, while on macOS is not empty and therefore it returns the display name?


Yes this is correct. Display_name is file name in Mac so we get only file name. In windows it's empty and so we get path. This needs to be fixed I think
sgaitonde
Newbie
 
Posts: 3
Joined: Mon Sep 04, 2023 6:33 am

Re: After Dragging the file, only file name is returned

Postby ndesktop » Thu Sep 21, 2023 9:34 am

Maybe adding a new method, GetFilePaths, which will return path instead of display_name.
ndesktop
Master
 
Posts: 756
Joined: Thu Dec 03, 2015 10:10 am

Re: After Dragging the file, only file name is returned

Postby magreenblatt » Thu Sep 21, 2023 9:55 am

ndesktop wrote:Maybe adding a new method, GetFilePaths, which will return path instead of display_name.

Agreed. GetFileNames() should probably also only return the file name component (not the complete path).
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: After Dragging the file, only file name is returned

Postby sgaitonde » Thu Sep 21, 2023 10:23 am

magreenblatt wrote:
ndesktop wrote:Maybe adding a new method, GetFilePaths, which will return path instead of display_name.

Agreed. GetFileNames() should probably also only return the file name component (not the complete path).


Thanks. Let us know when that API would be available. Or any alternative where we can get path currently. We need to open that file into a stream for further processing.
sgaitonde
Newbie
 
Posts: 3
Joined: Mon Sep 04, 2023 6:33 am

Re: After Dragging the file, only file name is returned

Postby magreenblatt » Thu Sep 21, 2023 11:36 am

sgaitonde wrote:
magreenblatt wrote:
ndesktop wrote:Maybe adding a new method, GetFilePaths, which will return path instead of display_name.

Agreed. GetFileNames() should probably also only return the file name component (not the complete path).


Thanks. Let us know when that API would be available. Or any alternative where we can get path currently. We need to open that file into a stream for further processing.

You can start by adding a feature request a https://github.com/chromiumembedded/cef/issues. A pull request implementing the necessary changes would also be welcome.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: After Dragging the file, only file name is returned

Postby ndesktop » Thu Sep 21, 2023 12:32 pm

Feature request added.
Will try to create the PR in the following days.
ndesktop
Master
 
Posts: 756
Joined: Thu Dec 03, 2015 10:10 am

Re: After Dragging the file, only file name is returned

Postby magreenblatt » Thu Sep 21, 2023 12:35 pm

ndesktop wrote:Feature request added.
Will try to create the PR in the following days.

Thanks :)
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Next

Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 205 guests