diff --git a/Sources/PropertyList.swift b/Sources/PropertyList.swift index f876966..171d99c 100644 --- a/Sources/PropertyList.swift +++ b/Sources/PropertyList.swift @@ -112,6 +112,11 @@ open class PropertyList { lineEnding: String? = nil, atomic: Bool = true) throws { let format = format ?? .xml + #if os(Linux) + let writingOptions: Data.WritingOptions = [] + #else + let writingOptions: Data.WritingOptions = atomic && !url.isStdOut ? [.atomicWrite]: [] + #endif if format == .openStep { try XcodeProj(dict: self.dict, format: Format.openStep).write(to: url, format: format, @@ -123,18 +128,10 @@ open class PropertyList { fromPropertyList: dict, format: propertyListformat, options: 0) -#if os(Linux) - try data.write(to: url, options: []) // error no attomic on linux -#else - try data.write(to: url, options: atomic ? [.atomicWrite] : []) -#endif + try data.write(to: url, options: writingOptions) } else if format == .json { let data = try JSONSerialization.data(withJSONObject: dict, options: .prettyPrinted) -#if os(Linux) - try data.write(to: url, options: []) // error no attomic on linux -#else - try data.write(to: url, options: atomic ? [.atomicWrite] : []) -#endif + try data.write(to: url, options: writingOptions) } } @@ -150,3 +147,9 @@ open class PropertyList { } } + +extension URL { + var isStdOut: Bool { + return self.isFileURL && self.path == "/dev/stdout" + } +} \ No newline at end of file diff --git a/Sources/XcodeProj.swift b/Sources/XcodeProj.swift index 10e0152..1eb2cb4 100755 --- a/Sources/XcodeProj.swift +++ b/Sources/XcodeProj.swift @@ -186,7 +186,13 @@ public class XcodeProj: PropertyList { let format = format ?? self.format if format == .openStep { let serializer = OpenStepSerializer(projectName: name, lineEnding: lineEnding, projectFile: self) - try serializer.serialize().write(to: pbxprojURL, atomically: atomic, encoding: .utf8) + let string = try serializer.serialize() + #if os(Linux) + let atomically = false + #else + let atomically = atomic && !pbxprojURL.isStdOut + #endif + try string.write(to: pbxprojURL, atomically: atomically, encoding: .utf8) } else { try super.write(to: pbxprojURL, format: format,