[futurebasic] Writing CFArray of CFData elements to disk

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 2007 : Group Archive : Group : All Groups

From: Bernie <fblist.bw@...>
Date: Thu, 24 May 2007 11:29:47 +0100
Good morning boys,

I'm experiencing a problem when writing a CFArray of CFData elements  
to disk. Viewing the file in Property List Editor shows the data  
elements to be empty (<>). Below are simplified examples of my create  
and write functions. Can any of yoos see anything obvious that I'm  
doing wrong?

Full example is at: <http://homepage.ntlworld.com/bernie.w/ 
ReadWriteCFArrayTest FB.zip> (20K)

Cheers

Bernie



'---------------
begin record DBData
dim as CFStringRef string
end record


local mode
local fn CreateArray
'~'1
dim as CFMutableArrayRef array
dim as CFMutableDataRef dataRef
dim as DBData cellData
array = fn CFArrayCreateMutable( 0, 0, fn CFTypeArrayCallBacks() )
long if ( array )
dataRef = fn CFDataCreateMutable( 0, 0 )
long if ( dataRef )
cellData.string = fn CFSTR( "MyData" )
CFDataReplaceBytes( dataRef, 0, sizeof(DBData), cellData, sizeof 
(DBData) )
CFArrayAppendValue( array, dataRef )
CFRelease( dataRef )
end if
end if
end fn = array


local mode
local fn WriteArray( array as CFMutableArrayRef, url as CFURLRef )
'~'1
dim as CFDataRef dataRef
dim as Boolean result : result = _false

dataRef = fn CFPropertyListCreateXMLData( 0, array )
long if ( dataRef )
result = fn CFURLWriteDataAndPropertiesToResource( url, dataRef, 0, #0 )
CFRelease( dataRef )
end if
end fn = result
'---------------