Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Mac > Mac Programmer Tools > I cant eject cd...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 558 of 630
Post > Topic >>

I cant eject cd wen my application once read from cd.Please Help

by "Noufal" <muhammednoufal@[EMAIL PROTECTED] > Oct 1, 2006 at 10:53 PM

Hai all
 I newbie in cocoa.I am now with font manager devolopment. The proj
want to read font from CD.I can read data from cd and use the data.but
I cant to eject cd wen application loaded and readed once from CD.After
reading  i read font from system font. then also i cant eject cd .CD
can eject only after closing application .
Wen try to close then a dialog box appears with "one application is
using cd close application and try".
I tried by removing all datas from arrays used,but then also cant
eject.

The pgm. work with font is below .please check that i hav missed any
code to be added with this to remove control over directory that is
currently using.

I have no idea about FSRef,FSpath,ATSFontRef.If anyone of the above
want to release or deallocate.I think one of them are continuing
control of cd wen once read data from cd.Wat i will do to eject cd wen
app. is running.Ejecting cd is for changing the cd and try it with
another cd.

Excuse my english .Please help


- (NSMutableArray *)checkFont:(NSString *)path
{
	NSMutableArray *myfonts=nil;
	myfonts=[[NSMutableArray alloc]init];
	[myfonts removeAllObjects];
	NSFont *f=nil;
	CFStringRef fontName=NULL;
	ATSFontContainerRef container;
	FSRef fsRef;
	FSSpec fsSpec;
	FSCatalogInfo catinfo;
	int osstatus = FSPathMakeRef((const UInt8*)[path UTF8String], &fsRef,
								 NULL);
	osstatus =
		FSGetCatalogInfo(&fsRef,kFSCatInfoNone,&catinfo,NULL,&fsSpec,NULL);
	osstatus = ATSFontActivateFromFileSpecification ( &fsSpec,
													  kATSFontContextLocal, kATSFontFormatUnspecified,
													  NULL, kATSOptionFlagsDefault, &container);
	if (osstatus != noErr)
	{
		//NSLog(@[EMAIL PROTECTED]
"Got error %d loading %@[EMAIL PROTECTED]
",osstatus,path);
	}

	else
	{
		int fntcount;
		ItemCount count;
		ByteCount bcount;




		osstatus = ATSFontFindFromContainer (container,
											 kATSOptionFlagsDefault, 0, NULL,&count);
		ATSFontRef *ioArray=(ATSFontRef *)malloc(count * sizeof(ATSFontRef));
		osstatus = ATSFontFindFromContainer (container,
											 kATSOptionFlagsDefault, count, ioArray,&count);


		for (fntcount=0; fntcount < count ; fntcount++ ) {


		osstatus = ATSFontGetName (ioArray[fntcount], kATSOptionFlagsDefault,
								   &fontName);

		if (fontName) f = [NSFont fontWithName:(NSString*)fontName size:24];

		  if ( f != nil )
		  {
			[myfonts addObject:f];

		  }[f release];



		//	osstatus=ATSFontGetFontFamilyResource(ioArray[fntcount],bcount,&iobuffer,&bcount)
		}


		}
	[f release];
	//CFRelease(path);
	return myfonts;
}

- (NSMutableArray *) getFonts:(NSString *)path
{

	//Declaring

	NSFont *getfont;
	NSArray *getArray;
    NSString *getfile;
	NSString *fileandfontname;
	NSMutableArray *fontarray,*getfontarr;
	NSFileManager *fm;
	NSString *locinfo,*userdir;

		//Intializing
	fontarray=[[NSMutableArray alloc] init];
	getfontarr=[[NSMutableArray alloc] init];
	[getfontarr removeAllObjects];
	[fontarray removeAllObjects];
	fm=[NSFileManager defaultManager];
	getArray=[fm directoryContentsAtPath:path];
    userdir=NSHomeDirectory();
	userdir=[userdir stringByAppendingPathComponent:@[EMAIL PROTECTED]
"/Library/Fonts/"];

	int rowcount=0;
    //getting path info

	if ( [path isEqualToString:userdir])
		{
		locinfo=@[EMAIL PROTECTED]
"User";
		}
	else if ([path isEqualToString:@[EMAIL PROTECTED]
"/Network/Library/Fonts/"]) {
		locinfo=@[EMAIL PROTECTED]
"Network";
	}
	else if ([path isEqualToString:@[EMAIL PROTECTED]
"/System/Library/Fonts/"]) {
		locinfo=@[EMAIL PROTECTED]
"System";
	}
	else if ([path isEqualToString:@[EMAIL PROTECTED]
"/Library/Fonts/"]) {
		locinfo=@[EMAIL PROTECTED]
"Library";
	}
	else if ([path isEqualToString:@[EMAIL PROTECTED]
"/Volumes/Summitsft"]) {
		locinfo=@[EMAIL PROTECTED]
"Summitsoft";
	}
	else if ([path  rangeOfString:@[EMAIL PROTECTED]
"macXware Fonts"].length) {
		locinfo=@[EMAIL PROTECTED]
"Summitsoft";
	}
	else {
		locinfo=@[EMAIL PROTECTED]
"Vault";
	}



	int fontcount;
	MDItemRef mdataitem;
	NSString *ftype,*ffoundary;
    NSFontDescriptor *fontdisc;
    NSFontSymbolicTraits fst;
	NSFontFamilyClass ffc;
	int fcval;

	for (rowcount=0; rowcount < [getArray count]; rowcount++)
	{
		//Getting Full file path
		getfile=[getArray objectAtIndex:rowcount];
		getfile=[path stringByAppendingPathComponent:getfile];

		//Calling Function
		getfontarr=[self checkFont:getfile];

		//===================================================================
		//Getting info from file MetaData ,it works 10.4 and above
		mdataitem=MDItemCreate(NULL,(CFStringRef)getfile);
	   //	ftype=(id)MDItemCopyAttribute( mdataitem , kMDItemKind);
	    ffoundary=(id)MDItemCopyAttribute( mdataitem , kMDItemCopyright);

		if (ffoundary == nil )
		ffoundary=@[EMAIL PROTECTED]
"--";

		if (ftype == nil)
		ftype=[self FindTypeByExt:getfile];

				//====================================================================



		for (fontcount=0 ; fontcount < [ getfontarr count] ; fontcount++) {

			getfont=[getfontarr objectAtIndex:fontcount];

		//If the file is font then adding to Array
		if ( getfont != nil )
		{
			//Getting font Descriptor
			fontdisc=[getfont fontDescriptor];
	        fst=[fontdisc symbolicTraits];
		  //	NSLog(@[EMAIL PROTECTED]
"%u",fst);

			fileandfontname=[getfont fontName];
			fileandfontname=[fileandfontname stringByAppendingString:@[EMAIL PROTECTED]
"/"];
			fileandfontname=[fileandfontname stringByAppendingString:[getArray
objectAtIndex:rowcount]];
            fileandfontname=[fileandfontname
stringByAppendingString:@[EMAIL PROTECTED]
"/"];
			fileandfontname=[fileandfontname stringByAppendingString:locinfo];
			fileandfontname=[fileandfontname stringByAppendingString:@[EMAIL PROTECTED]
"/"];
			fileandfontname=[fileandfontname stringByAppendingString:ftype];
			fileandfontname=[fileandfontname stringByAppendingString:@[EMAIL PROTECTED]
"/"];
			fileandfontname=[fileandfontname stringByAppendingString:ffoundary];

			[fontarray addObject:fileandfontname];
		    
		}
		}
		
	
	}

	
	//Returning Objects
	return fontarray;

	
}
 




 4 Posts in Topic:
I cant eject cd wen my application once read from cd.Please Help
"Noufal" <mu  2006-10-01 22:53:02 
Re: I cant eject cd wen my application once read from cd.Please
David Phillip Oster <o  2006-10-02 14:24:41 
Re: I cant eject cd wen my application once read from cd.Please
"Noufal" <mu  2006-10-02 21:28:34 
Re: Another problem again
"Noufal" <mu  2006-10-03 23:57:31 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 2:22:49 CDT 2008.