removal of NSURL.filePathURL as it serves no purpose without file reference URL in Linux


(Bhaktavatsal R Maram) #1

Hi,

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.

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

[1] https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/#//apple_ref/occ/instp/NSURL/filePathURL
[2] https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/#//apple_ref/occ/instm/NSURL/fileReferenceURL

  • mbvreddy

(Rainer Brockerhoff) #2

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
fileSystemImplementation.

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.

···

On 5/7/16 08:07, Bhaktavatsal R Maram via swift-corelibs-dev wrote:

--
Rainer Brockerhoff <rainer@brockerhoff.net>
Belo Horizonte, Brazil
"In the affairs of others even fools are wise
In their own business even sages err."
http://brockerhoff.net/blog/


(Bhaktavatsal R Maram) #3

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
fileSystemImplementation.

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.

···

On 5/7/16 08:07, Bhaktavatsal R Maram via swift-corelibs-dev wrote:


Rainer Brockerhoff rainer@brockerhoff.net
Belo Horizonte, Brazil
"In the affairs of others even fools are wise
In their own business even sages err."
http://brockerhoff.net/blog/


swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev

To: swift-corelibs-dev@swift.org
From: Rainer Brockerhoff via swift-corelibs-dev
Sent by: swift-corelibs-dev-bounces@swift.org
Date: 05/07/2016 08:35PM
Subject: Re: [swift-corelibs-dev] removal of NSURL.filePathURL as it serves no purpose without file reference URL in Linux

Hi Rainer,

Thank you for your inputs. I’ll implement it to return file URL (as no conversion is required for open source foundation).

-mbvreddy

-----swift-corelibs-dev-bounces@swift.org wrote: -----