Re: How to convert path through container into standard form?

2022-12-11 Thread Sandor Szatmari via Cocoa-dev
I was thinking that’d break sandbox encapsulation.  But I guess what really 
matters is what you get when you do the reverse and expand the tilde?

> 
> On Dec 11, 2022, at 17:58, Ben Kennedy via Cocoa-dev 
>  wrote:
> 
> 
> 
>> On 11 Dec 2022, at 12:51 pm, Mike Abdullah via Cocoa-dev 
>>  wrote:
>> 
>> Have you tried -URLByResolvingSymlinksInPath? As far as I’m aware, the 
>> Pictures entry inside your container is a symlink to the real thing, so 
>> assuming you have appropriate entitlements, should be possible to resolve it.
> 
> 
> Indeed, it seems to work in a Swift REPL. Issuing...
> 
> (URL(fileURLWithPath: 
> "/Users/ben/Library/Containers/com.apple.ScreenSaver.Engine/Data/Pictures").resolvingSymlinksInPath().path
>  as NSString).abbreviatingWithTildeInPath
> 
> ...yeilds "~/Pictures".
> 
> -ben
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@gmail.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: How to convert path through container into standard form?

2022-12-11 Thread Ben Kennedy via Cocoa-dev


> On 11 Dec 2022, at 12:51 pm, Mike Abdullah via Cocoa-dev 
>  wrote:
> 
> Have you tried -URLByResolvingSymlinksInPath? As far as I’m aware, the 
> Pictures entry inside your container is a symlink to the real thing, so 
> assuming you have appropriate entitlements, should be possible to resolve it.


Indeed, it seems to work in a Swift REPL. Issuing...

(URL(fileURLWithPath: 
"/Users/ben/Library/Containers/com.apple.ScreenSaver.Engine/Data/Pictures").resolvingSymlinksInPath().path
 as NSString).abbreviatingWithTildeInPath

...yeilds "~/Pictures".

-ben

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: How to convert path through container into standard form?

2022-12-11 Thread Sandor Szatmari via Cocoa-dev
Looking back, I guess you’d bump up against the sandbox with this… 

> 
> On Dec 11, 2022, at 16:21, Sandor Szatmari  
> wrote:
> 
> -stringByAbbreviatingWithTildeInPath
> 
> First page in google results
> 
>> On Dec 11, 2022, at 15:06, Gabriel Zachmann via Cocoa-dev 
>>  wrote:
>> 
>> 
>> I have an NSURL * pictures_path;
>> 
>> By default, this is set to 
>> 
>> pictures_path = [ [NSFileManager defaultManager] URLForDirectory: 
>> NSPicturesDirectory
>>inDomain: NSUserDomainMask
>>   appropriateForURL: nil create: NO error: 
>> ];
>> 
>> This works fine.
>> 
>> Occasionally, I am printing a log message, like so:
>> 
>> mesg = [[NSMutableString alloc] initWithString: [mainDirectoryLocation_ 
>> pictures_path] ]; 
>> 
>> and then output that to whatever channel is active (screen or log file).
>> 
>> Now, in cases where pictures_path is still set to the default, 
>> the users sees some thing like:
>> 
>> /Users//Library/Containers/com.apple.ScreenSaver.Engine.legacyScreenSaver/Data/Pictures
>> 
>> which is confusing to the user (and takes up a lot of space).
>> 
>> How can I convert this back to the more human-readable /Users/xx/Pictures  
>> or ~/Pictures ?
>> 
>> I have checked NSURL's doc, but couldn't find a method to convert the path.
>> 
>> 
>> Hints will be appreciated.
>> Best, Gabriel.
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/cocoa-dev/admin.szatmari.net%40gmail.com
>> 
>> This email sent to admin.szatmari@gmail.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: How to convert path through container into standard form?

2022-12-11 Thread Sandor Szatmari via Cocoa-dev
-stringByAbbreviatingWithTildeInPath

