Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6217625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:27:33+00:00 2026-05-24T07:27:33+00:00

(code examples in macruby syntax) If I create an url with: u1 = NSURL.fileURLWithPath(‘/tmp’)

  • 0

(code examples in macruby syntax)

If I create an url with:

u1 = NSURL.fileURLWithPath('/tmp')

and then try to create an url with symlinks resolved:

u2=u1.URLByResolvingSymlinksInPath

I get back /tmp:

irb(main):010:0> u2.pathComponents
=> ["/", "tmp"]

This is a problem because if I create an NSDirectoryEnumerator with this NSURL (or /var or /etc), and prefetch the NSURLParentDirectoryURLKey, the NSURLs returned will have path /private/tmp/…

I need to get the components of the directory paths that are relative to the root of the NSDirectoryEnumerator. Is there a robust way to do this, other than hardcoded detection of the special cases I know about (which so far are /tmp, /var, and /etc)?

Is anyone aware of other “special” directories on which URLByResolvingSymlinksInPath doesn’t work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T07:27:34+00:00Added an answer on May 24, 2026 at 7:27 am

    I was never able to find a complete answer to this. For my case, I added a method to NSURL that handles /tmp, /var & /etc:

    class NSURL
      def URLByResolvingSymlinksInPathIncludingPrivate
        url = self.URLByResolvingSymlinksInPath
        parts = url.pathComponents
        if (parts.first == '/') && ['tmp', 'var', 'etc'].include?(parts[1])
          url = NSURL.fileURLWithPathComponents(['/', 'private'] + parts[1..-1])
        end
        url
      end
    end
    

    I decided it was best to add an explicit method and not monkeypatch URLByResolvingSymlinksInPath.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Unfortunately I cannot provide any code examples, however I will try and create an
Does anyone have any code examples on how to create controllers that have parameters
I've seen a few JavaScript code examples that use this sort of syntax: function(foo:String)
I have seen recent code examples placing functions inside variables and then calling the
(code examples are python) Lets assume we have a list of percentages that add
Can source code examples be kept in a SQL database while retaining all formatting
Currently I format code examples in my javadoc using the PRE tag e.g.: /**
I have code examples from some of my previous work that help me to
I've seen the code examples on this article , but throwing Controller_Exception_404 produces an
I'm looking for one line code examples in various languages for getting a valid

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.