apple / swift-foundation

The Foundation project
Apache License 2.0
2.29k stars 135 forks source link

Prevent throwing when applying file attributes retrieved via `attributesOfItem(atPath:)` #644

Closed jmschonfeld closed 1 month ago

jmschonfeld commented 1 month ago

There are some scenarios in which you want to copy attributes from one file to another (for example, from within copyItem(atPath:toPath:). However currently, calling setAttributes(_:forItemAtPath:) with attributes retrieved from attributesForItem(atPath:) will throw because we can fetch .creationDate but we cannot set it (yet). Until this functionality is implemented in swift-foundation, we exclude .creationDate from the featureUnsupported check to ensure that applying attributes that Foundation provides will succeed.

This prevents throwing an error from copyItem calls made by SwiftPM when using the new re-cored Foundation

jmschonfeld commented 1 month ago

@swift-ci please test

jmschonfeld commented 1 month ago

@swift-ci please test

jmschonfeld commented 1 month ago

I updated the logic slightly to ensure that creationDate is still a relevant key for FOUNDATION_FRAMEWORK callers