diff --git a/.idea/runConfigurations/Build.xml b/.idea/runConfigurations/Build___Test.xml
similarity index 82%
rename from .idea/runConfigurations/Build.xml
rename to .idea/runConfigurations/Build___Test.xml
index 071ad1d..b930ca9 100644
--- a/.idea/runConfigurations/Build.xml
+++ b/.idea/runConfigurations/Build___Test.xml
@@ -1,5 +1,5 @@
-
+
@@ -11,6 +11,7 @@
@@ -18,7 +19,7 @@
true
true
false
- false
+ false
\ No newline at end of file
diff --git a/README.md b/README.md
index b619f87..050a49e 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# XMP Core for Kotlin Multiplatform
-[![Kotlin](https://img.shields.io/badge/kotlin-1.9.10-blue.svg?logo=kotlin)](httpw://kotlinlang.org)
+[![Kotlin](https://img.shields.io/badge/kotlin-1.9.20-blue.svg?logo=kotlin)](httpw://kotlinlang.org)
![JVM](https://img.shields.io/badge/-JVM-gray.svg?style=flat)
![Android](https://img.shields.io/badge/-Android-gray.svg?style=flat)
![macOS](https://img.shields.io/badge/-macOS-gray.svg?style=flat)
@@ -15,7 +15,7 @@ It's part of [Ashampoo Photos](https://ashampoo.com/photos).
## Installation
```
-implementation("com.ashampoo:xmpcore:0.1.6")
+implementation("com.ashampoo:xmpcore:0.1.7")
```
## How to use
diff --git a/build.gradle.kts b/build.gradle.kts
index 332de2c..d09cb6f 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -2,17 +2,17 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework
plugins {
- kotlin("multiplatform") version "1.9.10"
+ kotlin("multiplatform") version "1.9.20"
id("com.android.library") version "7.4.2"
id("maven-publish")
id("signing")
- id("io.gitlab.arturbosch.detekt") version "1.23.1"
+ id("io.gitlab.arturbosch.detekt") version "1.23.3"
id("org.sonarqube") version "4.3.1.3277"
id("org.jetbrains.kotlinx.kover") version "0.6.1"
id("com.asarkar.gradle.build-time-tracker") version "4.3.0"
id("me.qoomon.git-versioning") version "6.4.2"
id("com.goncalossilva.resources") version "0.4.0"
- id("com.github.ben-manes.versions") version "0.48.0"
+ id("com.github.ben-manes.versions") version "0.49.0"
}
repositories {
@@ -22,7 +22,7 @@ repositories {
val productName = "Ashampoo XMP Core"
-val ktorVersion: String = "2.3.4"
+val ktorVersion: String = "2.3.5"
val xmlUtilVersion: String = "0.86.2"
description = productName
@@ -111,7 +111,7 @@ koverMerged {
}
dependencies {
- detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.1")
+ detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.3")
}
kotlin {
@@ -148,8 +148,10 @@ kotlin {
dependencies {
- /* Needed for Charset class. */
- /* Defined as api() to prevent problems when used from a pure-java project. */
+ /*
+ * Needed for Charset class.
+ * Defined as api() to prevent problems when used from a pure-java project.
+ */
api("io.ktor:ktor-io:$ktorVersion")
/* Needed to parse XML and create a DOM Document */
@@ -169,7 +171,7 @@ kotlin {
implementation("com.goncalossilva:resources:0.4.0")
/* Multiplatform file access */
- implementation("org.jetbrains.kotlinx:kotlinx-io-core:0.2.1")
+ implementation("org.jetbrains.kotlinx:kotlinx-io-core:0.3.0")
}
}
diff --git a/gradle.properties b/gradle.properties
index 4831294..40c487c 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,6 +1,7 @@
android.useAndroidX=true
kotlin.code.style=official
kotlin.mpp.androidSourceSetLayoutVersion=2
+kotlin.mpp.applyDefaultHierarchyTemplate=false
kotlin.mpp.enableCInteropCommonization=true
kotlin.mpp.stability.nowarn=true
org.gradle.caching=true
diff --git a/src/commonMain/kotlin/com/ashampoo/xmp/XMPMeta.kt b/src/commonMain/kotlin/com/ashampoo/xmp/XMPMeta.kt
index cdfd6eb..02bdc5e 100644
--- a/src/commonMain/kotlin/com/ashampoo/xmp/XMPMeta.kt
+++ b/src/commonMain/kotlin/com/ashampoo/xmp/XMPMeta.kt
@@ -124,7 +124,7 @@ interface XMPMeta {
* *Note:* Qualifiers are only supported for simple leaf properties.
*
* @param schemaNS The namespace URI for the struct. Has the same usage as in getProperty.
- * @param structName The name of the struct.
+ * @param propName The name of the struct.
* May be a general path expression, must not be `null` or the empty string.
* Has the same namespace prefix usage as propName in `getProperty()`.
* @param qualNS The namespace URI for the qualifier. Has the same URI and prefix usage as the
diff --git a/src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPIteratorImpl.kt b/src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPIteratorImpl.kt
index 104f013..ac3bdf7 100644
--- a/src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPIteratorImpl.kt
+++ b/src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPIteratorImpl.kt
@@ -123,8 +123,10 @@ class XMPIteratorImpl(
else
nodeIterator = NodeIteratorChildren(startNode, initialPath)
- } else
+ } else {
+
nodeIterator = emptySequence().iterator()
+ }
}
override fun skipSubtree() {
diff --git a/src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPMetaImpl.kt b/src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPMetaImpl.kt
index 7a1af52..a6cc49b 100644
--- a/src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPMetaImpl.kt
+++ b/src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPMetaImpl.kt
@@ -153,7 +153,7 @@ class XMPMetaImpl : XMPMeta {
throw XMPException(XMPError.EMPTY_SCHEMA_TEXT, XMPError.BADPARAM)
if (propName.isEmpty())
- throw XMPException("Empty property name", XMPError.BADPARAM)
+ throw XMPException("Can't delete empty property name.", XMPError.BADPARAM)
val propNode = findNode(
xmpTree = this.root,
@@ -299,7 +299,7 @@ class XMPMetaImpl : XMPMeta {
if (specificLang.isEmpty())
throw XMPException("Empty specific language", XMPError.BADPARAM)
- val normalizedGenericLang = if (genericLang != null) normalizeLangValue(genericLang) else null
+ val normalizedGenericLang = genericLang?.let { normalizeLangValue(it) }
val normalizedSpecificLang = normalizeLangValue(specificLang)
val arrayPath = expandXPath(schemaNS, altTextName)
@@ -313,21 +313,18 @@ class XMPMetaImpl : XMPMeta {
return if (match != XMPNodeUtils.CLT_NO_VALUES) {
object : XMPProperty {
- override fun getValue(): String {
- return itemNode!!.value!!
- }
- override fun getOptions(): PropertyOptions {
- return itemNode!!.options
- }
+ override fun getValue(): String =
+ itemNode!!.value!!
- override fun getLanguage(): String {
- return itemNode!!.getQualifier(1).value!!
- }
+ override fun getOptions(): PropertyOptions =
+ itemNode!!.options
- override fun toString(): String {
- return itemNode!!.value.toString()
- }
+ override fun getLanguage(): String =
+ itemNode!!.getQualifier(1).value!!
+
+ override fun toString(): String =
+ itemNode!!.value.toString()
}
} else {
@@ -353,7 +350,7 @@ class XMPMetaImpl : XMPMeta {
if (specificLang.isEmpty())
throw XMPException("Empty specific language", XMPError.BADPARAM)
- val normalizedGenericLang = if (genericLang != null) normalizeLangValue(genericLang) else null
+ val normalizedGenericLang = genericLang?.let { normalizeLangValue(it) }
val normalizedSpecificLang = normalizeLangValue(specificLang)
val arrayPath = expandXPath(schemaNS, altTextName)
@@ -522,21 +519,17 @@ class XMPMetaImpl : XMPMeta {
return object : XMPProperty {
- override fun getValue(): String? {
- return value?.toString()
- }
+ override fun getValue(): String? =
+ value?.toString()
- override fun getOptions(): PropertyOptions {
- return propNode.options
- }
+ override fun getOptions(): PropertyOptions =
+ propNode.options
- override fun getLanguage(): String? {
- return null
- }
+ override fun getLanguage(): String? =
+ null
- override fun toString(): String {
- return value.toString()
- }
+ override fun toString(): String =
+ value.toString()
}
}
diff --git a/src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPNodeUtils.kt b/src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPNodeUtils.kt
index 826ecb0..b84fd7b 100644
--- a/src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPNodeUtils.kt
+++ b/src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPNodeUtils.kt
@@ -353,7 +353,7 @@ object XMPNodeUtils {
val index = when (stepKind) {
XMPPath.ARRAY_INDEX_STEP ->
- findIndexedItem(parentNode, nextStep.name, createNodes)
+ findIndexedItem(parentNode, nextStep.name!!, createNodes)
XMPPath.ARRAY_LAST_STEP ->
parentNode.getChildrenLength()
@@ -418,15 +418,15 @@ object XMPNodeUtils {
* @param createNodes flag if new nodes are allowed to be created.
* @return Returns the index or index = -1 if not found
*/
- private fun findIndexedItem(arrayNode: XMPNode?, segment: String?, createNodes: Boolean): Int {
+ private fun findIndexedItem(arrayNode: XMPNode, segment: String, createNodes: Boolean): Int {
var index: Int
try {
- var segment = segment!!.substring(1, segment.length - 1)
+ val innerSegment = segment.substring(1, segment.length - 1)
- index = segment.toInt()
+ index = innerSegment.toInt()
if (index < 1)
throw XMPException("Array index must be larger than zero", XMPError.BADXPATH)
@@ -435,7 +435,7 @@ object XMPNodeUtils {
throw XMPException("Array index not digits.", XMPError.BADXPATH, ex)
}
- if (createNodes && index == arrayNode!!.getChildrenLength() + 1) {
+ if (createNodes && index == arrayNode.getChildrenLength() + 1) {
// Append a new last + 1 node.
val newItem = XMPNode(XMPConst.ARRAY_ITEM_NAME, null)
diff --git a/src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPNormalizer.kt b/src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPNormalizer.kt
index 7f0fced..d5bb91c 100644
--- a/src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPNormalizer.kt
+++ b/src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPNormalizer.kt
@@ -72,17 +72,15 @@ internal object XMPNormalizer {
val path = expandXPath(XMPConst.NS_XMP_MM, "InstanceID")
val idNode = XMPNodeUtils.findNode(tree, path, true, null)
- if (idNode != null) {
-
- idNode.options = PropertyOptions() // Clobber any existing xmpMM:InstanceID.
- idNode.value = "uuid:$nameStr"
- idNode.removeChildren()
- idNode.removeQualifiers()
+ if (idNode == null)
+ throw XMPException("Failure creating xmpMM:InstanceID", XMPError.INTERNALFAILURE)
- tree.name = null
+ idNode.options = PropertyOptions() // Clobber any existing xmpMM:InstanceID.
+ idNode.value = "uuid:$nameStr"
+ idNode.removeChildren()
+ idNode.removeQualifiers()
- } else
- throw XMPException("Failure creating xmpMM:InstanceID", XMPError.INTERNALFAILURE)
+ tree.name = null
}
}
}
diff --git a/src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPRDFParser.kt b/src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPRDFParser.kt
index 489633b..fc89b8d 100644
--- a/src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPRDFParser.kt
+++ b/src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPRDFParser.kt
@@ -436,8 +436,10 @@ internal object XMPRDFParser {
parseRdfLiteralPropertyElement(xmp, xmpParent, xmlNode, isTopLevel)
- } else
+ } else {
+
parseEmptyPropertyElement(xmp, xmpParent, xmlNode, isTopLevel)
+ }
}
}
@@ -477,7 +479,7 @@ internal object XMPRDFParser {
if (XMPConst.XML_LANG == attribute.nodeName)
addQualifierNode(newCompound, XMPConst.XML_LANG, attribute.value)
else if ("ID" == attribute.localName && XMPConst.NS_RDF == attribute.namespaceURI)
- continue // Ignore all rdf:ID attributes.
+ continue
else
throw XMPException("Invalid attribute for resource property element", XMPError.BADRDF)
}
@@ -582,7 +584,7 @@ internal object XMPRDFParser {
XMPConst.NS_RDF == attribute.namespaceURI &&
("ID" == attribute.localName || "datatype" == attribute.localName)
)
- continue // Ignore all rdf:ID and rdf:datatype attributes.
+ continue
else
throw XMPException("Invalid attribute for literal property element", XMPError.BADRDF)
}
diff --git a/src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPRDFWriter.kt b/src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPRDFWriter.kt
index b47ab56..8e3c6bd 100644
--- a/src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPRDFWriter.kt
+++ b/src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPRDFWriter.kt
@@ -472,8 +472,8 @@ internal class XMPRDFWriter(
/**
* Serializes the general qualifier.
*
- * @param node the root node of the subtree
* @param indent the current indent level
+ * @param node the root node of the subtree
*/
private fun serializeCompactRDFGeneralQualifier(indent: Int, node: XMPNode) {
@@ -555,37 +555,37 @@ internal class XMPRDFWriter(
indent: Int
) {
- var prefix = prefix
- var namespace = namespace
+ var actualPrefix = prefix
+ var actualNamespace = namespace
- if (namespace == null) {
+ if (actualNamespace == null) {
// prefix contains qname, extract prefix and lookup namespace with prefix
- val qname = QName(prefix)
+ val qname = QName(actualPrefix)
if (!qname.hasPrefix())
return
- prefix = qname.prefix!!
+ actualPrefix = qname.prefix!!
// add colon for lookup
- namespace = schemaRegistry.getNamespaceURI("$prefix:")
+ actualNamespace = schemaRegistry.getNamespaceURI("$actualPrefix:")
// prefix w/o colon
- declareNamespace(prefix, namespace, usedPrefixes, indent)
+ declareNamespace(actualPrefix, actualNamespace, usedPrefixes, indent)
}
- if (!usedPrefixes.contains(prefix)) {
+ if (!usedPrefixes.contains(actualPrefix)) {
writeNewline()
writeIndent(indent)
write("xmlns:")
- write(prefix)
+ write(actualPrefix)
write("=\"")
- write(namespace!!)
+ write(actualNamespace!!)
write('"')
- usedPrefixes.add(prefix)
+ usedPrefixes.add(actualPrefix)
}
}
@@ -641,7 +641,7 @@ internal class XMPRDFWriter(
indent: Int
) {
- var indent = indent
+ var actualIndent = indent
var emitEndTag = true
var indentEndTag = true
@@ -654,7 +654,7 @@ internal class XMPRDFWriter(
else if (XMPConst.ARRAY_ITEM_NAME == elemName)
elemName = "rdf:li"
- writeIndent(indent)
+ writeIndent(actualIndent)
write('<')
write(elemName!!)
@@ -702,8 +702,8 @@ internal class XMPRDFWriter(
write(">")
writeNewline()
- indent++
- writeIndent(indent)
+ actualIndent++
+ writeIndent(actualIndent)
write(RDF_STRUCT_START)
write(">")
@@ -713,18 +713,18 @@ internal class XMPRDFWriter(
writeNewline()
- serializeCanonicalRDFProperty(node, useCanonicalRDF, true, indent + 1)
+ serializeCanonicalRDFProperty(node, useCanonicalRDF, true, actualIndent + 1)
for (qualifier in node.getQualifier())
if (!RDF_ATTR_QUALIFIER.contains(qualifier.name))
- serializeCanonicalRDFProperty(qualifier, useCanonicalRDF, false, indent + 1)
+ serializeCanonicalRDFProperty(qualifier, useCanonicalRDF, false, actualIndent + 1)
if (useCanonicalRDF) {
- writeIndent(indent)
+ writeIndent(actualIndent)
write(RDF_STRUCT_END)
writeNewline()
- indent--
+ actualIndent--
}
} else {
@@ -766,15 +766,15 @@ internal class XMPRDFWriter(
// This is an array.
write('>')
writeNewline()
- emitRDFArrayTag(node, true, indent + 1)
+ emitRDFArrayTag(node, true, actualIndent + 1)
if (node.options.isArrayAltText())
XMPNodeUtils.normalizeLangArray(node)
for (child in node.getChildren())
- serializeCanonicalRDFProperty(child, useCanonicalRDF, false, indent + 2)
+ serializeCanonicalRDFProperty(child, useCanonicalRDF, false, actualIndent + 2)
- emitRDFArrayTag(node, false, indent + 1)
+ emitRDFArrayTag(node, false, actualIndent + 1)
}
!hasRDFResourceQual -> {
@@ -788,7 +788,7 @@ internal class XMPRDFWriter(
write(">")
writeNewline()
- writeIndent(indent + 1)
+ writeIndent(actualIndent + 1)
write(RDF_EMPTY_STRUCT)
} else {
@@ -808,8 +808,8 @@ internal class XMPRDFWriter(
write(">")
writeNewline()
- indent++
- writeIndent(indent)
+ actualIndent++
+ writeIndent(actualIndent)
write(RDF_STRUCT_START)
write(">")
@@ -821,13 +821,13 @@ internal class XMPRDFWriter(
writeNewline()
for (child in node.getChildren())
- serializeCanonicalRDFProperty(child, useCanonicalRDF, false, indent + 1)
+ serializeCanonicalRDFProperty(child, useCanonicalRDF, false, actualIndent + 1)
if (useCanonicalRDF) {
- writeIndent(indent)
+ writeIndent(actualIndent)
write(RDF_STRUCT_END)
writeNewline()
- indent--
+ actualIndent--
}
}
@@ -843,7 +843,7 @@ internal class XMPRDFWriter(
throw XMPException("Can't mix rdf:resource and complex fields", XMPError.BADRDF)
writeNewline()
- writeIndent(indent + 1)
+ writeIndent(actualIndent + 1)
write(' ')
write(child.name!!)
write("=\"")
@@ -863,7 +863,7 @@ internal class XMPRDFWriter(
if (emitEndTag) {
if (indentEndTag)
- writeIndent(indent)
+ writeIndent(actualIndent)
write("")
write(elemName)
diff --git a/src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPSchemaRegistryImpl.kt b/src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPSchemaRegistryImpl.kt
index 3a9b39a..51077a3 100644
--- a/src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPSchemaRegistryImpl.kt
+++ b/src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPSchemaRegistryImpl.kt
@@ -64,22 +64,22 @@ object XMPSchemaRegistryImpl : XMPSchemaRegistry {
override fun registerNamespace(namespaceURI: String, suggestedPrefix: String): String {
- var suggestedPrefix = suggestedPrefix
+ var actualSuggestedPrefix = suggestedPrefix
if (namespaceURI.isEmpty())
throw XMPException(XMPError.EMPTY_SCHEMA_TEXT, XMPError.BADPARAM)
- if (suggestedPrefix.isEmpty())
+ if (actualSuggestedPrefix.isEmpty())
throw XMPException("Empty prefix", XMPError.BADPARAM)
- if (suggestedPrefix[suggestedPrefix.length - 1] != ':')
- suggestedPrefix += ':'
+ if (actualSuggestedPrefix[actualSuggestedPrefix.length - 1] != ':')
+ actualSuggestedPrefix += ':'
- if (!isXMLNameNS(suggestedPrefix.substring(0, suggestedPrefix.length - 1)))
+ if (!isXMLNameNS(actualSuggestedPrefix.substring(0, actualSuggestedPrefix.length - 1)))
throw XMPException("The prefix is a bad XML name", XMPError.BADXML)
val registeredPrefix = namespaceToPrefixMap[namespaceURI]
- val registeredNS = prefixToNamespaceMap[suggestedPrefix]
+ val registeredNS = prefixToNamespaceMap[actualSuggestedPrefix]
// Return the actual prefix
if (registeredPrefix != null)
@@ -89,24 +89,24 @@ object XMPSchemaRegistryImpl : XMPSchemaRegistry {
// the namespace is new, but the prefix is already engaged,
// we generate a new prefix out of the suggested
- var generatedPrefix = suggestedPrefix
+ var generatedPrefix = actualSuggestedPrefix
var i = 1
while (prefixToNamespaceMap.containsKey(generatedPrefix)) {
generatedPrefix =
- suggestedPrefix.substring(0, suggestedPrefix.length - 1) + "_" + i + "_:"
+ actualSuggestedPrefix.substring(0, actualSuggestedPrefix.length - 1) + "_" + i + "_:"
i++
}
- suggestedPrefix = generatedPrefix
+ actualSuggestedPrefix = generatedPrefix
}
- prefixToNamespaceMap[suggestedPrefix] = namespaceURI
- namespaceToPrefixMap[namespaceURI] = suggestedPrefix
+ prefixToNamespaceMap[actualSuggestedPrefix] = namespaceURI
+ namespaceToPrefixMap[namespaceURI] = actualSuggestedPrefix
// Return the suggested prefix
- return suggestedPrefix
+ return actualSuggestedPrefix
}
override fun deleteNamespace(namespaceURI: String) {
@@ -122,12 +122,12 @@ object XMPSchemaRegistryImpl : XMPSchemaRegistry {
override fun getNamespaceURI(namespacePrefix: String): String? {
- var namespacePrefix = namespacePrefix
+ var actualNamespacePrefix = namespacePrefix
- if (!namespacePrefix.endsWith(":"))
- namespacePrefix += ":"
+ if (!actualNamespacePrefix.endsWith(":"))
+ actualNamespacePrefix += ":"
- return prefixToNamespaceMap[namespacePrefix]
+ return prefixToNamespaceMap[actualNamespacePrefix]
}
override fun getNamespaces(): Map =
@@ -303,7 +303,8 @@ object XMPSchemaRegistryImpl : XMPSchemaRegistry {
aliasForm.toPropertyOptions(),
null
).getOptions()
- ) else
+ )
+ else
AliasOptions()
if (simpleProperyPattern.matches(aliasProp) || simpleProperyPattern.matches(actualProp))
diff --git a/src/commonTest/kotlin/com/ashampoo/xmp/RewriteXmpTest.kt b/src/commonTest/kotlin/com/ashampoo/xmp/RewriteXmpTest.kt
index a0b5f2a..b731f7f 100644
--- a/src/commonTest/kotlin/com/ashampoo/xmp/RewriteXmpTest.kt
+++ b/src/commonTest/kotlin/com/ashampoo/xmp/RewriteXmpTest.kt
@@ -2,7 +2,9 @@ package com.ashampoo.xmp
import com.ashampoo.xmp.options.SerializeOptions
import com.goncalossilva.resources.Resource
+import kotlinx.io.buffered
import kotlinx.io.files.Path
+import kotlinx.io.files.SystemFileSystem
import kotlinx.io.files.sink
import kotlin.test.Test
import kotlin.test.fail
@@ -55,13 +57,18 @@ class RewriteXmpTest {
if (!equals) {
- Path("build/sample_${index}_formatted_compact.xmp").sink().use {
- it.write(actualCompactXmp.encodeToByteArray())
- }
+ SystemFileSystem
+ .sink(Path("build/sample_${index}_formatted_compact.xmp"))
+ .buffered()
+ .use {
+ it.write(actualCompactXmp.encodeToByteArray())
+ }
- Path("build/sample_${index}_formatted_canonical.xmp").sink().use {
- it.write(actualCanonicalXmp.encodeToByteArray())
- }
+ SystemFileSystem.sink(Path("build/sample_${index}_formatted_canonical.xmp"))
+ .buffered()
+ .use {
+ it.write(actualCanonicalXmp.encodeToByteArray())
+ }
fail("XMP for sample $index looks different after rewrite.")
}
@@ -88,9 +95,12 @@ class RewriteXmpTest {
if (!equals) {
- Path("build/sample_${index}_roundtrip_compact.xmp").sink().use {
- it.write(newXmp.encodeToByteArray())
- }
+ SystemFileSystem
+ .sink(Path("build/sample_${index}_roundtrip_compact.xmp"))
+ .buffered()
+ .use {
+ it.write(newXmp.encodeToByteArray())
+ }
fail("XMP for sample $index looks different after compact roundtrip.")
}
@@ -117,9 +127,12 @@ class RewriteXmpTest {
if (!equals) {
- Path("build/sample_${index}_roundtrip_canonical.xmp").sink().use {
- it.write(newXmp.encodeToByteArray())
- }
+ SystemFileSystem
+ .sink(Path("build/sample_${index}_roundtrip_canonical.xmp"))
+ .buffered()
+ .use {
+ it.write(newXmp.encodeToByteArray())
+ }
fail("XMP for sample $index looks different after canonical roundtrip.")
}
@@ -146,9 +159,12 @@ class RewriteXmpTest {
if (!equals) {
- Path("build/sample_${index}_compact_to_canonical.xmp").sink().use {
- it.write(newXmp.encodeToByteArray())
- }
+ SystemFileSystem
+ .sink(Path("build/sample_${index}_compact_to_canonical.xmp"))
+ .buffered()
+ .use {
+ it.write(newXmp.encodeToByteArray())
+ }
fail("XMP for sample $index looks different after compact to canonical conversion.")
}
@@ -175,9 +191,12 @@ class RewriteXmpTest {
if (!equals) {
- Path("build/sample_${index}_canonical_to_compact.xmp").sink().use {
- it.write(newXmp.encodeToByteArray())
- }
+ SystemFileSystem
+ .sink(Path("build/sample_${index}_canonical_to_compact.xmp"))
+ .buffered()
+ .use {
+ it.write(newXmp.encodeToByteArray())
+ }
fail("XMP for sample $index looks different after canonical to compact conversion.")
}
diff --git a/src/commonTest/kotlin/com/ashampoo/xmp/WriteXmpTest.kt b/src/commonTest/kotlin/com/ashampoo/xmp/WriteXmpTest.kt
index 7eb62b8..fc588f4 100644
--- a/src/commonTest/kotlin/com/ashampoo/xmp/WriteXmpTest.kt
+++ b/src/commonTest/kotlin/com/ashampoo/xmp/WriteXmpTest.kt
@@ -5,7 +5,9 @@ import com.ashampoo.xmp.XMPConst.XMP_DC_SUBJECT
import com.ashampoo.xmp.options.PropertyOptions
import com.ashampoo.xmp.options.SerializeOptions
import com.goncalossilva.resources.Resource
+import kotlinx.io.buffered
import kotlinx.io.files.Path
+import kotlinx.io.files.SystemFileSystem
import kotlinx.io.files.sink
import kotlin.test.Test
import kotlin.test.fail
@@ -43,9 +45,12 @@ class WriteXmpTest {
if (!equals) {
- Path("build/empty.xmp").sink().use {
- it.write(actualXmp.encodeToByteArray())
- }
+ SystemFileSystem
+ .sink(Path("build/empty.xmp"))
+ .buffered()
+ .use {
+ it.write(actualXmp.encodeToByteArray())
+ }
fail("XMP empty.xmp looks different.")
}
@@ -70,9 +75,12 @@ class WriteXmpTest {
if (!equals) {
- Path("build/rating.xmp").sink().use {
- it.write(actualXmp.encodeToByteArray())
- }
+ SystemFileSystem
+ .sink(Path("build/rating.xmp"))
+ .buffered()
+ .use {
+ it.write(actualXmp.encodeToByteArray())
+ }
fail("XMP rating.xmp looks different.")
}
@@ -97,9 +105,12 @@ class WriteXmpTest {
if (!equals) {
- Path("build/new.xmp").sink().use {
- it.write(actualXmp.encodeToByteArray())
- }
+ SystemFileSystem
+ .sink(Path("build/new.xmp"))
+ .buffered()
+ .use {
+ it.write(actualXmp.encodeToByteArray())
+ }
fail("XMP new.xmp looks different.")
}
@@ -146,9 +157,12 @@ class WriteXmpTest {
if (!equals) {
- Path("build/updated.xmp").sink().use {
- it.write(actualXmp.encodeToByteArray())
- }
+ SystemFileSystem
+ .sink(Path("build/updated.xmp"))
+ .buffered()
+ .use {
+ it.write(actualXmp.encodeToByteArray())
+ }
fail("XMP updated.xmp looks different.")
}
diff --git a/src/posixMain/kotlin/com/ashampoo/xmp/main.kt b/src/posixMain/kotlin/com/ashampoo/xmp/Main.kt
similarity index 100%
rename from src/posixMain/kotlin/com/ashampoo/xmp/main.kt
rename to src/posixMain/kotlin/com/ashampoo/xmp/Main.kt