Bug 812412 - replace full path with leaf name only, r=dougt

This commit is contained in:
Eric Chou 2012-11-21 15:53:19 +08:00
parent 3d1f39fe89
commit 56866e71cd

View File

@ -23,6 +23,7 @@
#include "nsIFile.h"
#include "nsIInputStream.h"
#include "nsIOutputStream.h"
#include "nsLocalFile.h"
#include "nsNetUtil.h"
#define TARGET_FOLDER "/sdcard/downloads/bluetooth/"
@ -276,14 +277,22 @@ BluetoothOppManager::SendFile(BlobParent* aActor)
/*
* Process of sending a file:
* - Keep blob because OPP connection has not been established yet.
* - Try to retrieve file name from the blob or assign one if failed to get.
* - Create an OPP connection by SendConnectRequest()
* - After receiving the response, start to read file and send.
*/
mBlob = aActor->GetBlob();
nsCOMPtr<nsIDOMFile> file = do_QueryInterface(mBlob);
if (file) {
file->GetName(sFileName);
nsCOMPtr<nsIDOMFile> domFile = do_QueryInterface(mBlob);
nsString fullPath;
if (domFile && NS_SUCCEEDED(domFile->GetMozFullPathInternal(fullPath))) {
nsCOMPtr<nsIFile> localFile = new nsLocalFile();
NS_NewLocalFile(fullPath, false, getter_AddRefs(localFile));
if (localFile) {
localFile->GetLeafName(sFileName);
}
}
if (sFileName.IsEmpty()) {