Bug 105809 - filepicker crash if the user does not have read permission for the directory. r=jag, sr=shaver.
git-svn-id: svn://10.0.0.236/trunk@109046 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
ed1e2249a7
commit
d597acb80e
@ -519,7 +519,17 @@ function gotoDirectory(directory) {
|
||||
addToHistory(directory.unicodePath);
|
||||
|
||||
window.setCursor("wait");
|
||||
outlinerView.setDirectory(directory);
|
||||
try {
|
||||
outlinerView.setDirectory(directory);
|
||||
} catch(ex) {
|
||||
var errorTitle = gFilePickerBundle.getString("noPermissionTitle");
|
||||
var errorMsg = gFilePickerBundle.getString("noPermissionError");
|
||||
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(Components.interfaces.nsIPromptService);
|
||||
promptService.alert(window, errorTitle, errorMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
window.setCursor("auto");
|
||||
|
||||
outlinerView.QueryInterface(nsIOutlinerView).selection.clearSelection();
|
||||
|
||||
@ -25,3 +25,6 @@ errorOpenFileDoesntExistMessage=File %S doesn't exist
|
||||
errorSavingFileTitle=Error saving %S
|
||||
saveParentIsFileMessage=%S is a file, can't save %S
|
||||
saveParentDoesntExistMessage=Path %S doesn't exist, can't save %S
|
||||
|
||||
noPermissionTitle=Error opening directory
|
||||
noPermissionError=You do not have the permissions necessary to view this directory.
|
||||
|
||||
@ -239,12 +239,19 @@ nsFileView::Sort(PRInt16 aSortType, PRBool aReverseSort)
|
||||
NS_IMETHODIMP
|
||||
nsFileView::SetDirectory(nsIFile* aDirectory)
|
||||
{
|
||||
nsCOMPtr<nsISimpleEnumerator> dirEntries;
|
||||
aDirectory->GetDirectoryEntries(getter_AddRefs(dirEntries));
|
||||
|
||||
if (!dirEntries) {
|
||||
// Couldn't read in the directory, this can happen if the user does not
|
||||
// have permission to list it.
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mDirectoryPath = aDirectory;
|
||||
mFileList->Clear();
|
||||
mDirList->Clear();
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> dirEntries;
|
||||
mDirectoryPath->GetDirectoryEntries(getter_AddRefs(dirEntries));
|
||||
PRBool hasMore = PR_FALSE;
|
||||
PRInt32 dirCount = 0, fileCount = 0;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user