File tree Expand file tree Collapse file tree 1 file changed +22
-4
lines changed
Assets/FbxExporters/Editor Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -634,14 +634,32 @@ public static bool FolderAlreadyUnzippedAtPath(string path)
634
634
}
635
635
636
636
/// <summary>
637
- /// Check if the directory has write permission.
638
- /// TODO: find a way to do this that works in Unity
637
+ /// Make sure we can write to this directory.
638
+ /// Try creating a file in path directory, if it raises an error, then we can't
639
+ /// write here.
640
+ /// TODO: find a more reliable way to check this
639
641
/// </summary>
640
- /// <returns><c>true</c>, if has write permission was directoryed , <c>false</c> otherwise.</returns>
642
+ /// <returns><c>true</c>, if possible to write to path , <c>false</c> otherwise.</returns>
641
643
/// <param name="path">Path.</param>
642
644
public static bool DirectoryHasWritePermission ( string path )
643
645
{
644
- return System . IO . Directory . Exists ( path ) ;
646
+ try
647
+ {
648
+ using ( System . IO . FileStream fs = System . IO . File . Create (
649
+ System . IO . Path . Combine (
650
+ path ,
651
+ System . IO . Path . GetRandomFileName ( )
652
+ ) ,
653
+ 1 ,
654
+ System . IO . FileOptions . DeleteOnClose )
655
+ )
656
+ { }
657
+ return true ;
658
+ }
659
+ catch ( Exception )
660
+ {
661
+ return false ;
662
+ }
645
663
}
646
664
647
665
public static void DecompressZip ( string zipPath , string destPath ) {
You can’t perform that action at this time.
0 commit comments