Skip to content

Commit 72e804d

Browse files
committed
added prompt for folder
and function to check if the folder we want to unzip in has write access
1 parent 7515e75 commit 72e804d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Assets/FbxExporters/Editor/InstallIntegration.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,22 @@ class IntegrationsUI
506506
const string MenuItemName1 = "FbxExporters/Install Maya Integration";
507507
const string IntegrationZipPath = "FbxExporters/unityoneclick_for_maya.zip";
508508

509+
private static string DefaultIntegrationSavePath = Application.dataPath;
510+
private static string LastIntegrationSavePath = DefaultIntegrationSavePath;
511+
509512
[MenuItem (MenuItemName1, false, 0)]
510513
public static void OnMenuItem1 ()
511514
{
515+
// prompt user to enter location to unzip file
516+
var unzipFolder = EditorUtility.OpenFolderPanel("Select Location to Save Maya Integration",LastIntegrationSavePath,"");
517+
Debug.Log (unzipFolder);
518+
519+
// check that this is a valid location to unzip the file
520+
521+
522+
// if file already unzipped in this location, then prompt user
523+
// if they would like to continue unzipping or use what is there
524+
512525
// unzip Integration folder
513526
DecompressZip(Application.dataPath + "/" + IntegrationZipPath, Application.dataPath + "/TestIntegrations");
514527
return;
@@ -531,6 +544,21 @@ public static void OnMenuItem1 ()
531544
UnityEditor.EditorUtility.DisplayDialog (title, message, "Ok");
532545
}
533546

547+
private static bool hasWriteAccessToFolder(string folderPath)
548+
{
549+
try
550+
{
551+
// Attempt to get a list of security permissions from the folder.
552+
// This will raise an exception if the path is read only or do not have access to view the permissions.
553+
System.Security.AccessControl.DirectorySecurity ds = System.IO.Directory.GetAccessControl(folderPath);
554+
return true;
555+
}
556+
catch (UnauthorizedAccessException)
557+
{
558+
return false;
559+
}
560+
}
561+
534562
public static void DecompressZip(string zipPath, string destPath){
535563
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
536564
myProcess.StartInfo.FileName = string.Format("\"{0}\"", EditorApplication.applicationContentsPath + "/Tools/7z.exe");

0 commit comments

Comments
 (0)