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

No way to get file base name (filename without extension)? #69

Closed
JetForMe opened this issue Sep 20, 2019 · 4 comments
Closed

No way to get file base name (filename without extension)? #69

JetForMe opened this issue Sep 20, 2019 · 4 comments

Comments

@JetForMe
Copy link

Is there no way to get file base name (filename without extension)?

@lechuckcaptain
Copy link

Something like that should do the trick?

extension Path {

    var fileOnlyName: String {
        guard pathExtension.count > 0 else {
            return fileName
        }

        let extLen = pathExtension.count + 1
        let nameOnlyLen = fileName.count - extLen
        return String(fileName.prefix(nameOnlyLen))
    }
}

@JetForMe
Copy link
Author

Of course I can do that. What I was hoping for was for that to already be included in FileKit.

@lechuckcaptain
Copy link

Sure, just wanted to have a feedback before submitting a pull request 😄

@JetForMe
Copy link
Author

Ah in that case, that seems as good as any other way of doing it.

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

No branches or pull requests

2 participants