-
Notifications
You must be signed in to change notification settings - Fork 826
Ignore normal directory with dots #397
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
Changes from 6 commits
07fbf83
6073ea0
96e9bbb
80e0cbf
e883566
1e21b1d
3433988
6b30fbd
b24a7bf
6933cde
0f8bc82
d6890dc
fd74ab1
3aac581
9227503
4165ec8
a6b925a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Foundation | ||
import PathKit | ||
|
||
extension Path { | ||
|
||
/// Treat this as a resource instead of a normal directory. | ||
var isNonFolderDirectory: Bool { | ||
|
||
if isFile { | ||
return false | ||
} | ||
|
||
if let uti = try! URL(fileURLWithPath: self.string) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like to get the performance tests in (coming shortly) so this can be tested for performance |
||
.resourceValues(forKeys: [URLResourceKey.typeIdentifierKey]) | ||
.typeIdentifier { | ||
// NOTE: lproj is public.folder | ||
return uti != "public.folder" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If someone looks at this code in three months, it's hard to say what it does. Which types of paths am I ignoring with this expression. Maybe it's worth adding a larger comment where you explain the rationale behind this line. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. Will do. Maybe as a doc-comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in 6933cde |
||
} | ||
|
||
return false | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isNonFolderDirectory
sounds a bit ambiguous. What aboutisGroupDirectory
? That's how Xcode names directories in an Xcode project.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then you could just say
!myPath.isGroupDirectory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand, but I think it's depends on how you look at the problem.
From Xcode perspective,
isGroupDirectory
is maybe straight forward, but this specific functionality is seen outside of Xcode too. That's why I've put this asPathKitExtension
.Also, I actually tried to rename it, and ended up with rather complicated code. (Needed additional
is a directory, but
condition to retrieve non "public.folder" directory.)Therefore, I think it's better to define this way (
isNonFolderDirectory
) in whitelist manner.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about
isFileDirectory
? I agree thatisNonFolderDirectory
is a bit strange of a name. The actual logic doesn't need to changeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 3aac581