nvzqz/FileKit

Need way to append a path extension without removing anything after a period

JetForMe opened this issue · 1 comments

Setting .pathExtension replaces any possible path extension on the Path, even if it doesn't actually have one (e.g. a file named "Image 2019-09-18 19.43.38.067"). Path needs append(extension: String) or some such.

this replace

file.pathExtension = "myext"

to append to current extension ("" if no ext)

file.pathExtension = file.pathExtension+ "myext"

of make and extension

extension Path {
  mutating func appendToExtension(_ toAppend: String) {
        self.pathExtension = pathExtension + toAppend
    }
}