月份:五月 2008

get file’s Full path in Bundle Resource

Posted on Updated on

void GetBoundleResourcePath( char * inResourceName, UInt8 * outPath, size_t outPathSize)
{
CFStringRef url2 = CFStringCreateWithCString(NULL,inResourceName,kCFStringEncodingASCII) ;
CFBundleRef appBundle = ::CFBundleGetMainBundle();
CFURLRef url = ::CFBundleCopyResourceURL( appBundle, url2, NULL, NULL );
unsigned char outpath [1024] ;
memset(outpath, 0,1024);
CFURLGetFileSystemRepresentation(url, true, outpath, 1024) ;
memcpy(outPath,outpath, (1024&gh;outPathSize?outPathSize:1024));
outPath[outPathSize-1] = ‘\\ 0’ ;
CFRelease(url);
CFRelease(url2);
}

廣告

redirect stdout to a file

Posted on

FILE * fp = fopen(“myfile.txt","w+a") ;
int fd= -1;
if ( fp != NULL ) dup2(fd,1) ; // 1 for stdout
if ( fd < 0 ) return false ; // fail
else return true ; // success
close(fd);
fclose(fp);

get applicatoin’s path by Carbon

Posted on

CFURLRef url = CFBundleCopyBundleURL( CFBundleGetMainBundle() );
CFURLCreateCopyDeletingLastPathComponent( url )

to add a launch icon in EeePC

Posted on Updated on

reference:
http://www.weekl.net/blog/?p=12

remember to run /opt/xandros/bin/AsusLauncher
but after you reboot, the new setting doesn’t work.
strange!!