Windows Folder Permissions
-
I'm using a script to check folder permissions before downloading a file. This works fine on OSX but not on Windows. The script should display a warning if there are no write permissions in the destination folder, but on windows it skips that part, displays nothing and the file is not downloaded. Code below. @d-healey I think you're using this function too - are you having success on Windows with it?
inline function startDownload() { Engine.showYesNoWindow("SELECT FOLDER", "SELECT WHERE YOU WANT TO STORE THE SAMPLES", function(response) { if (response) { FileSystem.browseForDirectory(downloadsFolder, function(dir) { if (isDefined(dir) && dir.isDirectory()) { if (dir.hasWriteAccess()) { Server.setBaseURL("https://linkylink.com"); var f = dir.getChildFile("SAMPLES.zip"); if(f.isFile()) { f.deleteFileOrDirectory(); download = Server.downloadFile(url, {}, f, downloadCallback); } else { download = Server.downloadFile(url, {}, f, downloadCallback); } } else { Label1.set("text", "PERMISSIONS ERROR!"); } d = dir; } }); } }); }
-
This is what I'm doing
if (isDefined(dir) && dir.isDirectory()) { if (!dir.hasWriteAccess()) return MessageHandler.showMessage("Unwritable Directory", "You do not have write permission for the selected directory. Please choose a different one.", 1);
-
@DanH Not sure I ever tested this in Windows BTW, so it's possible it doesn't work there.
-
@d-healey yes, annoyingly it doesn't!
-
@DanH Very easy way to test it.
const dir = FileSystem.getFolder(FileSystem.Downloads); Console.print(dir.hasWriteAccess()); // If you get a 1 it works.
-
@d-healey looks like I've been here before
https://forum.hise.audio/topic/6404/downloading-permissions/5?_=1671616793197 -
@DanH Did you try the test script above? Are you sure you have write permission for the directory you're selecting?
-
@d-healey not yet I'm exporting right now. But I'm trying to save into a folder that I don't have permissions for in order to execute my error dialogue so the user know's what's going on.
-
@DanH said in Windows Folder Permissions:
@d-healey not yet I'm exporting right now. But I'm trying to save into a folder that I don't have permissions for in order to execute my error dialogue so the user know's what's going on.
make sure you are NOT running as an Admin then....as you will have a lot of permissions by default if you are.
-
@Lindon I've created a special folder with no permissions at all to test with. Doesn't matter if I'm admin or not. The point is that the script doesn't run the 'else' command after checking permissions.
I just rechecked the Admin Permissions box in the project settings again and now when I open my standalone app I get the generic windows User Account Control message which is interesting (Do you want to allow this app from an unknown publisher to make changes to your device?). It still doesn't solve the permissions script, however.
As my other thread details if you double click on the folder you are trying to save to (in the Windows save to dialogue) it will display a permissions error (made by @Christoph-Hart I assume). However I assume like me most people will click once on the folder and then click 'Select Folder' button (in the Windows browser I mean).
Would be great if this permissions error would show after hitting the 'Select Folder' button as well.
-
@DanH Yep I can confirm this issue. But it's not a HISE issue, it's a JUCE issue, and an old one - https://forum.juce.com/t/file-haswriteaccess-does-not-check-permissions/31340
-
@d-healey but it does work if you double click on the folder...
-
@DanH Yes, but that's unrelated to JUCE.
-
@d-healey you think that's a Windows message?
-
@DanH Show me a screenshot please so I know we're talking about the same thing.
-
@d-healey how does one screenshot windows?
-
@DanH Press the Prnt Scrn button on your keyboard or use the Snipping Tool.
-
@d-healey had to take a photo in the end
-
@DanH Yeah that's a Window's message from Explorer.
-
@d-healey ok, thanks!