[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Embedded Control Chars (fwd)



According to Mark F. Murphy:
> 
> So ultimately, I must have a final process that bundles the product's
> source for each platform.  It is this step I wanted to avoid.
> 
When I read this I had this "Oh!" light bulb go off in my
head.  Here's what the blinding light showed me (before I
went blind):

Why not store all of the files on the Mac.  Write a MacPerl
script which uses BBEdit's capability to read and/or write
Mac, IBM, and Unix file types and have your program simply
create the appropriate output files on an as needed basis
by having BBEdit read in the file and the write it out as
whatever.????

So long as you have your output routines written to handle
the various OS types this should remove the problem.

PS: I think BBEdit figures out what the line endings are by
reading in the whole file and then testing to see how many
\012, \015, and \012\015's there are.  All you have to do
(to convert a file from one format to the other) would be
to read the entire file in, count how many \012s there are,
then how many \015s there are and:

1. If there are only \012s and no \015s then it's Unix.
2. if there are only \015s and no \012s then it's Macintosh.
3. If the two are even, then it's IBM.

So either way.  Use BBEdit or roll your own.

PPS: To read in the entire file...

	@fileStats = stat( "myfile" );
	sysopen( THEFILE, "myfile", O_RDWR ) || die $!;
	sysread( THEFILE, $theInfo, $fileStats[7] )
    close( THEFILE );

Then to write it back out...

	sysopen( THEFILE, "outFile, O_RDWR|O_CREAT ) || die $!;
	syswrite( THEFILE, $theInfo, length($theInfo) );
	close( THEFILE );

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch