Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split FileManager into Platform Dependent Files #2057

Merged
merged 1 commit into from
Apr 13, 2019

Conversation

gmittert
Copy link
Contributor

@gmittert gmittert commented Apr 2, 2019

Splits the Windows and POSIX specific File Manager implementations into their own files. See #2002 (comment)

Not sure if there's a way to make the diff more readable, but in general, what I've done is copy over the function to win32/POSIX, prefixed the name with an underscore, removed the non applicable #if branch, and have the FileManager version pass through to it.

@gmittert gmittert force-pushed the split branch 3 times, most recently from b7d5af6 to 695f666 Compare April 2, 2019 02:07
@spevans
Copy link
Contributor

spevans commented Apr 2, 2019

Might be worth moving internal class NSURLDirectoryEnumerator : DirectoryEnumerator to the per OS files as well as there looks to be very little shared there.

@spevans
Copy link
Contributor

spevans commented Apr 2, 2019

@swift-ci test

#endif
return urls
}
internal func _urls(for directory: SearchPathDirectory, in domainMask: SearchPathDomainMask) -> [URL] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the per-OS helper functions should be private instead of internal where possible`. These are probably a holdover from when they were first written but may as well fix them now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe most of these need to be internal instead of private since they are used in a file they aren't defined in.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah, good point.


return urls
}
internal func _createDirectory(atPath path: String, withIntermediateDirectories createIntermediates: Bool, attributes: [FileAttributeKey : Any]? = [:]) throws {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a separating blank line between functions

throw _NSErrorWithErrno(errno, reading: false, path: path)
}
})
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs indentation.

return
}

if rmdir(path) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to have lost its _fileSystemRepresentation wrapper from #1994. Did you base this split on the latest version from master?

@gmittert
Copy link
Contributor Author

gmittert commented Apr 2, 2019

  • Did some formatting
  • Fixed the missing fsr, After going through, I pretty sure that it was the only one that got dropped...
  • Also split out the iterators

@spevans
Copy link
Contributor

spevans commented Apr 2, 2019

@swift-ci test

@spevans
Copy link
Contributor

spevans commented Apr 3, 2019

I think the following can be moved into FileManager+POSIX.swift as well

darwinPathURLs
darwinURLS
xdgHomeDirectory
xdgURLs

and wrapped inside a #if canImport(Darwin) / #else / #endif block

@gmittert
Copy link
Contributor Author

gmittert commented Apr 4, 2019

I think the following can be moved into FileManager+POSIX.swift as well

darwinPathURLs
darwinURLS
xdgHomeDirectory
xdgURLs

and wrapped inside a #if canImport(Darwin) / #else / #endif block

Moved, though not in an #if since they're used in places not guarded by an #if

@millenomi
Copy link
Contributor

@swift-ci please test

2 similar comments
@compnerd
Copy link
Member

compnerd commented Apr 9, 2019

@swift-ci please test

@compnerd
Copy link
Member

compnerd commented Apr 9, 2019

@swift-ci please test

@millenomi
Copy link
Contributor

@jmittert I'm okay taking this if you fix the conflicts with the things that are landing.

@gmittert
Copy link
Contributor Author

Alright, rebased!

@spevans
Copy link
Contributor

spevans commented Apr 11, 2019

@swift-ci test

@compnerd
Copy link
Member

@swift-ci please test

@gmittert
Copy link
Contributor Author

These both failed on the Swift test suite

11:11:25 ********************
11:11:25 Failing Tests (2):
11:11:25     Swift(macosx-x86_64) :: IRGen/autorelease_optimized_armv7.sil
11:11:25     Swift(macosx-x86_64) :: IRGen/autorelease_optimized_aarch64.sil

These don't somehow rely on foundation at all do they?

@spevans
Copy link
Contributor

spevans commented Apr 12, 2019

@jmittert The tests have been failing for most of the PRs for unrelated reasons

@compnerd
Copy link
Member

@swift-ci please test

@compnerd compnerd merged commit 591789d into swiftlang:master Apr 13, 2019
@gmittert gmittert deleted the split branch April 15, 2019 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants