Thanks again, Jacque.

My solution for migrating preference files from the Preferences folder to the 
Container turned out to be quite simple but for some reason I spent a bunch of 
time pondering other more complicated methods. In the end I changed an existing 
function which returns a path to the preferences file and had it first look to 
see if a Container exists. If it doesn’t then it creates the Container but 
still returns the path to the original Preferences folder. (This works in my 
use case because the app's first call to this function will always be to “read” 
the preference file)  Now that the Container exists, all future calls to the 
function will return the Container path… and the original data, having been 
already loaded into the app, is ready to write to (and read from) the new 
Container location.

--
Scott Morrow

Elementary Software
(Now with 20% less chalk dust!)
web       https://elementarysoftware.com/
email     sc...@elementarysoftware.com
booth    1-360-734-4701
------------------------------------------------------

> On Jul 14, 2023, at 4:05 PM, J. Landman Gay via use-livecode 
> <use-livecode@lists.runrev.com> wrote:
> 
> On 7/14/23 4:10 PM, scott--- via use-livecode wrote:
>> If the file (say a preference.txt file) already exists in the Preferences or 
>> App Support folder, are we able to continue writing to it?  In other words, 
>> is this an issue with the creation of the file or also of writing in general?
>> How are you handling this? Are you attempting to write to the Preferences or 
>> App Support folder first… and are you moving existing files to the 
>> “Container” folder?
> 
> That's a very good question and I'm afraid I don't know the answer. It's 
> worrying though, because a couple of my older products need to write to 
> Preferences. Here's what I do know.
> 
> The issue only came up recently. My tester with the problem is on Ventura but 
> I suspect it's a little older than that.
> 
> In the past I always wrote files to Preferences without issues. For my 
> current project there was already a prefs file there and it worked. But it 
> also worked if I put it directly in App Support, and also worked if I made a 
> container. In fact, it worked anywhere because it's my machine. Not so for 
> others.
> 
> For the tester, I originally tried to create and write the file in 
> Preferences as usual. It didn't work and no file was created. Another tester, 
> also on Ventura, had the Mac ask for permissions, he gave it, and it worked. 
> Everything else I subsequently tried also worked for him.
> 
> Next, I changed the app to write directly to Application Support. Same 
> problem, no file was created, the Mac didn't ask for permission. So I changed 
> it again to create a folder in Application Support with the name of the app 
> and put the prefs file in there. Same failure. Finally, I created the 
> container folder in ~/Library/Conainers and bingo, success.
> 
> The tester who gave permissions and had no trouble at any point, including 
> reading and writing to the container.
> 
> Since I can't test on my own machine, I'm waiting for someone who has my 
> older products to tell me there's a problem. Or I'll lean on my husband to 
> try it. Husbands are good for things like that.
> 
> 
> -- 
> Jacqueline Landman Gay         |     jac...@hyperactivesw.com
> HyperActive Software           |     http://www.hyperactivesw.com



_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to