Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Directory creation error #4244

Merged
merged 10 commits into from
Jul 11, 2013
10 changes: 6 additions & 4 deletions src/nls/root/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ define({
"NO_MODIFICATION_ALLOWED_ERR" : "The target directory cannot be modified.",
"NO_MODIFICATION_ALLOWED_ERR_FILE" : "The permissions do not allow you to make modifications.",
"FILE_EXISTS_ERR" : "The file or directory already exists.",
"FILE" : "file",
"DIRECTORY" : "directory",

// Project error strings
"ERROR_LOADING_PROJECT" : "Error loading project",
Expand All @@ -55,11 +57,11 @@ define({
"ERROR_RENAMING_FILE" : "An error occurred when trying to rename the file <span class='dialog-filename'>{0}</span>. {1}",
"ERROR_DELETING_FILE_TITLE" : "Error deleting file",
"ERROR_DELETING_FILE" : "An error occurred when trying to delete the file <span class='dialog-filename'>{0}</span>. {1}",
"INVALID_FILENAME_TITLE" : "Invalid file name",
"INVALID_FILENAME_TITLE" : "Invalid {0} name",
"INVALID_FILENAME_MESSAGE" : "Filenames cannot contain the following characters: /?*:;{}<>\\| or use any system reserved words.",
"FILE_ALREADY_EXISTS" : "The file <span class='dialog-filename'>{0}</span> already exists.",
"ERROR_CREATING_FILE_TITLE" : "Error creating file",
"ERROR_CREATING_FILE" : "An error occurred when trying to create the file <span class='dialog-filename'>{0}</span>. {1}",
"FILE_ALREADY_EXISTS" : "The {0} <span class='dialog-filename'>{1}</span> already exists.",
"ERROR_CREATING_FILE_TITLE" : "Error creating {0}",
"ERROR_CREATING_FILE" : "An error occurred when trying to create the {0} <span class='dialog-filename'>{1}</span>. {2}",

// Application error strings
"ERROR_IN_BROWSER_TITLE" : "Oops! {APP_NAME} doesn't run in browsers yet.",
Expand Down
29 changes: 16 additions & 13 deletions src/project/ProjectManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1227,15 +1227,21 @@ define(function (require, exports, module) {
};

var errorCallback = function (error) {
if ((error.name === NativeFileError.PATH_EXISTS_ERR) ||
(error.name === NativeFileError.TYPE_MISMATCH_ERR)) {
var entryType = isFolder ? Strings.DIRECTORY : Strings.FILE,
oppositeEntryType = isFolder ? Strings.FILE : Strings.DIRECTORY;
if (error.name === NativeFileError.PATH_EXISTS_ERR) {
Dialogs.showModalDialog(
DefaultDialogs.DIALOG_ID_ERROR,
Strings.INVALID_FILENAME_TITLE,
StringUtils.format(
Strings.FILE_ALREADY_EXISTS,
StringUtils.breakableUrl(data.rslt.name)
)
StringUtils.format(Strings.INVALID_FILENAME_TITLE, entryType),
StringUtils.format(Strings.FILE_ALREADY_EXISTS, entryType,
StringUtils.breakableUrl(data.rslt.name))
);
} else if (error.name === NativeFileError.TYPE_MISMATCH_ERR) {
Dialogs.showModalDialog(
DefaultDialogs.DIALOG_ID_ERROR,
StringUtils.format(Strings.INVALID_FILENAME_TITLE, entryType),
StringUtils.format(Strings.FILE_ALREADY_EXISTS, oppositeEntryType,
StringUtils.breakableUrl(data.rslt.name))
);
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this else branch there is another error dialog that always display "File" in the strings as the code fixed. Maybe this could be fixed here too.

var errString = error.name === NativeFileError.NO_MODIFICATION_ALLOWED_ERR ?
Expand All @@ -1244,12 +1250,9 @@ define(function (require, exports, module) {

Dialogs.showModalDialog(
DefaultDialogs.DIALOG_ID_ERROR,
Strings.ERROR_CREATING_FILE_TITLE,
StringUtils.format(
Strings.ERROR_CREATING_FILE,
StringUtils.breakableUrl(data.rslt.name),
errString
)
StringUtils.format(Strings.ERROR_CREATING_FILE_TITLE, entryType),
StringUtils.format(Strings.ERROR_CREATING_FILE, entryType,
Strings.breakableUrl(data.rslt.name), errString)
);
}

Expand Down