Create folders on mac
I'm trying to create folders (and files) on mac in my game in the folder provided by Unity (Application.dataPath) which leads to User/Library/Application Support/Appname
I can create the folders using a simple:
if (!System.IO.Directory.Exists(pathMods))
{
System.IO.Directory.CreateDirectory(pathMods);
}
The folder is created but I can't write anything inside. If I try to manually find the folder using Finder, it says I don't have access to it.
I haven't found any solution on google but it seems to be a pretty simple problem.
I have also tried to call this function with 777 but it didn't work:
private static bool GrantAccess(string fullPath)
{
try
{
#if UNITY_STANDALONE_OSX
sys_chmod(fullPath, 777);
#else
DirectoryInfo dInfo = new DirectoryInfo(fullPath);
DirectorySecurity dSecurity = dInfo.GetAccessControl();
dSecurity.AddAccessRule(new FileSystemAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), FileSystemRights.FullControl, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.NoPropagateInherit, AccessControlType.Allow));
dInfo.SetAccessControl(dSecurity);
#endif
}
catch (PlatformNotSupportedException erreur)
{
try
{
sys_chmod(fullPath, 777);
}
catch (Exception e2)
{
LibTRANSVERSE.Helper.Monitoring.Exception(erreur2, LibTRANSVERSE.Helper.MethodInfoHelper.GetCurrentMethod());
return false;
}
}
catch (Exception e)
{
LibTRANSVERSE.Helper.Monitoring.Exception(erreur, LibTRANSVERSE.Helper.MethodInfoHelper.GetCurrentMethod());
return false;
}
return true;
}
[DllImport("libc", EntryPoint = "chmod", SetLastError = true)]
private static extern int sys_chmod(string path, uint mode);
But it doesn't work.
To be complete all the folders don't have the same permissions for some reasons.
Hello @U$$anonymous$$SDev did you solve this issue?,Hello @U$$anonymous$$SDev did you solve the issue?
Your answer
Follow this Question
Related Questions
How to request Microphone Permisson for Mac OSX Standalone? 2 Answers
DepthTextureMode.Depth on Mac -> streched Image 1 Answer
Unity Player as a OS X framework 0 Answers
Unity Editor 2018.4.20f1 - Editor Window on Macintosh is translucent and empty 0 Answers
Mac Build doesn't open after download 0 Answers