Skip to content

Commit cffcbdc

Browse files
committed
Version checking
1 parent fdcf929 commit cffcbdc

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

ColorSetKit/ColorSet.swift

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import Cocoa
2727
@objc public class ColorSet: NSObject
2828
{
2929
private static let magic: UInt64 = 0x434F4C4F52534554
30+
private static let major: UInt32 = 1
31+
private static let minor: UInt32 = 2
3032

3133
public static var shared: ColorSet =
3234
{
@@ -127,7 +129,13 @@ import Cocoa
127129
}
128130

129131
let minor = stream.readUInt32()
130-
let n = stream.readUInt64()
132+
133+
if major > ColorSet.major || minor > ColorSet.minor
134+
{
135+
return nil
136+
}
137+
138+
let n = stream.readUInt64()
131139

132140
for _ in 0 ..< n
133141
{
@@ -291,9 +299,9 @@ import Cocoa
291299

292300
let stream = ColorSetStream()
293301

294-
stream += ColorSet.magic /* COLORSET */
295-
stream += UInt32( 1 ) /* Major */
296-
stream += UInt32( 2 ) /* Minor */
302+
stream += ColorSet.magic
303+
stream += UInt32( ColorSet.major )
304+
stream += UInt32( ColorSet.minor )
297305
stream += UInt64( colors.count ) /* Count */
298306

299307
for p in colors

0 commit comments

Comments
 (0)