First page in google results

> On Dec 11, 2022, at 15:06, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> 
> I have an NSURL * pictures_path;
> 
> By default, this is set to 
> 
>  pictures_path = [ [NSFileManager defaultManager] URLForDirectory: 
> NSPicturesDirectory
> inDomain: NSUserDomainMask
>appropriateForURL: nil create: NO error: 
> ];
> 
> This works fine.
> 
> Occasionally, I am printing a log message, like so:
> 
>  mesg = [[NSMutableString alloc] initWithString: [mainDirectoryLocation_ 
> pictures_path] ]; 
> 
> and then output that to whatever channel is active (screen or log file).
> 
> Now, in cases where pictures_path is still set to the default, 
> the users sees some thing like:
> 
>  
> /Users//Library/Containers/com.apple.ScreenSaver.Engine.legacyScreenSaver/Data/Pictures
> 
> which is confusing to the user (and takes up a lot of space).
> 
> How can I convert this back to the more human-readable /Users/xx/Pictures  or 
> ~/Pictures ?
> 
> I have checked NSURL's doc, but couldn't find a method to convert the path.
> 
> 
> Hints will be appreciated.
> Best, Gabriel.
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@gmail.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: How to convert path through container into standard form?

2022-12-11 Thread Mike Abdullah via Cocoa-dev
Have you tried -URLByResolvingSymlinksInPath? As far as I’m aware, the Pictures 
entry inside your container is a symlink to the real thing, so assuming you 
have appropriate entitlements, should be possible to resolve it.

Mike.

> On 11 Dec 2022, at 10:56, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> 
> I have an NSURL * pictures_path;
> 
> By default, this is set to 
> 
>  pictures_path = [ [NSFileManager defaultManager] URLForDirectory: 
> NSPicturesDirectory
> inDomain: NSUserDomainMask
>appropriateForURL: nil create: NO error: 
> ];
> 
> This works fine.
> 
> Occasionally, I am printing a log message, like so:
> 
>  mesg = [[NSMutableString alloc] initWithString: [mainDirectoryLocation_ 
> pictures_path] ]; 
> 
> and then output that to whatever channel is active (screen or log file).
> 
> Now, in cases where pictures_path is still set to the default, 
> the users sees some thing like:
> 
>  
> /Users//Library/Containers/com.apple.ScreenSaver.Engine.legacyScreenSaver/Data/Pictures
> 
> which is confusing to the user (and takes up a lot of space).
> 
> How can I convert this back to the more human-readable /Users/xx/Pictures  or 
> ~/Pictures ?
> 
> I have checked NSURL's doc, but couldn't find a method to convert the path.
> 
> 
> Hints will be appreciated.
> Best, Gabriel.
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/mabdullah%40karelia.com
> 
> This email sent to mabdul...@karelia.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


How to convert path through container into standard form?

2022-12-11 Thread Gabriel Zachmann via Cocoa-dev

I have an NSURL * pictures_path;

By default, this is set to

  pictures_path = [ [NSFileManager defaultManager] URLForDirectory: 
NSPicturesDirectory
 inDomain: NSUserDomainMask
appropriateForURL: nil create: NO error: 
];

This works fine.

Occasionally, I am printing a log message, like so:

  mesg = [[NSMutableString alloc] initWithString: [mainDirectoryLocation_ 
pictures_path] ];

and then output that to whatever channel is active (screen or log file).

Now, in cases where pictures_path is still set to the default,
the users sees some thing like:

  
/Users//Library/Containers/com.apple.ScreenSaver.Engine.legacyScreenSaver/Data/Pictures

which is confusing to the user (and takes up a lot of space).

How can I convert this back to the more human-readable /Users/xx/Pictures  or 
~/Pictures ?

I have checked NSURL's doc, but couldn't find a method to convert the path.


Hints will be appreciated.
Best, Gabriel.



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com