예제 #1
0
char *read_setting_s(void *handle, char const *key, char *buffer, int buflen) {
    int fd;
    Handle h;
    size_t len;
    Str255 pkey;

    if (handle == NULL) goto out;
    fd = *(int *)handle;
    UseResFile(fd);
    if (ResError() != noErr) goto out;
    c2pstrcpy(pkey, key);
    h = Get1NamedResource(FOUR_CHAR_CODE('TEXT'), pkey);
    if (h == NULL) goto out;

    len = GetHandleSize(h);
    if (len + 1 > buflen) goto out;
    memcpy(buffer, *h, len);
    buffer[len] = '\0';

    ReleaseResource(h);
    if (ResError() != noErr) goto out;
    return buffer;

  out:
    return NULL;
}
void InfoMsg(const char *string){
	Str255 msg;
	c2pstrcpy(msg, string);

	SInt16 ret;
	StandardAlert(kAlertNoteAlert, msg, NULL, NULL, &ret);
}
void ErrorMsg(const char *string){
	Str255 msg;
	c2pstrcpy(msg, string);

	SInt16 ret;
	StandardAlert(kAlertStopAlert, msg, NULL, NULL, &ret);
}
예제 #4
0
void *wxDynamicLibrary::DoGetSymbol(const wxString &name, bool *success) const
{
    wxCHECK_MSG( IsLoaded(), NULL,
                 _T("Can't load symbol from unloaded library") );

    void    *symbol = 0;

    wxUnusedVar(symbol);
#if defined(__WXMAC__) && !defined(__DARWIN__)
    Ptr                 symAddress;
    CFragSymbolClass    symClass;
    Str255              symName;
#if TARGET_CARBON
    c2pstrcpy( (StringPtr) symName, name.fn_str() );
#else
    strcpy( (char *)symName, name.fn_str() );
    c2pstr( (char *)symName );
#endif
    if( FindSymbol( m_handle, symName, &symAddress, &symClass ) == noErr )
        symbol = (void *)symAddress;
#elif defined(__WXPM__) || defined(__EMX__)
    DosQueryProcAddr( m_handle, 1L, (PSZ)name.c_str(), (PFN*)symbol );
#else
    symbol = RawGetSymbol(m_handle, name);
#endif

    if ( success )
        *success = symbol != NULL;

    return symbol;
}
void WarningMsg(const char *string){
	Str255 msg;
	c2pstrcpy(msg, string);

	SInt16 ret;
	StandardAlert(kAlertCautionAlert, msg, NULL, NULL, &ret);
}
예제 #6
0
static gboolean
device_select (GstOSXVideoSrc * src)
{
  Str63 pstr;
  ComponentResult err;
  gchar *sgname;
  int inputIndex;

  /* if there's no device id set, attempt to select default device */
  if (!src->device_id && !device_set_default (src))
    return FALSE;

  if (!parse_device_id (src->device_id, &sgname, &inputIndex)) {
    GST_ERROR_OBJECT (src, "unable to parse device id: [%s]", src->device_id);
    return FALSE;
  }

  c2pstrcpy (pstr, sgname);
  g_free (sgname);

  err = SGSetChannelDevice (src->video_chan, (StringPtr) & pstr);
  if (err != noErr) {
    GST_ERROR_OBJECT (src, "SGSetChannelDevice returned %d", (int) err);
    return FALSE;
  }

  err = SGSetChannelDeviceInput (src->video_chan, inputIndex);
  if (err != noErr) {
    GST_ERROR_OBJECT (src, "SGSetChannelDeviceInput returned %d", (int) err);
    return FALSE;
  }

  return TRUE;
}
예제 #7
0
void write_setting_i(void *handle, char const *key, int value) {
    int fd = *(int *)handle;
    Handle h;
    int id;
    OSErr error;
    Str255 pkey;

    UseResFile(fd);
    if (ResError() != noErr)
        fatalbox("Failed to open saved session (%d)", ResError());

    /* XXX assume all systems have the same "int" format */
    error = PtrToHand(&value, &h, sizeof(int));
    if (error != noErr)
	fatalbox("Failed to allocate memory (%d)", error);

    /* Put the data in a resource. */
    id = Unique1ID(FOUR_CHAR_CODE('Int '));
    if (ResError() != noErr)
	fatalbox("Failed to get ID for resource %s (%d)", key, ResError());
    c2pstrcpy(pkey, key);
    AddResource(h, FOUR_CHAR_CODE('Int '), id, pkey);
    if (ResError() != noErr)
	fatalbox("Failed to add resource %s (%d)", key, ResError());
}
예제 #8
0
static void mac_config(int midsession)
{
    Session *s;
    WinInfo *wi;
    Str255 mactitle;
    char *str;

    if (midsession) {
        s = mac_windowsession(FrontWindow());
    } else {  
        s = snew(Session);
        memset(s, 0, sizeof(*s));
        do_defaults(NULL, &s->cfg);
        s->hasfile = FALSE;
	s->session_closed = FALSE;
    }

    /* Copy the configuration somewhere else in case this is a *
     * reconfiguration and the user cancels the operation      */

    s->temp_cfg = s->cfg;

    if (HAVE_COLOR_QD())
	s->settings_window = GetNewCWindow(wSettings, NULL, (WindowPtr)-1);
    else
	s->settings_window = GetNewWindow(wSettings, NULL, (WindowPtr)-1);

    s->ctrlbox = ctrl_new_box();
    setup_config_box(s->ctrlbox, midsession, 0, 0);

    s->settings_ctrls.data = &s->temp_cfg;
    if (midsession)
        s->settings_ctrls.end = &mac_enddlg_reconfig;
    else
        s->settings_ctrls.end = &mac_enddlg_config;

    macctrl_layoutbox(s->ctrlbox, s->settings_window, &s->settings_ctrls);

    wi = snew(WinInfo);
    memset(wi, 0, sizeof(*wi));
    wi->s = s;
    wi->mcs = &s->settings_ctrls;
    wi->wtype = wSettings;
    wi->update = &macctrl_update;
    wi->click = &macctrl_click;
    wi->key = &macctrl_key;
    wi->activate = &macctrl_activate;
    wi->adjustmenus = &macctrl_adjustmenus;
    wi->close = &mac_closedlg;
    SetWRefCon(s->settings_window, (long)wi);
    if (midsession)
        str = dupprintf("%s Reconfiguration", appname);
    else
        str = dupprintf("%s Configuration", appname);
    c2pstrcpy(mactitle, str);
    sfree(str);
    SetWTitle(s->settings_window, mactitle);
    ShowWindow(s->settings_window);
}
예제 #9
0
HX_RESULT CHXString::MakeStr255(Str255& outPascalString) const
{
    UINT32 len = GetLength();

    if (m_pRep)
        c2pstrcpy(outPascalString, m_pRep->GetBuffer());

    return (len <= 255 ? HXR_OK : HXR_FAIL);
}
예제 #10
0
파일: macmisc.c 프로젝트: rdebath/sgt
Filename filename_from_str(const char *str)
{
    Filename ret;
    Str255 tmp;

    /* XXX This fails for filenames over 255 characters long. */
    c2pstrcpy(tmp, str);
    FSMakeFSSpec(0, 0, tmp, &ret.fss);
    return ret;
}
예제 #11
0
void write_setting_filename(void *handle, const char *key, Filename fn)
{
    int fd = *(int *)handle;
    AliasHandle h;
    int id;
    OSErr error;
    Str255 pkey;

    UseResFile(fd);
    if (ResError() != noErr)
        fatalbox("Failed to open saved session (%d)", ResError());

    if (filename_is_null(fn)) {
	/* Generate a special "null" alias */
	h = (AliasHandle)NewHandle(sizeof(**h));
	if (h == NULL)
	    fatalbox("Failed to create fake alias");
	(*h)->userType = 'pTTY';
	(*h)->aliasSize = sizeof(**h);
    } else {
	error = NewAlias(NULL, &fn.fss, &h);
	if (error == fnfErr) {
	    /*
	     * NewAlias can't create an alias for a nonexistent file.
	     * Create an alias for the directory, and record the
	     * filename as well.
	     */
	    FSSpec tmpfss;

	    FSMakeFSSpec(fn.fss.vRefNum, fn.fss.parID, NULL, &tmpfss);
	    error = NewAlias(NULL, &tmpfss, &h);
	    if (error != noErr)
		fatalbox("Failed to create alias");
	    (*h)->userType = 'pTTY';
	    SetHandleSize((Handle)h, (*h)->aliasSize + fn.fss.name[0] + 1);
	    if (MemError() != noErr)
		fatalbox("Failed to create alias");
	    memcpy((char *)*h + (*h)->aliasSize, fn.fss.name,
		   fn.fss.name[0] + 1);
	}
	if (error != noErr)
	    fatalbox("Failed to create alias");
    }
    /* Put the data in a resource. */
    id = Unique1ID(rAliasType);
    if (ResError() != noErr)
	fatalbox("Failed to get ID for resource %s (%d)", key, ResError());
    c2pstrcpy(pkey, key);
    AddResource((Handle)h, rAliasType, id, pkey);
    if (ResError() != noErr)
	fatalbox("Failed to add resource %s (%d)", key, ResError());
}
예제 #12
0
I_Location_Ptr Location_Disk_FSSpec::get_ChildLocation( const char* inName ) const
{
	const FSSpec* curr = get_FSSpec();

	vint32 DirID;
	bool IsDir;
	GetDirectoryID( curr->vRefNum, curr->parID, curr->name, &DirID, &IsDir );

	Str255 pasName;
	c2pstrcpy(inName, pasName);
	
	FSSpec childSpec;
	OSErr err = FSMakeFSSpec( curr->vRefNum, DirID, pasName, &childSpec );
	argused1(err);

	return new Location_Disk_FSSpec( &childSpec );
}
예제 #13
0
void del_settings(char const *sessionname) {
    OSErr error;
    FSSpec sessfile;
    short sessVRefNum;
    long sessDirID;
    Str255 psessionname;

    error = get_session_dir(kDontCreateFolder, &sessVRefNum, &sessDirID);

    c2pstrcpy(psessionname, sessionname);
    error = FSMakeFSSpec(sessVRefNum, sessDirID, psessionname, &sessfile);
    if (error != noErr) goto out;

    error = FSpDelete(&sessfile);
    return;
  out:
    fatalbox("Delete session failed (%d)", error);
}
예제 #14
0
int read_setting_fontspec(void *handle, const char *name, FontSpec *result)
{
    char *settingname;
    FontSpec ret;
    char tmp[256];

    if (!read_setting_s(handle, name, tmp, sizeof(tmp)))
	return 0;
    c2pstrcpy(ret.name, tmp);
    settingname = dupcat(name, "Face", NULL);
    ret.face = read_setting_i(handle, settingname, 0);
    sfree(settingname);
    settingname = dupcat(name, "Height", NULL);
    ret.size = read_setting_i(handle, settingname, 0);
    sfree(settingname);
    if (ret.size == 0) return 0;
    *result = ret;
    return 1;
}
예제 #15
0
void *open_settings_r(char const *sessionname)
{
    short sessVRefNum;
    long sessDirID;
    FSSpec sessfile;
    OSErr error;
    Str255 psessionname;

    error = get_session_dir(kDontCreateFolder, &sessVRefNum, &sessDirID);

    if (!sessionname || !*sessionname)
	sessionname = "Default Settings";
    c2pstrcpy(psessionname, sessionname);
    error = FSMakeFSSpec(sessVRefNum, sessDirID, psessionname, &sessfile);
    if (error != noErr) goto out;
    return open_settings_r_fsp(&sessfile);

  out:
    return NULL;
}
예제 #16
0
int read_setting_i(void *handle, char const *key, int defvalue) {
    int fd;
    Handle h;
    int value;
    Str255 pkey;

    if (handle == NULL) goto out;
    fd = *(int *)handle;
    UseResFile(fd);
    if (ResError() != noErr) goto out;
    c2pstrcpy(pkey, key);
    h = Get1NamedResource(FOUR_CHAR_CODE('Int '), pkey);
    if (h == NULL) goto out;
    value = *(int *)*h;
    ReleaseResource(h);
    if (ResError() != noErr) goto out;
    return value;

  out:
    return defvalue;
}
예제 #17
0
int read_setting_filename(void *handle, const char *key, Filename *result)
{
    int fd;
    AliasHandle h;
    Boolean changed;
    OSErr err;
    Str255 pkey;

    if (handle == NULL) goto out;
    fd = *(int *)handle;
    UseResFile(fd);
    if (ResError() != noErr) goto out;
    c2pstrcpy(pkey, key);
    h = (AliasHandle)Get1NamedResource(rAliasType, pkey);
    if (h == NULL) goto out;
    if ((*h)->userType == 'pTTY' && (*h)->aliasSize == sizeof(**h))
	memset(result, 0, sizeof(*result));
    else {
	err = ResolveAlias(NULL, h, &result->fss, &changed);
	if (err != noErr && err != fnfErr) goto out;
	if ((*h)->userType == 'pTTY') {
	    long dirid;
	    StrFileName fname;

	    /* Tail of record is pascal string contaning leafname */
	    if (FSpGetDirID(&result->fss, &dirid, FALSE) != noErr) goto out;
	    memcpy(fname, (char *)*h + (*h)->aliasSize,
		   GetHandleSize((Handle)h) - (*h)->aliasSize);
	    err = FSMakeFSSpec(result->fss.vRefNum, dirid, fname,
			       &result->fss);
	    if (err != noErr && err != fnfErr) goto out;
	}
    }
    ReleaseResource((Handle)h);
    if (ResError() != noErr) goto out;
    return 1;

  out:
    return 0;
}
예제 #18
0
/*
 * NB: Destination file must exist.
 */
