[swift-corelibs-dev] removal of NSURL.filePathURL as it serves no purpose without file reference URL in Linux

Rainer Brockerhoff rainer at brockerhoff.net
Sat May 7 09:59:15 CDT 2016

On 5/7/16 08:07, Bhaktavatsal R Maram via swift-corelibs-dev wrote:
> I'm working on implementation of unimplemented properties in NSURL.swift.
> /public var filePathURL: NSURL?/
> As per specification[1] which says "If the receiver is a file reference URL, 
> this property contains a copy of the URL converted to a file path URL. If the 
> receiver’s URL is a file path URL, this property contains the original URL. If 
> the original URL is not a file URL, or if the resource is not reachable or no 
> longer exists, this property contains |nil|. "
> 'filePathURL' property is to hold copy of file reference URL converted to file 
> path URL.
> for example,
> file reference URL - *file:///.file/id=6571367.3617528/*
> file path URL - *file:///Users/mbvreddy/workarea/swift/MyTest/MyTest.xcodeproj/*
> File reference URL is a special URL on OS X which is of type 
> file:///.file/id=<volume_id>.<file_id>/. And it is not available on Linux. APIs 
> that return file reference URLs [2] on OS X foundation NSURL.fileReferenceURL() 
> is removed from Linux Foundation.

AFAIK this particular format of file reference URLs is an OS X
implementation detail, and should not be relied upon (nor is it, I
think, supported on certain file systems).

One reason for it, no doubt, is to be able to use low-level file system
APIs independently of things like maximum path length or POSIX working
file directory.

Nothing precludes an implementation on another platform that leverages
per-file identifiers analogous to volume and file id — or you may even
have a trivial implementation that just stores the full path from

> So, I think NSURL.filePathURL also should be removed as it serves no purpose 
> without file reference URL. Any comments are appreciated.

I'm not a Linux user but this will probably unduly restrict
cross-platform apps. Using file reference URLs is quite common,
especially if at some point you need a path to pass to a POSIX API.

Rainer Brockerhoff  <rainer at brockerhoff.net>
Belo Horizonte, Brazil
"In the affairs of others even fools are wise
In their own business even sages err."

More information about the swift-corelibs-dev mailing list