コード例 #1
0
ファイル: startui.c プロジェクト: nthung82/fontforge
static pascal OSErr OpenDocumentsAE( const AppleEvent * theAppleEvent,
	AppleEvent * reply, SInt32 handlerRefcon) {
    AEDescList  docList;
    FSRef       theFSRef;
    long        index;
    long        count = 0;
    OSErr       err;
    char	buffer[2048];

 fprintf( logfile, "OPEN event received.\n" ); fflush( logfile );
    if ( localsplash )
	start_splash_screen();

    err = AEGetParamDesc(theAppleEvent, keyDirectObject,
                         typeAEList, &docList);
    err = AECountItems(&docList, &count);
    for(index = 1; index <= count; index++) {
        err = AEGetNthPtr(&docList, index, typeFSRef,
                        NULL, NULL, &theFSRef,
                        sizeof(theFSRef), NULL);// 4
	err = FSRefMakePath(&theFSRef,(unsigned char *) buffer,sizeof(buffer));
	ViewPostScriptFont(buffer,0);
 fprintf( logfile, " file: %s\n", buffer );
    }
    system( "DYLD_LIBRARY_PATH=\"\"; osascript -e 'tell application \"X11\" to activate'" );
    AEDisposeDesc(&docList);
 fprintf( logfile, " event processed %d.\n", err ); fflush( logfile );

return( err );
}
コード例 #2
0
ファイル: ArchHooks_MacOSX.cpp プロジェクト: Ancaro/stepmania
static void PathForFolderType( char dir[PATH_MAX], OSType folderType )
{
	FSRef fs;

	if( FSFindFolder(kUserDomain, folderType, kDontCreateFolder, &fs) )
		FAIL_M( ssprintf("FSFindFolder(%lu) failed.", folderType) );
	if( FSRefMakePath(&fs, (UInt8 *)dir, PATH_MAX) )
		FAIL_M( "FSRefMakePath() failed." );
}
コード例 #3
0
ファイル: lldir_mac.cpp プロジェクト: AGoodPerson/Ascent
static void FSRefToLLString(FSRef *fsRef, std::string &llString)
{
	OSStatus	error = noErr;
	char		path[MAX_PATH];
	
	error = FSRefMakePath(fsRef, (UInt8*) path, sizeof(path));
	if (error == noErr)
		llString = path;
}
コード例 #4
0
ファイル: appbundle.c プロジェクト: megastep/loki_setup
static int manually_locate_product(const char *name, char *buf, size_t bufsize, const char *title)
{
    NavDialogCreationOptions dlgopt;
    NavDialogRef dlg;
    NavReplyRecord reply;
    NavUserAction action;
    AEKeyword keyword;
    AEDesc desc;
    FSRef fsref;
    OSStatus rc;
    int retval = 0;
    const char *promptfmt = _("We can't find your \"%s\" installation."
                            " Would you like to show us where it is?");
    char *promptstr = alloca(strlen(name) + strlen(promptfmt) + 1);

    if (promptstr == NULL)
    {
        log_fatal(_("Out of memory."));
        return(0);
    } /* if */
    sprintf(promptstr, promptfmt, name);

    if (!ui_prompt_yn(promptstr, title))
        return(0);

    NavGetDefaultDialogCreationOptions(&dlgopt);
    dlgopt.optionFlags |= kNavSupportPackages;
    dlgopt.optionFlags |= kNavAllowOpenPackages;
    dlgopt.optionFlags &= ~kNavAllowMultipleFiles;
    dlgopt.windowTitle = CFSTR("Please select the product's icon and click 'OK'.");  /* !!! FIXME! */
    dlgopt.actionButtonLabel = CFSTR("OK");
    NavCreateChooseFolderDialog(&dlgopt, NULL, NULL, NULL, &dlg);
    NavDialogRun(dlg);
    action = NavDialogGetUserAction(dlg);
    if (action != kNavUserActionCancel)
    {
        NavDialogGetReply(dlg, &reply);
        rc = AEGetNthDesc(&reply.selection, 1, typeFSRef, &keyword, &desc);
        if (rc != noErr)
            log_fatal("Unexpected error in AEGetNthDesc: %d", (int) rc);
        else
        {
            /* !!! FIXME: Check return values here! */
            BlockMoveData(*desc.dataHandle, &fsref, sizeof (fsref));
            FSRefMakePath(&fsref, BAD_CAST buf, bufsize - 1);
            buf[bufsize - 1] = '\0';
            AEDisposeDesc(&desc);
            retval = 1;
        } /* if */

        NavDisposeReply(&reply);
    } /* else */

    NavDialogDispose(dlg);

    return(retval);
} /* manually_locate_product */
コード例 #5
0
ファイル: alias.c プロジェクト: asvitkine/phxd
/* resolve_alias
   -------------
   Resolves the Macintosh alias file at the path pointed to
   by path and stores the resolved path in resolved_path.

   The return value is a  pointer to the resolved path upon
   success.  On  error the  return  value is  zero and both
   errno and mac_errno should be consulted.
*/
char* resolve_alias (const char *path, char *resolved_path)
{
#ifdef HAVE_CORESERVICES
   FSRef *fspath;
   Boolean isdir = 0, isalias = 0;
#endif

#ifndef HAVE_CORESERVICES
   /* this function is for resolving macintosh aliases.
      if we don't have the CoreServices API it's impossible,
      so why fool ourselves, let's just return error now
      and save the cpu cycles for something else */

   errno = EIO; /* returning a generic I/O error */
   return 0;
#endif

   /* reset it for each occurrence */
   /* mac_errno = 0; */

   if (!path) return 0;

   /* if the second parameter is null, assume caller wants it allocated */
   if (!resolved_path) {
      resolved_path = (char *)malloc(PATH_MAX + 1);
      if (!resolved_path) return 0;
   }

#ifdef HAVE_CORESERVICES

   /* allocate memory for the resolved path(s) */
   fspath = (FSRef *)malloc(sizeof(FSRef));

   /* attempt to convert the target path into an FSRef */
   mac_errno = FSPathMakeRef(path, fspath, 0);
   if (mac_errno) return 0;

   /* check if the file is actually an alias */
   mac_errno = FSIsAliasFile(fspath, &isalias, &isdir);
   if (mac_errno) return 0;

   /* resolve the path completely */
   mac_errno = FSResolveAliasFile(fspath, true, &isdir, &isalias);
   if (mac_errno) return 0;

   /* obtain the resolved path */
   mac_errno = FSRefMakePath(fspath, resolved_path, PATH_MAX);
   if (mac_errno) return 0;

#endif

   /* return the resolved path upon success */
   return resolved_path;
}
コード例 #6
0
ファイル: llfilepicker.cpp プロジェクト: Boy/rainbow
OSStatus	LLFilePicker::doNavChooseDialog(ELoadFilter filter)
{
	OSStatus		error = noErr;
	NavDialogRef	navRef = NULL;
	NavReplyRecord	navReply;

	memset(&navReply, 0, sizeof(navReply));
	
	// NOTE: we are passing the address of a local variable here.  
	//   This is fine, because the object this call creates will exist for less than the lifetime of this function.
	//   (It is destroyed by NavDialogDispose() below.)
	error = NavCreateChooseFileDialog(&mNavOptions, NULL, NULL, NULL, navOpenFilterProc, (void*)(&filter), &navRef);

	gViewerWindow->mWindow->beforeDialog();

	if (error == noErr)
		error = NavDialogRun(navRef);

	gViewerWindow->mWindow->afterDialog();

	if (error == noErr)
		error = NavDialogGetReply(navRef, &navReply);

	if (navRef)
		NavDialogDispose(navRef);

	if (error == noErr && navReply.validRecord)
	{
		SInt32	count = 0;
		SInt32	index;
		
		// AE indexes are 1 based...
		error = AECountItems(&navReply.selection, &count);
		for (index = 1; index <= count; index++)
		{
			FSRef		fsRef;
			AEKeyword	theAEKeyword;
			DescType	typeCode;
			Size		actualSize = 0;
			char		path[MAX_PATH];	/*Flawfinder: ignore*/
			
			memset(&fsRef, 0, sizeof(fsRef));
			error = AEGetNthPtr(&navReply.selection, index, typeFSRef, &theAEKeyword, &typeCode, &fsRef, sizeof(fsRef), &actualSize);
			
			if (error == noErr)
				error = FSRefMakePath(&fsRef, (UInt8*) path, sizeof(path));
			
			if (error == noErr)
				mFiles.push_back(std::string(path));
		}
	}
	
	return error;
}
コード例 #7
0
ファイル: plugins.c プロジェクト: bagnz0r/ichigo-audio
pascal OSStatus OpenEventHandler(EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData)
{
	NavDialogRef fileDialog;
	NavDialogCreationOptions fo;
	NavGetDefaultDialogCreationOptions(&fo);
	fo.optionFlags=0;
	fo.parentWindow=win;
	NavCreateChooseFileDialog(&fo,NULL,NULL,NULL,NULL,NULL,&fileDialog);
// if someone wants to somehow get the file selector to filter like in the Windows example, that'd be nice ;)
	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 stream before opening new
				if (!(chan=BASS_StreamCreateFile(FALSE,file,0,0,BASS_SAMPLE_LOOP|BASS_SAMPLE_FLOAT))) {
					SetControlTitleWithCFString(inUserData,CFSTR("click here to open a file..."));
					{
						ControlRef cref=GetControl(11);
						SetControlData(cref,kControlNoPart,kControlStaticTextTextTag,0,"");
						DrawOneControl(cref);
					}
					SetControl32BitMaximum(GetControl(12),0);
					Error("Can't play the file");
				} else {
					CFStringRef cs=CFStringCreateWithCString(0,file,kCFStringEncodingUTF8);
					SetControlTitleWithCFString(inUserData,cs);
					CFRelease(cs);
					{ // display the file type and length
						QWORD bytes=BASS_ChannelGetLength(chan,BASS_POS_BYTE);
						DWORD time=BASS_ChannelBytes2Seconds(chan,bytes);
						BASS_CHANNELINFO info;
						BASS_ChannelGetInfo(chan,&info);
						sprintf(file,"channel type = %x (%s)\nlength = %llu (%u:%02u)",
							info.ctype,GetCTypeString(info.ctype,info.plugin),bytes,time/60,time%60);
						{
							ControlRef cref=GetControl(11);
							SetControlData(cref,kControlNoPart,kControlStaticTextTextTag,strlen(file),file);
							DrawOneControl(cref);
						}
						SetControl32BitMaximum(GetControl(12),time); // update scroller range
					}
					BASS_ChannelPlay(chan,FALSE);
				}
			}
			NavDisposeReply(&r);
		}
	}
	NavDialogDispose(fileDialog);
    return noErr;
}
コード例 #8
0
RTDECL(int) RTPathUserDocuments(char *pszPath, size_t cchPath)
{
    /*
     * Validate input
     */
    AssertPtrReturn(pszPath, VERR_INVALID_POINTER);
    AssertReturn(cchPath, VERR_INVALID_PARAMETER);

    /*
     * Try NSSystemDirectories first since that works for directories that doesn't exist.
     */
    int rc = VERR_PATH_NOT_FOUND;
    NSSearchPathEnumerationState EnmState = NSStartSearchPathEnumeration(NSDocumentDirectory, NSUserDomainMask);
    if (EnmState != 0)
    {
        char szTmp[PATH_MAX];
        szTmp[0] = szTmp[PATH_MAX - 1] = '\0';
        EnmState = NSGetNextSearchPathEnumeration(EnmState, szTmp);
        if (EnmState != 0)
        {
            size_t cchTmp = strlen(szTmp);
            if (cchTmp >= cchPath)
                return VERR_BUFFER_OVERFLOW;

            if (szTmp[0] == '~' && szTmp[1] == '/')
            {
                /* Expand tilde. */
                rc = RTPathUserHome(pszPath, cchPath - cchTmp + 2);
                if (RT_FAILURE(rc))
                    return rc;
                rc = RTPathAppend(pszPath, cchPath, &szTmp[2]);
            }
            else
                rc = RTStrCopy(pszPath, cchPath, szTmp);
            return rc;
        }
    }

#ifdef IPRT_USE_CORE_SERVICE_FOR_USER_DOCUMENTS
    /*
     * Fall back on FSFindFolder in case the above should fail...
     */
    FSRef ref;
    OSErr err = FSFindFolder(kOnAppropriateDisk, kDocumentsFolderType, false /* createFolder */, &ref);
    if (err == noErr)
    {
        err = FSRefMakePath(&ref, (UInt8*)pszPath, cchPath);
        if (err == noErr)
            return VINF_SUCCESS;
    }
#endif
    Assert(RT_FAILURE_NP(rc));
    return rc;
}
コード例 #9
0
ファイル: mac_saver_module.cpp プロジェクト: DanAurea/boinc
OSErr CScreensaver::GetpathToBOINCManagerApp(char* path, int maxLen)
{
    CFStringRef bundleID = CFSTR("edu.berkeley.boinc");
    OSType creator = 'BNC!';
    FSRef theFSRef;
    OSStatus status = noErr;

    status = LSFindApplicationForInfo(creator, bundleID, NULL, &theFSRef, NULL);
    if (status == noErr)
        status = FSRefMakePath(&theFSRef, (unsigned char *)path, maxLen);
    return status;
}
コード例 #10
0
static std::string GetMacFolder(OSType folderType, const char* errorMsg) {
	std::string ret;
	FSRef ref;
    char path[PATH_MAX];
    OSStatus err = FSFindFolder( kUserDomain, folderType, kCreateFolder, &ref );
	if (err != noErr) {
		throw std::runtime_error(errorMsg);
	}
    FSRefMakePath( &ref, (UInt8*)&path, PATH_MAX );
	ret = path;
	return ret;
}
コード例 #11
0
ファイル: mac-client.cpp プロジェクト: alesegdia/snes-sdk
static bool8 NPClientEndOpenROMImage(void)
{
	OSStatus		err;
	FSCatalogInfo   info;
	FSRef			cartRef;
	char			filename[PATH_MAX + 1];
	bool8			r;

	r = NavEndOpenROMImageSheet(&cartRef);
	if (!r)
	{
		cartOpen = false;
		return (false);
	}

	err = FSGetCatalogInfo(&cartRef, kFSCatInfoVolume, &info, nil, nil, nil);
	lockedROMMedia = IsLockedMedia(info.volume);

	Settings.ForceLoROM          = (romDetect        == kLoROMForce       );
	Settings.ForceHiROM          = (romDetect        == kHiROMForce       );
	Settings.ForceNotInterleaved = (interleaveDetect == kNoInterleaveForce);
	Settings.ForceInterleaved    = (interleaveDetect == kInterleaveForce  );
	Settings.ForceInterleaved2   = (interleaveDetect == kInterleave2Force );
	Settings.ForceInterleaveGD24 = (interleaveDetect == kInterleaveGD24   );
	Settings.ForcePAL            = (videoDetect      == kPALForce         );
	Settings.ForceNTSC           = (videoDetect      == kNTSCForce        );
	Settings.ForceHeader         = (headerDetect     == kHeaderForce      );
	Settings.ForceNoHeader       = (headerDetect     == kNoHeaderForce    );

	Settings.ForceSuperFX = Settings.ForceNoSuperFX = false;
	Settings.ForceDSP1    = Settings.ForceNoDSP1    = false;
	Settings.ForceSA1     = Settings.ForceNoSA1     = false;
	Settings.ForceC4      = Settings.ForceNoC4      = false;
	Settings.ForceSDD1    = Settings.ForceNoSDD1    = false;

	GFX.InfoString = nil;
	GFX.InfoStringTimeout = 0;

	err = FSRefMakePath(&cartRef, (unsigned char *) filename, PATH_MAX);

	if (Memory.LoadROM(filename) /*&& (Memory.ROMCRC32 == nprominfo.crc32)*/)
	{
		ChangeTypeAndCreator(filename, 'CART', '~9X~');
		SNES9X_InitSound();
		cartOpen = true;
		return (true);
	}
	else
	{
		cartOpen = false;
		return (false);
	}
}
コード例 #12
0
ファイル: OSUtils.cpp プロジェクト: aaronmjacobs/Shiny
bool getAppDataPath(const std::string &appName, std::string &appDataPath) {
   FSRef ref;
   FSFindFolder(kUserDomain, kApplicationSupportFolderType, kCreateFolder, &ref);

   char path[PATH_MAX];
   FSRefMakePath(&ref, (UInt8*)&path, PATH_MAX);

   appDataPath = std::string(path);
   appDataPath += "/" + appName;

   return true;
}
コード例 #13
0
ファイル: dirpath.c プロジェクト: Ismael-VC/femtolisp
char *get_exename(char *buf, size_t size)
{
    ProcessSerialNumber PSN;
    FSRef ref;

    if (GetCurrentProcess(&PSN) < 0 ||
        GetProcessBundleLocation(&PSN, &ref) < 0 ||
        FSRefMakePath(&ref, buf, size) < 0)
        return NULL;

    return buf;
}
コード例 #14
0
ファイル: Crash.cpp プロジェクト: Ancaro/stepmania
RString CrashHandler::GetLogsDirectory()
{
	FSRef fs;
	char dir[PATH_MAX];
	
	if( FSFindFolder(kUserDomain, kDomainLibraryFolderType, kDontCreateFolder, &fs) ||
	    FSRefMakePath(&fs, (UInt8 *)dir, PATH_MAX) )
	{
		return "/tmp";
	}
	return RString( dir ) + "/Logs/" PRODUCT_ID;
}
コード例 #15
0
ファイル: gui-unique.c プロジェクト: AnonPower/picman
/* Handle the kAEOpenDocuments Apple events. This will register
 * an idle source callback for each filename in the event.
 */
static pascal OSErr
gui_unique_mac_open_documents (const AppleEvent *inAppleEvent,
                               AppleEvent       *outAppleEvent,
                               long              handlerRefcon)
{
  OSStatus    status;
  AEDescList  documents;
  gchar       path[MAXPATHLEN];

  status = AEGetParamDesc (inAppleEvent,
                           keyDirectObject, typeAEList,
                           &documents);
  if (status == noErr)
    {
      long count = 0;
      int  i;

      AECountItems (&documents, &count);

      for (i = 0; i < count; i++)
        {
          FSRef    ref;
          gchar    *callback_path;
          GSource  *source;
          GClosure *closure;

          status = AEGetNthPtr (&documents, i + 1, typeFSRef,
                                0, 0, &ref, sizeof (ref),
                                0);
          if (status != noErr)
            continue;

          FSRefMakePath (&ref, (UInt8 *) path, MAXPATHLEN);

          callback_path = g_strdup (path);

          closure = g_cclosure_new (G_CALLBACK (gui_unique_mac_idle_open),
                                    (gpointer) callback_path,
                                    (GClosureNotify) g_free);

          g_object_watch_closure (G_OBJECT (unique_gimp), closure);

          source = g_idle_source_new ();
          g_source_set_priority (source, G_PRIORITY_LOW);
          g_source_set_closure (source, closure);
          g_source_attach (source, NULL);
          g_source_unref (source);
        }
    }

    return status;
}
コード例 #16
0
ファイル: m_specialpaths.cpp プロジェクト: Marqt/ViZDoom
FString M_GetSavegamesPath()
{
	FString path;
	char cpath[PATH_MAX];
	FSRef folder;

	if (noErr == FSFindFolder(kUserDomain, kDocumentsFolderType, kCreateFolder, &folder) &&
		noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
	{
		path << cpath << "/" GAME_DIR "/Savegames/";
	}
	return path;
}
コード例 #17
0
QFontEngine::FaceId QFontEngineMac::faceId() const
{
    FaceId ret;
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
    FSRef ref;
    if (ATSFontGetFileReference(FMGetATSFontRefFromFont(fontID), &ref) != noErr)
        return ret;
    ret.filename = QByteArray(128, 0);
    ret.index = fontID;
    FSRefMakePath(&ref, (UInt8 *)ret.filename.data(), ret.filename.size());
#else
    FSSpec spec;
    if (ATSFontGetFileSpecification(FMGetATSFontRefFromFont(fontID), &spec) != noErr)
        return ret;

    FSRef ref;
    FSpMakeFSRef(&spec, &ref);
    ret.filename = QByteArray(128, 0);
    ret.index = fontID;
    FSRefMakePath(&ref, (UInt8 *)ret.filename.data(), ret.filename.size());
#endif
    return ret;
}
コード例 #18
0
FString M_GetAutoexecPath()
{
	FString path;

	char cpath[PATH_MAX];
	FSRef folder;
	
	if (noErr == FSFindFolder(kUserDomain, kApplicationSupportFolderType, kCreateFolder, &folder) &&
		noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
	{
		path << cpath << "/" GAME_DIR "/autoexec.cfg";
	}
	return path;
}
コード例 #19
0
ファイル: FileManager.cpp プロジェクト: 010001111/darling
CFURLRef CFURLCreateFromFSRef(CFAllocatorRef alloc, FSRef* location)
{
	std::string path;
	struct stat st;
	Boolean isDir = false;
	
	if (!FSRefMakePath(location, path))
		return nullptr;
	
	if (::stat(path.c_str(), &st))
		isDir = S_ISDIR(st.st_mode);
	
	return CFURLCreateFromFileSystemRepresentation(alloc, (const UInt8*) path.c_str(), path.size(), isDir);
}
コード例 #20
0
ファイル: cltool.c プロジェクト: bsingr/unison-mirror
int main(int argc, char **argv) {

  /* Look up the application by its bundle identifier, which is given
     in the Info.plist file.  This will continue to work even if the
     user changes the name of the application, unlike
     fullPathForApplication. */

  FSRef fsref;
  OSStatus status;
  int len;
  char buf[BUFSIZE];

  status = LSFindApplicationForInfo(NULL,CFSTR("edu.upenn.cis.Unison"),NULL,&fsref,NULL);
  if (status) {
    if (status == kLSApplicationNotFoundErr) {
      fprintf(stderr,"Error: can't find the Unison application using the Launch Services database.\n");
      fprintf(stderr,"Try launching Unison from the Finder, and then try this again.\n",status);
    }
    else fprintf(stderr,"Error: can't find Unison application (%d).\n",status);
    exit(1);
  }

  status = FSRefMakePath(&fsref,buf,BUFSIZE);
  if (status) {
    fprintf(stderr,"Error: problem building path to Unison application (%d).\n",status);
    exit(1);
  }

  len = strlen(buf);
  if (len + strlen(EXECPATH) + 1 > BUFSIZE) {
    fprintf(stderr,"Error: path to Unison application exceeds internal buffer size (%d).\n",BUFSIZE);
    exit(1);
  }
  strcat(buf,EXECPATH);

  /* It's important to pass the absolute path on to the GUI,
     that's how it knows where to find the bundle, e.g., the
     Info.plist file. */
  argv[0] = buf;

  // printf("The Unison executable is at %s\n",argv[0]);
  // printf("Running...\n");

  execv(argv[0],argv);

  /* If we get here the execv has failed; print an error message to stderr */
  perror("unison");
  exit(1);
}
コード例 #21
0
OSStatus FSRefMakePath(const FSRef* fsref, uint8_t* path, uint32_t maxSize)
{
	std::string rpath;

	if (!fsref || !path || !maxSize)
		return paramErr;

	if (!FSRefMakePath(fsref, rpath))
		return fnfErr;

	strncpy((char*) path, rpath.c_str(), maxSize);
	path[maxSize-1] = 0;

	return noErr;
}
コード例 #22
0
ファイル: m_specialpaths.cpp プロジェクト: Marqt/ViZDoom
FString M_GetConfigPath(bool for_reading)
{
	char cpath[PATH_MAX];
	FSRef folder;
	
	if (noErr == FSFindFolder(kUserDomain, kPreferencesFolderType, kCreateFolder, &folder) &&
		noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
	{
		FString path;
		path << cpath << "/" GAMENAMELOWERCASE ".ini";
		return path;
	}
	// Ungh.
	return GAMENAMELOWERCASE ".ini";
}
コード例 #23
0
ファイル: mac-client.cpp プロジェクト: RedGuyyyy/snes9x
static bool8 NPClientEndOpenROMImage (void)
{
	OSStatus	err;
	FSRef		cartRef;
	char		filename[PATH_MAX + 1];
	bool8		r;

	r = NavEndOpenROMImageSheet(&cartRef);
	if (!r)
	{
		cartOpen = false;
		return (false);
	}

	CheckSaveFolder(&cartRef);

	Settings.ForceLoROM          = (romDetect        == kLoROMForce       );
	Settings.ForceHiROM          = (romDetect        == kHiROMForce       );
	Settings.ForceHeader         = (headerDetect     == kHeaderForce      );
	Settings.ForceNoHeader       = (headerDetect     == kNoHeaderForce    );
	Settings.ForceInterleaved    = (interleaveDetect == kInterleaveForce  );
	Settings.ForceInterleaved2   = (interleaveDetect == kInterleave2Force );
	Settings.ForceInterleaveGD24 = (interleaveDetect == kInterleaveGD24   );
	Settings.ForceNotInterleaved = (interleaveDetect == kNoInterleaveForce);
	Settings.ForcePAL            = (videoDetect      == kPALForce         );
	Settings.ForceNTSC           = (videoDetect      == kNTSCForce        );

	GFX.InfoString = NULL;
	GFX.InfoStringTimeout = 0;

	S9xResetSaveTimer(true);

	err = FSRefMakePath(&cartRef, (unsigned char *) filename, PATH_MAX);

	SNES9X_InitSound();

	if (Memory.LoadROM(filename) /*&& (Memory.ROMCRC32 == nprominfo.crc32)*/)
	{
		ChangeTypeAndCreator(filename, 'CART', '~9X~');
		cartOpen = true;
		return (true);
	}
	else
	{
		cartOpen = false;
		return (false);
	}
}
コード例 #24
0
std::string
Moose::applicationPath()
{
    FSRef appRef;
    LSFindApplicationForInfo( kLSUnknownCreator, CFSTR( AUDIOSCROBBLER_BUNDLEID ), NULL, &appRef, NULL );
    
    char path[PATH_MAX];
    FSRefMakePath( &appRef, (unsigned char*)path, PATH_MAX );
    
    if ( path == NULL )
        return "/Applications/Last.Fm.app/Contents/MacOS/Last.fm";

    std::string s = path;
    s.append( "/Contents/MacOS/Last.fm" );
    return s;
}
コード例 #25
0
OSStatus	LLDirPicker::doNavChooseDialog()
{
	OSStatus		error = noErr;
	NavDialogRef	navRef = NULL;
	NavReplyRecord	navReply;

	memset(&navReply, 0, sizeof(navReply));
	
	// NOTE: we are passing the address of a local variable here.  
	//   This is fine, because the object this call creates will exist for less than the lifetime of this function.
	//   (It is destroyed by NavDialogDispose() below.)

	error = NavCreateChooseFolderDialog(&mNavOptions, &doNavCallbackEvent, NULL, NULL, &navRef);

	gViewerWindow->mWindow->beforeDialog();

	if (error == noErr)
		error = NavDialogRun(navRef);

	gViewerWindow->mWindow->afterDialog();

	if (error == noErr)
		error = NavDialogGetReply(navRef, &navReply);

	if (navRef)
		NavDialogDispose(navRef);

	if (error == noErr && navReply.validRecord)
	{	
		FSRef		fsRef;
		AEKeyword	theAEKeyword;
		DescType	typeCode;
		Size		actualSize = 0;
		char		path[LL_MAX_PATH];		 /*Flawfinder: ignore*/
		
		memset(&fsRef, 0, sizeof(fsRef));
		error = AEGetNthPtr(&navReply.selection, 1, typeFSRef, &theAEKeyword, &typeCode, &fsRef, sizeof(fsRef), &actualSize);
		
		if (error == noErr)
			error = FSRefMakePath(&fsRef, (UInt8*) path, sizeof(path));
		
		if (error == noErr)
			mDir = path;
	}
	
	return error;
}
コード例 #26
0
FString M_GetConfigPath(bool for_reading)
{
	char cpath[PATH_MAX];
	FSRef folder;
	
	if (noErr == FSFindFolder(kUserDomain, kApplicationSupportFolderType, kCreateFolder, &folder) &&
		noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
	{
		FString path;
		path << cpath << "/" GAME_DIR "/";
		CreatePath(path);
		path << "GZDoom.ini";
		return path;
	}
	// Ungh.
	return "GZDoom.ini";
}
コード例 #27
0
ファイル: mac-file.cpp プロジェクト: BruceJawn/flashsnes
static OSErr FindApplicationSupportFolder(FSRef *folderRef, char *folderPath, const char *folderName)
{
	OSErr		err;
	FSRef		p2ref, p1ref;
	CFStringRef	fstr;
	UniChar		buffer[PATH_MAX + 1];
	UniChar		s9xfolder[6] = { 'S', 'n', 'e', 's', '9', 'x' },
				oldfolder[6] = { 'S', 'N', 'E', 'S', '9', 'X' };

	err = FSFindFolder(kUserDomain, kApplicationSupportFolderType, kCreateFolder, &p2ref);
	if (err)
		return (err);

	err = FSMakeFSRefUnicode(&p2ref, 6, s9xfolder, kTextEncodingUnicodeDefault, &p1ref);
	if (err == dirNFErr || err == fnfErr)
	{
		err = FSMakeFSRefUnicode(&p2ref, 6, oldfolder, kTextEncodingUnicodeDefault, &p1ref);
		if (err == dirNFErr || err == fnfErr)
			err = FSCreateDirectoryUnicode(&p2ref, 6, s9xfolder, kFSCatInfoNone, nil, &p1ref, nil, nil);
	}
	if (err)
		return (err);

	fstr = CFStringCreateWithCString(kCFAllocatorDefault, folderName, CFStringGetSystemEncoding());
	CFStringGetCharacters(fstr, CFRangeMake(0, CFStringGetLength(fstr)), buffer);

	err = FSMakeFSRefUnicode(&p1ref, CFStringGetLength(fstr), buffer, kTextEncodingUnicodeDefault, folderRef);
 	if (err == dirNFErr || err == fnfErr)
	{
		err = FSCreateDirectoryUnicode(&p1ref, CFStringGetLength(fstr), buffer, kFSCatInfoNone, nil, folderRef, nil, nil);
		if (err == noErr)
			AddFolderIcon(folderRef, folderName);
	}

	if (err != noErr && !folderWarning)
	{
		AppearanceAlert(kAlertCautionAlert, kFolderFail, kFolderHint);
		folderWarning = true;
	}
	else
		err = FSRefMakePath(folderRef, (unsigned char *) folderPath, PATH_MAX);

	CFRelease(fstr);

	return err;
}
コード例 #28
0
ファイル: mac_updater.cpp プロジェクト: xinyaojiejie/Dale
bool isDirWritable(FSRef &dir)
{
	bool result = false;
	
	// Test for a writable directory by creating a directory, then deleting it again.
	// This is kinda lame, but will pretty much always give the right answer.
	
	OSStatus err = noErr;
	char temp[PATH_MAX];		/* Flawfinder: ignore */

	err = FSRefMakePath(&dir, (UInt8*)temp, sizeof(temp));

	if(err == noErr)
	{
		temp[0] = '\0';
		strncat(temp, "/.test_XXXXXX", sizeof(temp) - 1);
		
		if(mkdtemp(temp) != NULL)
		{
			// We were able to make the directory.  This means the directory is writable.
			result = true;
			
			// Clean up.
			rmdir(temp);
		}
	}

#if 0
	// This seemed like a good idea, but won't tell us if we're on a volume mounted read-only.
	UInt8 perm;
	err = FSGetUserPrivilegesPermissions(&targetParentRef, &perm, NULL);
	if(err == noErr)
	{
		if(perm & kioACUserNoMakeChangesMask)
		{
			// Parent directory isn't writable.
			llinfos << "Target parent directory not writable." << llendl;
			err = -1;
			replacingTarget = false;
		}
	}
#endif

	return result;
}
コード例 #29
0
ファイル: PIUFile.cpp プロジェクト: dannyyiu/ps-color-test
int32 GetFullPathToDesktop(char * fullPath, int32 maxPathLength)
{
	int32 error = 0;
	if (fullPath == NULL || maxPathLength < 1) return kSPBadParameterError;
	
	#if __PIMac__

		FSRef fsRef;
	
		error = FSFindFolder(kOnSystemDisk, 
			 				 kDesktopFolderType, 
							 kDontCreateFolder, 
							 &fsRef);
		if (error) return error;

		error = FSRefMakePath(&fsRef, (unsigned char*)fullPath, maxPathLength-1);

		if (PIstrlcat(fullPath, "/", maxPathLength) >= maxPathLength)
			error = kSPBadParameterError;
		fullPath[maxPathLength-1]= '\0';

	#else
		
		if (MAX_PATH <= maxPathLength)
		{
			HRESULT hr = SHGetFolderPath( NULL, CSIDL_DESKTOPDIRECTORY, NULL, 0, fullPath );
			if (FAILED(hr))
			{
				fullPath[0] = 0;
				error = kSPBadParameterError;
			}
			else
			{
				if (PIstrlcat(fullPath, "\\", maxPathLength) >= (size_t)maxPathLength)
					error = kSPBadParameterError;
				fullPath[maxPathLength-1]= '\0';
			}
		} else {
			error = kSPBadParameterError;
		}

	#endif
	
	return error;
}
コード例 #30
0
ファイル: ftmac.c プロジェクト: 32767/libgdx
  FT_GetFilePath_From_Mac_ATS_Name( const char*  fontName,
                                    UInt8*       path,
                                    UInt32       maxPathSize,
                                    FT_Long*     face_index )
  {
    FSRef     ref;
    FT_Error  err;


    err = FT_GetFileRef_From_Mac_ATS_Name( fontName, &ref, face_index );
    if ( FT_Err_Ok != err )
      return err;

    if ( noErr != FSRefMakePath( &ref, path, maxPathSize ) )
      return FT_Err_Unknown_File_Format;

    return FT_Err_Ok;
  }