void *open_settings_w_fsp(FSSpec *dstfile)
{
    short tmpVRefNum;
    long tmpDirID;
    struct write_settings *ws;
    OSErr error;
    Str255 tmpname;

    ws = snew(struct write_settings);
    ws->dstfile = *dstfile;

    /* Create a temporary file to save to first. */
    error = FindFolder(ws->dstfile.vRefNum, kTemporaryFolderType,
		       kCreateFolder, &tmpVRefNum, &tmpDirID);
    if (error != noErr) goto out;
    c2pstrcpy(tmpname, tmpnam(NULL));
    error = FSMakeFSSpec(tmpVRefNum, tmpDirID, tmpname, &ws->tmpfile);
    if (error != noErr && error != fnfErr) goto out;
    if (error == noErr) {
	error = FSpDelete(&ws->tmpfile);
	if (error != noErr) goto out;
    }
    FSpCreateResFile(&ws->tmpfile, PUTTY_CREATOR, SESS_TYPE, smSystemScript);
    if ((error = ResError()) != noErr) goto out;

    ws->fd = FSpOpenResFile(&ws->tmpfile, fsWrPerm);
    if (ws->fd == -1) {error = ResError(); goto out;}

    /* Set up standard resources.  Doesn't matter if these fail. */
    copy_resource('STR ', -16396);
    copy_resource('TMPL', TMPL_Int);

    return ws;

  out:
    safefree(ws);
    fatalbox("Failed to open session for write (%d)", error);
}
예제 #19
0
void *open_settings_w(char const *sessionname, char **errmsg) {
    short sessVRefNum;
    long sessDirID;
    OSErr error;
    Str255 psessionname;
    FSSpec dstfile;

    *errmsg = NULL;

    error = get_session_dir(kCreateFolder, &sessVRefNum, &sessDirID);
    if (error != noErr) return NULL;

    if (!sessionname || !*sessionname)
	sessionname = "Default Settings";
    c2pstrcpy(psessionname, sessionname);
    error = FSMakeFSSpec(sessVRefNum, sessDirID, psessionname, &dstfile);
    if (error == fnfErr) {
	FSpCreateResFile(&dstfile, PUTTY_CREATOR, SESS_TYPE, smSystemScript);
	if ((error = ResError()) != noErr) return NULL;
    } else if (error != noErr) return NULL;

    return open_settings_w_fsp(&dstfile);
}
예제 #20
0
void write_setting_s(void *handle, char const *key, char const *value) {
    int fd = *(int *)handle;
    Handle h;
    int id;
    OSErr error;
    Str255 pkey;

    UseResFile(fd);
    if (ResError() != noErr)
        fatalbox("Failed to open saved session (%d)", ResError());

    error = PtrToHand(value, &h, strlen(value));
    if (error != noErr)
	fatalbox("Failed to allocate memory");
    /* Put the data in a resource. */
    id = Unique1ID(FOUR_CHAR_CODE('TEXT'));
    if (ResError() != noErr)
	fatalbox("Failed to get ID for resource %s (%d)", key, ResError());
    c2pstrcpy(pkey, key);
    AddResource(h, FOUR_CHAR_CODE('TEXT'), id, pkey);
    if (ResError() != noErr)
	fatalbox("Failed to add resource %s (%d)", key, ResError());
}
void ONScripterLabel::searchSaveFile( SaveFileInfo &save_file_info, int no )
{
    char file_name[256];

    bool use_fullwidth = (script_h.system_menu_script == ScriptHandler::JAPANESE_SCRIPT);
    script_h.getStringFromInteger( save_file_info.sjis_no, no,
                                  (num_save_file >= 10)?2:1,
                                  false, use_fullwidth );
#if defined(LINUX) || defined(MACOSX)
    if (script_h.savedir)
        sprintf( file_name, "%ssave%d.dat", script_h.savedir, no );
    else
        sprintf( file_name, "%ssave%d.dat", script_h.save_path, no );
    struct stat buf;
    struct tm *tm;
    if ( stat( file_name, &buf ) != 0 ){
        save_file_info.valid = false;
        return;
    }
    time_t mtime = buf.st_mtime;
    tm = localtime( &mtime );

    save_file_info.month  = tm->tm_mon + 1;
    save_file_info.day    = tm->tm_mday;
    save_file_info.hour   = tm->tm_hour;
    save_file_info.minute = tm->tm_min;
#elif defined(WIN32)
    if (script_h.savedir)
        sprintf( file_name, "%ssave%d.dat", script_h.savedir, no );
    else
        sprintf( file_name, "%ssave%d.dat", script_h.save_path, no );
    HANDLE  handle;
    FILETIME    tm, ltm;
    SYSTEMTIME  stm;

    handle = CreateFile( file_name, GENERIC_READ, 0, NULL,
                         OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
    if ( handle == INVALID_HANDLE_VALUE ){
        save_file_info.valid = false;
        return;
    }

    GetFileTime( handle, NULL, NULL, &tm );
    FileTimeToLocalFileTime( &tm, &ltm );
    FileTimeToSystemTime( &ltm, &stm );
    CloseHandle( handle );

    save_file_info.month  = stm.wMonth;
    save_file_info.day    = stm.wDay;
    save_file_info.hour   = stm.wHour;
    save_file_info.minute = stm.wMinute;
#elif defined(MACOS9)
    if (script_h.savedir)
        sprintf( file_name, "%ssave%d.dat", script_h.savedir, no );
    else
        sprintf( file_name, "%ssave%d.dat", script_h.save_path, no );
	CInfoPBRec  pb;
	Str255      p_file_name;
	FSSpec      file_spec;
	DateTimeRec tm;
	c2pstrcpy( p_file_name, file_name );
	if ( FSMakeFSSpec(0, 0, p_file_name, &file_spec) != noErr ){
		save_file_info.valid = false;
		return;
	}
	pb.hFileInfo.ioNamePtr = file_spec.name;
	pb.hFileInfo.ioVRefNum = file_spec.vRefNum;
	pb.hFileInfo.ioFDirIndex = 0;
	pb.hFileInfo.ioDirID = file_spec.parID;
	if (PBGetCatInfoSync(&pb) != noErr) {
		save_file_info.valid = false;
		return;
	}
	SecondsToDate( pb.hFileInfo.ioFlMdDat, &tm );
	save_file_info.month  = tm.month;
	save_file_info.day    = tm.day;
	save_file_info.hour   = tm.hour;
	save_file_info.minute = tm.minute;
#elif defined(PSP)
    if (script_h.savedir)
        sprintf( file_name, "%ssave%d.dat", script_h.savedir, no );
    else
        sprintf( file_name, "%ssave%d.dat", script_h.save_path, no );
    SceIoStat buf;
    if ( sceIoGetstat(file_name, &buf)<0 ){
        save_file_info.valid = false;
        return;
    }

    save_file_info.month  = buf.st_mtime.month;
    save_file_info.day    = buf.st_mtime.day;
    save_file_info.hour   = buf.st_mtime.hour;
    save_file_info.minute = buf.st_mtime.minute;
#else
    sprintf( file_name, "save%d.dat", no );
    FILE *fp;
    if ( (fp = fopen( file_name, "rb" )) == NULL ){
        save_file_info.valid = false;
        return;
    }
    fclose( fp );

    save_file_info.month  = 1;
    save_file_info.day    = 1;
    save_file_info.hour   = 0;
    save_file_info.minute = 0;
#endif
    save_file_info.valid = true;
    script_h.getStringFromInteger( save_file_info.sjis_month,
                                   save_file_info.month, 2,
                                   false, use_fullwidth );
    script_h.getStringFromInteger( save_file_info.sjis_day,
                                   save_file_info.day, 2,
                                   false, use_fullwidth );
    script_h.getStringFromInteger( save_file_info.sjis_hour,
                                   save_file_info.hour, 2,
                                   false, use_fullwidth );
    script_h.getStringFromInteger( save_file_info.sjis_minute,
                                   save_file_info.minute, 2,
                                   true, use_fullwidth );
}
예제 #22
0
static OSErr MacPathname2FSSpec(const char *inPathname, FSSpec *outFSS)
{
	OSErr err;
	size_t len;
	char *p;
	short vRefNum;
	long dirID;
	FSSpec fss;
	
	if (inPathname == NULL || outFSS == NULL) {
		return paramErr;
	}
	
	err = HGetVol(NULL, &vRefNum, &dirID);  /* default volume and directory */
	if (err != noErr) return err;
	
	len = strlen(inPathname);
	
	p = strchr(inPathname, ':');
	if (p == NULL) {
		/* Partial pathname -- filename only */
		Str31 filename;
		assert(len <= 31);
		c2pstrcpy(filename, inPathname);
		err = FSMakeFSSpec(vRefNum, dirID, filename, outFSS);
	} else {
		Str31 name;
		int nameLen;
		if (inPathname[0] == ':') {
			/* Relative pathname including directory path */
			
		} else {
			/* Absolute pathname */
			/* Str31 volName;  We would use Str28 if it was defined -- 27, plus 1 for ':'. */
			nameLen = p - inPathname;
			assert(nameLen <= 27);
			name[0] = nameLen + 1;
			memcpy(name + 1, inPathname, nameLen + 1);  /* Copy the volume name and the colon. */
			err = DetermineVRefNum(name, 0, &vRefNum);
			if (err != noErr) return err;
			dirID = 2;
		}
		/* vRefNum and dirID now specify the directory in which we should descend
		   the path pointed to by p (pointing to the first colon). */
		p++;
		while (p != NULL && *p != '\0') {
			char *q = strchr(p, ':');
			if (q != NULL) {
				Boolean isDir;
				nameLen = q - p;
				assert(nameLen <= 31);
				name[0] = nameLen;
				memcpy(name + 1, p, nameLen);
				err = FSMakeFSSpec(vRefNum, dirID, name, &fss);
				if (err != noErr) return err;
				if (q[1] == '\0') {
					p = NULL;
					*outFSS = fss;
				} else {
					err = FSpGetDirectoryID(&fss, &dirID, &isDir);
					assert(isDir == true);
					if (err != noErr) return err;
					p = q + 1;
				}
			} else {
				q = strchr(p, '\0');  /* go to end of string */
				nameLen = q - p;
				assert(nameLen > 0);
				assert(nameLen <= 31);
				c2pstrcpy(name, p);
				p = NULL;
				err = FSMakeFSSpec(vRefNum, dirID, name, outFSS);
			}
		}
	}
	return err;
}
예제 #23
0
pascal OSStatus OpenEventHandler(EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData)
{
	DWORD p;
	NavDialogRef fileDialog;
	NavDialogCreationOptions fo;
	NavGetDefaultDialogCreationOptions(&fo);
	fo.optionFlags=0;
	fo.parentWindow=win;
	NavCreateChooseFileDialog(&fo,NULL,NULL,NULL,NULL,NULL,&fileDialog);
	if (!NavDialogRun(fileDialog)) {
		NavReplyRecord r;
		if (!NavDialogGetReply(fileDialog,&r)) {
			AEKeyword k;
			FSRef fr;
			if (!AEGetNthPtr(&r.selection,1,typeFSRef,&k,NULL,&fr,sizeof(fr),NULL)) {
				char file[256];
				FSRefMakePath(&fr,(BYTE*)file,sizeof(file));
				BASS_StreamFree(chan); // free old streams before opening new
		
				// create decode channel
				chan = BASS_StreamCreateFile(FALSE,file,0,0,BASS_SAMPLE_FLOAT|BASS_STREAM_DECODE|BASS_STREAM_PRESCAN);

				// check for MOD
				if (!chan) chan = BASS_MusicLoad(FALSE, file, 0, 0, BASS_SAMPLE_FLOAT|BASS_MUSIC_RAMP|BASS_STREAM_DECODE|BASS_MUSIC_PRESCAN,0);

				if (!chan) {
					SetControlTitleWithCFString(inUserData,CFSTR("click here to open a file && play it..."));
					Error("Selected file couldn't be loaded!");
				} else {
					// create new stream - decoded & reversed
					// 2 seconds decoding block as a decoding channel
					if (!(chan=BASS_FX_ReverseCreate(chan, 2, BASS_STREAM_DECODE|BASS_FX_FREESOURCE))) {
						SetControlTitleWithCFString(inUserData,CFSTR("click here to open a file && play it..."));
						Error("Couldn't create a reversed stream!");
						BASS_StreamFree(chan);
						BASS_MusicFree(chan);
					} else {
						// create a new stream - decoded & resampled :)
						if (!(chan=BASS_FX_TempoCreate(chan, BASS_SAMPLE_LOOP|BASS_FX_FREESOURCE))){
							SetControlTitleWithCFString(inUserData,CFSTR("click here to open a file && play it..."));
							Error("Couldn't create a resampled stream!");
							BASS_StreamFree(chan);
							BASS_MusicFree(chan);
						} else {
							// update the Button to show the loaded file
							c2pstrcpy((BYTE*)file,file);
							SetControlTitle(inUserData,(BYTE*)file);

							// update the position slider
							p = BASS_ChannelBytes2Seconds(chan, BASS_ChannelGetLength(chan, BASS_POS_BYTE));
							SetControl32BitMaximum(GetControl(15),p);
							SetControl32BitValue(GetControl(15),p);

							// set Volume
							p = GetControl32BitValue(GetControl(11));
							BASS_ChannelSetAttribute(chan, BASS_ATTRIB_VOL, (float)p/100.0f);

							// update tempo slider
							SetControl32BitValue(GetControl(13),0);
							SetStaticText(12,"Tempo = 0%");

							// play new created stream
							BASS_ChannelPlay(chan,FALSE);
						}
					}
				}
			}
			NavDisposeReply(&r);
		}
	}
	NavDialogDispose(fileDialog);
	return noErr;
}