FLEX-34446 give warning when trying to write to director you don't have permission to do so
diff --git a/installer/src/InstallApacheFlex.mxml b/installer/src/InstallApacheFlex.mxml
index 0b76f4c..bbb9220 100644
--- a/installer/src/InstallApacheFlex.mxml
+++ b/installer/src/InstallApacheFlex.mxml
@@ -1096,14 +1096,27 @@
loader.addEventListener(ErrorEvent.ERROR, handleInstallerXMLError);
loader.addEventListener(IOErrorEvent.IO_ERROR, handleInstallerXMLError);
- loader.load(req);
+ loader.load(req);
}
else {
showDirectoryState();
- }
- }
-
- protected function handleFirstStepNextBtnClick(event:MouseEvent):void {
+ }
+ }
+
+ protected function handleFirstStepNextBtnClick(event:MouseEvent):void
+ {
+ // Quick check to see if the selected directory is writable
+ try {
+ var f:File = new File(_flexHome + File.separator + "flex.txt");
+ checkDirWritable(f);
+ } catch (e:Error) {
+ log(_viewResourceConstants.ERROR_UNABLE_TO_CREATE_TEMP_DIRECTORY);
+ flexSDKTxtInput.errorString = _viewResourceConstants.ERROR_DIR_REQUIRE_ADMIN_RIGHTS;
+ flexSDKTxtInput.prompt = _viewResourceConstants.ERROR_DIR_REQUIRE_ADMIN_RIGHTS;
+ updateActivityStep(_viewResourceConstants.STEP_CREATE_DIRECTORIES, StepItem.ERROR);
+ return;
+ }
+
showOptionsState();
}
@@ -1313,10 +1326,34 @@
file.addEventListener(Event.SELECT, flexSDKDirSelected, false, 0, true);
file.browseForDirectory(_viewResourceConstants.INFO_SELECT_DIRECTORY);
}
-
- protected function flexSDKDirSelected(event:Event):void {
- var selectedDir:File = File(event.target);
+
+ protected function checkDirWritable(file:File):void
+ {
+ var ba:ByteArray = new ByteArray();
+ ba.writeUTFBytes("1");
+ writeFileToDirectory(file, ba);
+ file.deleteFile();
+ }
+
+ protected function flexSDKDirSelected(event:Event):void
+ {
+ var selectedDir:File = File(event.target);
var overlay:Boolean = flexVersion.selectedItem.overlay;
+
+ // Quick check to see if the selected directory is writable
+ try {
+ var f:File = new File(selectedDir.nativePath + File.separator + "flex.txt");
+ checkDirWritable(f);
+ } catch (e:Error) {
+ log(_viewResourceConstants.ERROR_UNABLE_TO_CREATE_TEMP_DIRECTORY);
+ log(_viewResourceConstants.ERROR_DIR_REQUIRE_ADMIN_RIGHTS);
+ flexSDKTxtInput.text = selectedDir.nativePath;
+ flexSDKTxtInput.errorString = _viewResourceConstants.ERROR_DIR_REQUIRE_ADMIN_RIGHTS + " : " + selectedDir.nativePath; // tooltip
+ flexSDKTxtInput.prompt = _viewResourceConstants.ERROR_DIR_REQUIRE_ADMIN_RIGHTS; // field
+ updateActivityStep(_viewResourceConstants.STEP_CREATE_DIRECTORIES, StepItem.ERROR);
+ return;
+ }
+
overlaying = overlay;
if (!overlay)
{
@@ -1329,7 +1366,8 @@
flexSDKTxtInput.prompt = _viewResourceConstants.SELECT_PATH_PROMPT;
} else {
nextBtn.enabled = false;
- flexSDKTxtInput.errorString = _viewResourceConstants.ERROR_DIR_NOT_EMPTY;
+ flexSDKTxtInput.text = selectedDir.nativePath;
+ flexSDKTxtInput.errorString = _viewResourceConstants.ERROR_DIR_NOT_EMPTY + " : " + selectedDir.nativePath;
flexSDKTxtInput.prompt = _viewResourceConstants.ERROR_DIR_NOT_EMPTY;
}
}
diff --git a/installer/src/properties/en_US.properties b/installer/src/properties/en_US.properties
index 0bf9bb7..9432443 100644
--- a/installer/src/properties/en_US.properties
+++ b/installer/src/properties/en_US.properties
@@ -36,6 +36,7 @@
BTN_LABEL_OPEN_APACHE_FLEX_FOLDER=OPEN APACHE FLEX FOLDER
ERROR_CONFIG_XML_LOAD=Error while trying to load XML configuration file:
ERROR_DIR_NOT_EMPTY=The selected directory is not empty
+ERROR_DIR_REQUIRE_ADMIN_RIGHTS=The selected directory requires Administrator rights to write files
ERROR_INVALID_AIR_SDK_URL_MAC=Adobe AIR SDK URL for Mac invalid in configuration file
ERROR_INVALID_AIR_SDK_URL_WINDOWS=Adobe AIR SDK URL for Windows invalid in configuration file
ERROR_INVALID_FLASH_PLAYER_SWC_URL=Flash Player swc URL invalid in configuration file