Re: Handling of paths through sandbox

2020-02-12 Thread Quincey Morris via Cocoa-dev
On Feb 12, 2020, at 08:56 , Gabriel Zachmann  wrote:
> 
> So rather than having the last part being chopped off (which is the important 
> part),
> I would like to remove the beginning of the path, since that is unimportant.

For partial paths, you can try converting the URLs to URLComponents, then 
constructing a relative URL whose base URL is the directory you searched in. 
That might give you a relative path that you can display.

If that doesn’t give a suitable result, you’ll have to do a bit of work, but 
not much. Starting from a file URL, starting taking the last component of the 
URL (property “lastPathComponent”), and building it up into a path string. Keep 
removing the last component until the shortened URL equals the pictures 
directory.

That’s a bit hand-wavy on the details, but it shouldn’t be too hard to code.

___

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: Handling of paths through sandbox

2020-02-12 Thread Gabriel Zachmann via Cocoa-dev
>> 
>> The problem is that the path names can get very long.
>> And I am going to show them to the user.
> 
> There is support in AppKit for displaying file paths to the user. 
> Unfortunately it's been

I guess I should have said that I display the paths as a simple text overlay in 
my screensaver while it is running (and displaying images).


Best regards, 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/archive%40mail-archive.com

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


Re: Handling of paths through sandbox

2020-02-12 Thread Jens Alfke via Cocoa-dev


> On Feb 12, 2020, at 8:56 AM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> The problem is that the path names can get very long.
> And I am going to show them to the user.

There is support in AppKit for displaying file paths to the user. Unfortunately 
it's been long enough since I used it that I can't remember what it's called 
:-p Hopefully someone else remembers?

> So rather than having the last part being chopped off (which is the important 
> part),
> I would like to remove the beginning of the path, since that is unimportant.


Generally you'd truncate the middle of the path, since the beginning of the 
path can be very important.

—Jens
___

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: Handling of paths through sandbox

2020-02-12 Thread Gabriel Zachmann via Cocoa-dev
Thanks a lot for your response.

>> Problem is that I can't just do
>> 
>>  [ array_with_all_images addObject: [path substringFromIndex: ([dir_to_scan 
>> length] + 1)] ];
> 
> What is this supposed to be an array of? File names? Partial paths underneath 
> ~/Pictures?

Exactly.

The problem is that the path names can get very long.
And I am going to show them to the user.
So rather than having the last part being chopped off (which is the important 
part),
I would like to remove the beginning of the path, since that is unimportant.

Best regards, Gabriel


> If the latter, why get partial paths at all, why not just make an array of 
> URLs?
> 
> 

___

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