<s> """<STR_LIT>""" <EOL> __version__ = "<STR_LIT>" <EOL> __author__ = "<STR_LIT>" <EOL> import warnings <EOL> warnings . warnpy3k ( "<STR_LIT>" , <EOL> stacklevel = <NUM_LIT:2> ) <EOL> import Carbon . File <EOL> import struct <EOL> from Carbon import Res <EOL> import os <EOL> import sys <EOL> DEBUG = <NUM_LIT:0> <EOL> error = "<STR_LIT>" <EOL> BUFSIZE = <NUM_LIT> <EOL> def mergecfmfiles ( srclist , dst , architecture = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> srclist = list ( srclist ) <EOL> for i in range ( len ( srclist ) ) : <EOL> srclist [ i ] = Carbon . File . pathname ( srclist [ i ] ) <EOL> dst = Carbon . File . pathname ( dst ) <EOL> dstfile = open ( dst , "<STR_LIT:wb>" ) <EOL> rf = Res . FSpOpenResFile ( dst , <NUM_LIT:3> ) <EOL> try : <EOL> dstcfrg = CfrgResource ( ) <EOL> for src in srclist : <EOL> srccfrg = CfrgResource ( src ) <EOL> for frag in srccfrg . fragments : <EOL> if frag . architecture == '<STR_LIT>' and architecture == '<STR_LIT>' : <EOL> continue <EOL> if frag . architecture == '<STR_LIT>' and architecture == '<STR_LIT>' : <EOL> continue <EOL> dstcfrg . append ( frag ) <EOL> frag . copydata ( dstfile ) <EOL> cfrgres = Res . Resource ( dstcfrg . build ( ) ) <EOL> Res . UseResFile ( rf ) <EOL> cfrgres . AddResource ( '<STR_LIT>' , <NUM_LIT:0> , "<STR_LIT>" ) <EOL> finally : <EOL> dstfile . close ( ) <EOL> rf = Res . CloseResFile ( rf ) <EOL> class CfrgResource : <EOL> def __init__ ( self , path = None ) : <EOL> self . version = <NUM_LIT:1> <EOL> self . fragments = [ ] <EOL> self . path = path <EOL> if path is not None and os . path . exists ( path ) : <EOL> currentresref = Res . CurResFile ( ) <EOL> resref = Res . FSpOpenResFile ( path , <NUM_LIT:1> ) <EOL> Res . UseResFile ( resref ) <EOL> try : <EOL> try : <EOL> data = Res . Get1Resource ( '<STR_LIT>' , <NUM_LIT:0> ) . data <EOL> except Res . Error : <EOL> raise Res . Error , "<STR_LIT>" , sys . exc_traceback <EOL> finally : <EOL> Res . CloseResFile ( resref ) <EOL> Res . UseResFile ( currentresref ) <EOL> self . parse ( data ) <EOL> if self . version != <NUM_LIT:1> : <EOL> raise error , "<STR_LIT>" <EOL> def parse ( self , data ) : <EOL> ( res1 , res2 , self . version , <EOL> res3 , res4 , res5 , res6 , <EOL> self . memberCount ) = struct . unpack ( "<STR_LIT>" , data [ : <NUM_LIT:32> ] ) <EOL> data = data [ <NUM_LIT:32> : ] <EOL> while data : <EOL> frag = FragmentDescriptor ( self . path , data ) <EOL> data = data [ frag . memberSize : ] <EOL> self . fragments . append ( frag ) <EOL> def build ( self ) : <EOL> self . memberCount = len ( self . fragments ) <EOL> data = struct . pack ( "<STR_LIT>" , <NUM_LIT:0> , <NUM_LIT:0> , self . version , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , self . memberCount ) <EOL> for frag in self . fragments : <EOL> data = data + frag . build ( ) <EOL> return data <EOL> def append ( self , frag ) : <EOL> self . fragments . append ( frag ) <EOL> class FragmentDescriptor : <EOL> def __init__ ( self , path , data = None ) : <EOL> self . path = path <EOL> if data is not None : <EOL> self . parse ( data ) <EOL> def parse ( self , data ) : <EOL> self . architecture = data [ : <NUM_LIT:4> ] <EOL> ( self . updatelevel , <EOL> self . currentVersion , <EOL> self . oldDefVersion , <EOL> self . stacksize , <EOL> self . applibdir , <EOL> self . fragtype , <EOL> self . where , <EOL> self . offset , <EOL> self . length , <EOL> self . res1 , self . res2 , <EOL> self . memberSize , ) = struct . unpack ( "<STR_LIT>" , data [ <NUM_LIT:4> : <NUM_LIT> ] ) <EOL> pname = data [ <NUM_LIT> : self . memberSize ] <EOL> self . name = pname [ <NUM_LIT:1> : <NUM_LIT:1> + ord ( pname [ <NUM_LIT:0> ] ) ] <EOL> def build ( self ) : <EOL> data = self . architecture <EOL> data = data + struct . pack ( "<STR_LIT>" , <EOL> self . updatelevel , <EOL> self . currentVersion , <EOL> self . oldDefVersion , <EOL> self . stacksize , <EOL> self . applibdir , <EOL> self . fragtype , <EOL> self . where , <EOL> self . offset , <EOL> self . length , <EOL> self . res1 , self . res2 ) <EOL> self . memberSize = len ( data ) + <NUM_LIT:2> + <NUM_LIT:1> + len ( self . name ) <EOL> if self . memberSize % <NUM_LIT:4> : <EOL> self . memberSize = self . memberSize + <NUM_LIT:4> - ( self . memberSize % <NUM_LIT:4> ) <EOL> data = data + struct . pack ( "<STR_LIT>" , self . memberSize , len ( self . name ) ) <EOL> data = data + self . name <EOL> data = data + '<STR_LIT>' * ( self . memberSize - len ( data ) ) <EOL> return data <EOL> def getfragment ( self ) : <EOL> if self . where != <NUM_LIT:1> : <EOL> raise error , "<STR_LIT>" <EOL> f = open ( self . path , "<STR_LIT:rb>" ) <EOL> f . seek ( self . offset ) <EOL> if self . length : <EOL> frag = f . read ( self . length ) <EOL> else : <EOL> frag = f . read ( ) <EOL> f . close ( ) <EOL> return frag <EOL> def copydata ( self , outfile ) : <EOL> if self . where != <NUM_LIT:1> : <EOL> raise error , "<STR_LIT>" <EOL> infile = open ( self . path , "<STR_LIT:rb>" ) <EOL> if self . length == <NUM_LIT:0> : <EOL> infile . seek ( <NUM_LIT:0> , <NUM_LIT:2> ) <EOL> self . length = infile . tell ( ) <EOL> infile . seek ( self . offset ) <EOL> offset = outfile . tell ( ) <EOL> if offset % <NUM_LIT:16> : <EOL> offset = offset + <NUM_LIT:16> - ( offset % <NUM_LIT:16> ) <EOL> outfile . seek ( offset ) <EOL> self . offset = offset <EOL> l = self . length <EOL> while l : <EOL> if l > BUFSIZE : <EOL> outfile . write ( infile . read ( BUFSIZE ) ) <EOL> l = l - BUFSIZE <EOL> else : <EOL> outfile . write ( infile . read ( l ) ) <EOL> l = <NUM_LIT:0> <EOL> infile . close ( ) </s>
