FSRef transition
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28878 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -155,15 +155,7 @@ bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec) ;
|
|||||||
|
|
||||||
// filefn.h
|
// filefn.h
|
||||||
WXDLLEXPORT wxString wxMacFSSpec2MacFilename( const FSSpec *spec ) ;
|
WXDLLEXPORT wxString wxMacFSSpec2MacFilename( const FSSpec *spec ) ;
|
||||||
WXDLLEXPORT void wxMacFilename2FSSpec( const char *path , FSSpec *spec ) ;
|
WXDLLEXPORT void wxMacFilename2FSSpec( const wxString &path , FSSpec *spec ) ;
|
||||||
WXDLLEXPORT void wxMacFilename2FSSpec( const wxChar *path , FSSpec *spec ) ;
|
|
||||||
# ifndef __DARWIN__
|
|
||||||
// Mac file names are POSIX (Unix style) under Darwin, so these are not needed
|
|
||||||
WXDLLEXPORT wxString wxMacFSSpec2UnixFilename( const FSSpec *spec ) ;
|
|
||||||
WXDLLEXPORT void wxUnixFilename2FSSpec( const char *path , FSSpec *spec ) ;
|
|
||||||
WXDLLEXPORT wxString wxMac2UnixFilename( const char *s) ;
|
|
||||||
WXDLLEXPORT wxString wxUnix2MacFilename( const char *s);
|
|
||||||
# endif
|
|
||||||
|
|
||||||
// utils.h
|
// utils.h
|
||||||
WXDLLEXPORT wxString wxMacFindFolder(short vRefNum,
|
WXDLLEXPORT wxString wxMacFindFolder(short vRefNum,
|
||||||
@@ -564,11 +556,11 @@ void wxMacWakeUp() ;
|
|||||||
|
|
||||||
ControlRef wxMacFindControlUnderMouse( Point location , WindowRef window , ControlPartCode *outPart ) ;
|
ControlRef wxMacFindControlUnderMouse( Point location , WindowRef window , ControlPartCode *outPart ) ;
|
||||||
|
|
||||||
#ifdef TARGET_API_MAC_OSX
|
// filefn.cpp
|
||||||
#define kDefaultPathStyle kCFURLPOSIXPathStyle
|
|
||||||
#else
|
wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathComponent = NULL ) ;
|
||||||
#define kDefaultPathStyle kCFURLHFSPathStyle
|
OSStatus wxMacPathToFSRef( const wxString&path , FSRef *fsRef ) ;
|
||||||
#endif
|
wxString wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname ) ;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// _WX_PRIVATE_H_
|
// _WX_PRIVATE_H_
|
||||||
|
@@ -228,7 +228,7 @@ bool wxFile::Create(const wxChar *szFileName, bool bOverwrite, int accessMode)
|
|||||||
// otherwise we only create the new file and fail if it already exists
|
// otherwise we only create the new file and fail if it already exists
|
||||||
#if defined(__WXMAC__) && !defined(__UNIX__) && !wxUSE_UNICODE
|
#if defined(__WXMAC__) && !defined(__UNIX__) && !wxUSE_UNICODE
|
||||||
// Dominic Mazzoni [dmazzoni+@cs.cmu.edu] reports that open is still broken on the mac, so we replace
|
// Dominic Mazzoni [dmazzoni+@cs.cmu.edu] reports that open is still broken on the mac, so we replace
|
||||||
// int fd = open(wxUnix2MacFilename( szFileName ), O_CREAT | (bOverwrite ? O_TRUNC : O_EXCL), access);
|
// int fd = open( szFileName , O_CREAT | (bOverwrite ? O_TRUNC : O_EXCL), access);
|
||||||
int fd = creat( szFileName , accessMode);
|
int fd = creat( szFileName , accessMode);
|
||||||
#else
|
#else
|
||||||
#ifdef __WXWINCE__
|
#ifdef __WXWINCE__
|
||||||
|
@@ -999,15 +999,19 @@ bool wxFileConfig::Flush(bool /* bCurrentOnly */)
|
|||||||
#if defined(__WXMAC__)
|
#if defined(__WXMAC__)
|
||||||
if ( ret )
|
if ( ret )
|
||||||
{
|
{
|
||||||
FSSpec spec ;
|
FSRef fsRef ;
|
||||||
|
FSCatalogInfo catInfo;
|
||||||
|
FileInfo *finfo ;
|
||||||
|
|
||||||
wxMacFilename2FSSpec( m_strLocalFile , &spec ) ;
|
if ( wxMacPathToFSRef( m_strLocalFile , &fsRef ) == noErr )
|
||||||
FInfo finfo ;
|
|
||||||
if ( FSpGetFInfo( &spec , &finfo ) == noErr )
|
|
||||||
{
|
{
|
||||||
finfo.fdType = 'TEXT' ;
|
if ( FSGetCatalogInfo (&fsRef, kFSCatInfoFinderInfo, &catInfo, NULL, NULL, NULL) == noErr )
|
||||||
finfo.fdCreator = 'ttxt' ;
|
{
|
||||||
FSpSetFInfo( &spec , &finfo ) ;
|
finfo = (FileInfo*)&catInfo.finderInfo;
|
||||||
|
finfo->fileType = 'TEXT' ;
|
||||||
|
finfo->fileCreator = 'ttxt' ;
|
||||||
|
FSSetCatalogInfo( &fsRef, kFSCatInfoFinderInfo, &catInfo ) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // __WXMAC__
|
#endif // __WXMAC__
|
||||||
|
@@ -164,14 +164,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
# ifdef __DARWIN__
|
|
||||||
# include "MoreFilesX.h"
|
# include "MoreFilesX.h"
|
||||||
# else
|
|
||||||
# include "MoreFiles.h"
|
|
||||||
# include "MoreFilesExtras.h"
|
|
||||||
# include "FullPath.h"
|
|
||||||
# include "FSpCompat.h"
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -915,220 +908,72 @@ wxString wxPathOnly (const wxString& path)
|
|||||||
// Also, convert to lower case, since case is significant in UNIX.
|
// Also, convert to lower case, since case is significant in UNIX.
|
||||||
|
|
||||||
#if defined(__WXMAC__)
|
#if defined(__WXMAC__)
|
||||||
wxString wxMacFSSpec2MacFilename( const FSSpec *spec )
|
|
||||||
{
|
|
||||||
#ifdef __DARWIN__
|
|
||||||
int i;
|
|
||||||
int j;
|
|
||||||
OSErr theErr;
|
|
||||||
OSStatus theStatus = noErr;
|
|
||||||
Boolean isDirectory = FALSE;
|
|
||||||
Str255 theParentPath = "\p";
|
|
||||||
FSSpec theParentSpec;
|
|
||||||
FSRef theParentRef;
|
|
||||||
FSRef theRef ;
|
|
||||||
char theFileName[FILENAME_MAX];
|
|
||||||
char thePath[FILENAME_MAX];
|
|
||||||
|
|
||||||
// we loose the long filename by merely copying the spec->name
|
#if TARGET_API_MAC_OSX
|
||||||
// so try the built-ins, which only work if the file exists, but still...
|
#define kDefaultPathStyle kCFURLPOSIXPathStyle
|
||||||
|
#else
|
||||||
|
#define kDefaultPathStyle kCFURLHFSPathStyle
|
||||||
|
#endif
|
||||||
|
|
||||||
theErr = FSpMakeFSRef(spec, &theRef);
|
wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathComponent )
|
||||||
if ( theErr == noErr )
|
|
||||||
{
|
{
|
||||||
CFURLRef fullURLRef;
|
CFURLRef fullURLRef;
|
||||||
fullURLRef = ::CFURLCreateFromFSRef(NULL, &theRef);
|
fullURLRef = CFURLCreateFromFSRef(NULL, fsRef);
|
||||||
#ifdef __UNIX__
|
if ( additionalPathComponent )
|
||||||
CFURLPathStyle pathstyle = kCFURLPOSIXPathStyle;
|
{
|
||||||
#else
|
CFURLRef parentURLRef = fullURLRef ;
|
||||||
CFURLPathStyle pathstyle = kCFURLHFSPathStyle;
|
fullURLRef = CFURLCreateCopyAppendingPathComponent(NULL, parentURLRef,
|
||||||
#endif
|
additionalPathComponent,false);
|
||||||
CFStringRef cfString = CFURLCopyFileSystemPath(fullURLRef, pathstyle);
|
CFRelease( parentURLRef ) ;
|
||||||
::CFRelease( fullURLRef ) ;
|
}
|
||||||
|
CFStringRef cfString = CFURLCopyFileSystemPath(fullURLRef, kDefaultPathStyle);
|
||||||
|
CFRelease( fullURLRef ) ;
|
||||||
return wxMacCFStringHolder(cfString).AsString(wxLocale::GetSystemEncoding());
|
return wxMacCFStringHolder(cfString).AsString(wxLocale::GetSystemEncoding());
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(thePath, "");
|
OSStatus wxMacPathToFSRef( const wxString&path , FSRef *fsRef )
|
||||||
|
|
||||||
// GD: Separate file name from path and make a FSRef to the parent
|
|
||||||
// directory. This is necessary since FSRefs cannot reference files
|
|
||||||
// that have not yet been created.
|
|
||||||
// Based on example code from Apple Technical Note TN2022
|
|
||||||
// http://developer.apple.com/technotes/tn/tn2022.html
|
|
||||||
|
|
||||||
// check whether we are converting a directory
|
|
||||||
isDirectory = ((spec->name)[spec->name[0]] == ':');
|
|
||||||
// count length of file name
|
|
||||||
for (i = spec->name[0] - (isDirectory ? 1 : 0); ((spec->name[i] != ':') && (i > 0)); i--);
|
|
||||||
// copy file name
|
|
||||||
// prepend path separator since it will later be appended to the path
|
|
||||||
theFileName[0] = wxFILE_SEP_PATH;
|
|
||||||
for (j = i + 1; j <= spec->name[0] - (isDirectory ? 1 : 0); j++) {
|
|
||||||
theFileName[j - i] = spec->name[j];
|
|
||||||
}
|
|
||||||
theFileName[j - i] = '\0';
|
|
||||||
// copy path if any
|
|
||||||
for (j = 1; j <= i; j++) {
|
|
||||||
theParentPath[++theParentPath[0]] = spec->name[j];
|
|
||||||
}
|
|
||||||
theErr = FSMakeFSSpec(spec->vRefNum, spec->parID, theParentPath, &theParentSpec);
|
|
||||||
if (theErr == noErr) {
|
|
||||||
// convert the FSSpec to an FSRef
|
|
||||||
theErr = FSpMakeFSRef(&theParentSpec, &theParentRef);
|
|
||||||
}
|
|
||||||
if (theErr == noErr) {
|
|
||||||
// get the POSIX path associated with the FSRef
|
|
||||||
theStatus = FSRefMakePath(&theParentRef,
|
|
||||||
(UInt8 *)thePath, sizeof(thePath));
|
|
||||||
}
|
|
||||||
if (theStatus == noErr) {
|
|
||||||
// append file name to path
|
|
||||||
// includes previously prepended path separator
|
|
||||||
strcat(thePath, theFileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// create path string for return value
|
|
||||||
wxString result( thePath , wxConvLocal) ;
|
|
||||||
#else
|
|
||||||
Handle myPath ;
|
|
||||||
short length ;
|
|
||||||
|
|
||||||
// get length of path and allocate handle
|
|
||||||
FSpGetFullPath( spec , &length , &myPath ) ;
|
|
||||||
::SetHandleSize( myPath , length + 1 ) ;
|
|
||||||
::HLock( myPath ) ;
|
|
||||||
(*myPath)[length] = 0 ;
|
|
||||||
if ((length > 0) && ((*myPath)[length-1] == ':'))
|
|
||||||
(*myPath)[length-1] = 0 ;
|
|
||||||
|
|
||||||
// create path string for return value
|
|
||||||
wxString result( *myPath , wxConvLocal) ;
|
|
||||||
|
|
||||||
// free allocated handle
|
|
||||||
::HUnlock( myPath ) ;
|
|
||||||
::DisposeHandle( myPath ) ;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return result ;
|
|
||||||
}
|
|
||||||
#ifndef __DARWIN__
|
|
||||||
// Mac file names are POSIX (Unix style) under Darwin
|
|
||||||
// therefore the conversion functions below are not needed
|
|
||||||
|
|
||||||
static wxChar sMacFileNameConversion[ 1000 ] ;
|
|
||||||
static char scMacFileNameConversion[ 1000 ] ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
void wxMacFilename2FSSpec( const char *path , FSSpec *spec )
|
|
||||||
{
|
{
|
||||||
OSStatus err = noErr ;
|
OSStatus err = noErr ;
|
||||||
#ifdef __DARWIN__
|
CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, wxMacCFStringHolder(path ,wxLocale::GetSystemEncoding() ) , kDefaultPathStyle, false);
|
||||||
FSRef theRef;
|
if ( NULL != url )
|
||||||
|
|
||||||
// get the FSRef associated with the POSIX path
|
|
||||||
err = FSPathMakeRef((const UInt8 *) path, &theRef, NULL);
|
|
||||||
// convert the FSRef to an FSSpec
|
|
||||||
err = FSGetCatalogInfo(&theRef, kFSCatInfoNone, NULL, NULL, spec, NULL);
|
|
||||||
#else
|
|
||||||
if ( strchr( path , ':' ) == NULL )
|
|
||||||
{
|
{
|
||||||
// try whether it is a volume / or a mounted volume
|
if ( CFURLGetFSRef(url, fsRef) == false )
|
||||||
strncpy( scMacFileNameConversion , path , 1000 ) ;
|
err = fnfErr ;
|
||||||
scMacFileNameConversion[998] = 0 ;
|
CFRelease( url ) ;
|
||||||
strcat( scMacFileNameConversion , ":" ) ;
|
|
||||||
err = FSpLocationFromFullPath( strlen(scMacFileNameConversion) , scMacFileNameConversion , spec ) ;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
err = FSpLocationFromFullPath( strlen(path) , path , spec ) ;
|
err = fnfErr ;
|
||||||
}
|
}
|
||||||
#endif
|
return err ;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if wxUSE_UNICODE
|
wxString wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname )
|
||||||
WXDLLEXPORT void wxMacFilename2FSSpec( const wxChar *path , FSSpec *spec )
|
|
||||||
{
|
{
|
||||||
return wxMacFilename2FSSpec( wxConvFile.cWC2MB(path) , spec ) ;
|
CFStringRef cfname = CFStringCreateWithCharacters( kCFAllocatorDefault,
|
||||||
}
|
uniname->unicode,
|
||||||
#endif
|
uniname->length );
|
||||||
|
return wxMacCFStringHolder(cfname).AsString() ;
|
||||||
#ifndef __DARWIN__
|
|
||||||
|
|
||||||
wxString wxMac2UnixFilename (const wxChar *str)
|
|
||||||
{
|
|
||||||
wxChar *s = sMacFileNameConversion ;
|
|
||||||
wxStrcpy( s , str ) ;
|
|
||||||
if (s)
|
|
||||||
{
|
|
||||||
memmove( s+1 , s ,wxStrlen( s ) + 1 * sizeof(wxChar)) ;
|
|
||||||
if ( *s == ':' )
|
|
||||||
*s = '.' ;
|
|
||||||
else
|
|
||||||
*s = '/' ;
|
|
||||||
|
|
||||||
while (*s)
|
|
||||||
{
|
|
||||||
if (*s == ':')
|
|
||||||
*s = '/';
|
|
||||||
else
|
|
||||||
*s = wxTolower(*s); // Case INDEPENDENT
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return wxString(sMacFileNameConversion) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxUnix2MacFilename (const wxChar *str)
|
wxString wxMacFSSpec2MacFilename( const FSSpec *spec )
|
||||||
{
|
{
|
||||||
wxChar *s = sMacFileNameConversion ;
|
FSRef fsRef ;
|
||||||
wxStrcpy( s , str ) ;
|
if ( FSpMakeFSRef( spec , &fsRef) == noErr )
|
||||||
if (s)
|
|
||||||
{
|
{
|
||||||
if ( *s == '.' )
|
return wxMacFSRefToPath( &fsRef ) ;
|
||||||
{
|
|
||||||
// relative path , since it goes on with slash which is translated to a :
|
|
||||||
memmove( s , s+1 ,wxStrlen( s ) * sizeof(wxChar)) ;
|
|
||||||
}
|
}
|
||||||
else if ( *s == '/' )
|
return wxEmptyString ;
|
||||||
{
|
|
||||||
// absolute path -> on mac just start with the drive name
|
|
||||||
memmove( s , s+1 ,wxStrlen( s ) * sizeof(wxChar) ) ;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wxASSERT_MSG( 1 , wxT("unkown path beginning") ) ;
|
|
||||||
}
|
|
||||||
while (*s)
|
|
||||||
{
|
|
||||||
if (*s == '/' || *s == '\\')
|
|
||||||
{
|
|
||||||
// convert any back-directory situations
|
|
||||||
if ( *(s+1) == '.' && *(s+2) == '.' && ( (*(s+3) == '/' || *(s+3) == '\\') ) )
|
|
||||||
{
|
|
||||||
*s = ':';
|
|
||||||
memmove( s+1 , s+3 ,(wxStrlen( s+3 ) + 1)*sizeof(wxChar) ) ;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
*s = ':';
|
|
||||||
}
|
|
||||||
s++ ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return wxString(sMacFileNameConversion) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxMacFSSpec2UnixFilename( const FSSpec *spec )
|
void wxMacFilename2FSSpec( const wxString& path , FSSpec *spec )
|
||||||
{
|
{
|
||||||
return wxMac2UnixFilename( wxMacFSSpec2MacFilename( spec) ) ;
|
OSStatus err = noErr ;
|
||||||
|
FSRef fsRef ;
|
||||||
|
wxMacPathToFSRef( path , &fsRef ) ;
|
||||||
|
err = FSRefMakeFSSpec( &fsRef , spec ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxUnixFilename2FSSpec( const wxChar *path , FSSpec *spec )
|
|
||||||
{
|
|
||||||
wxString var = wxUnix2MacFilename( path ) ;
|
|
||||||
wxMacFilename2FSSpec( var , spec ) ;
|
|
||||||
}
|
|
||||||
#endif // ! __DARWIN__
|
|
||||||
|
|
||||||
#endif // __WXMAC__
|
#endif // __WXMAC__
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -1577,28 +1422,15 @@ wxChar *wxGetWorkingDirectory(wxChar *buf, int sz)
|
|||||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||||
ok = _getcwd(cbuf, sz) != NULL;
|
ok = _getcwd(cbuf, sz) != NULL;
|
||||||
#elif defined(__WXMAC__) && !defined(__DARWIN__)
|
#elif defined(__WXMAC__) && !defined(__DARWIN__)
|
||||||
FSSpec cwdSpec ;
|
char lbuf[1024] ;
|
||||||
FCBPBRec pb;
|
if ( getcwd( lbuf , sizeof( lbuf ) ) )
|
||||||
OSErr error;
|
|
||||||
Str255 fileName ;
|
|
||||||
pb.ioNamePtr = (StringPtr) &fileName;
|
|
||||||
pb.ioVRefNum = 0;
|
|
||||||
pb.ioRefNum = LMGetCurApRefNum();
|
|
||||||
pb.ioFCBIndx = 0;
|
|
||||||
error = PBGetFCBInfoSync(&pb);
|
|
||||||
if ( error == noErr )
|
|
||||||
{
|
{
|
||||||
cwdSpec.vRefNum = pb.ioFCBVRefNum;
|
wxString res( lbuf , *wxConvCurrent ) ;
|
||||||
cwdSpec.parID = pb.ioFCBParID;
|
|
||||||
cwdSpec.name[0] = 0 ;
|
|
||||||
wxString res = wxMacFSSpec2MacFilename( &cwdSpec ) ;
|
|
||||||
wxStrcpy( buf , res ) ;
|
wxStrcpy( buf , res ) ;
|
||||||
ok = true;
|
ok = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
ok = false ;
|
ok = false ;
|
||||||
}
|
|
||||||
#elif defined(__OS2__)
|
#elif defined(__OS2__)
|
||||||
APIRET rc;
|
APIRET rc;
|
||||||
ULONG ulDriveNum = 0;
|
ULONG ulDriveNum = 0;
|
||||||
|
@@ -2031,32 +2031,45 @@ static void MacEnsureDefaultExtensionsLoaded()
|
|||||||
gMacDefaultExtensionsInited = true ;
|
gMacDefaultExtensionsInited = true ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxFileName::MacSetTypeAndCreator( wxUint32 type , wxUint32 creator )
|
bool wxFileName::MacSetTypeAndCreator( wxUint32 type , wxUint32 creator )
|
||||||
{
|
{
|
||||||
FInfo fndrInfo ;
|
FSRef fsRef ;
|
||||||
FSSpec spec ;
|
FSCatalogInfo catInfo;
|
||||||
wxMacFilename2FSSpec(GetFullPath(),&spec) ;
|
FileInfo *finfo ;
|
||||||
OSErr err = FSpGetFInfo( &spec , &fndrInfo ) ;
|
|
||||||
wxCHECK( err == noErr , false ) ;
|
|
||||||
|
|
||||||
fndrInfo.fdType = type ;
|
if ( wxMacPathToFSRef( GetFullPath() , &fsRef ) == noErr )
|
||||||
fndrInfo.fdCreator = creator ;
|
{
|
||||||
FSpSetFInfo( &spec , &fndrInfo ) ;
|
if ( FSGetCatalogInfo (&fsRef, kFSCatInfoFinderInfo, &catInfo, NULL, NULL, NULL) == noErr )
|
||||||
|
{
|
||||||
|
finfo = (FileInfo*)&catInfo.finderInfo;
|
||||||
|
finfo->fileType = type ;
|
||||||
|
finfo->fileCreator = creator ;
|
||||||
|
FSSetCatalogInfo( &fsRef, kFSCatInfoFinderInfo, &catInfo ) ;
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
|
||||||
bool wxFileName::MacGetTypeAndCreator( wxUint32 *type , wxUint32 *creator )
|
bool wxFileName::MacGetTypeAndCreator( wxUint32 *type , wxUint32 *creator )
|
||||||
{
|
{
|
||||||
FInfo fndrInfo ;
|
FSRef fsRef ;
|
||||||
FSSpec spec ;
|
FSCatalogInfo catInfo;
|
||||||
wxMacFilename2FSSpec(GetFullPath(),&spec) ;
|
FileInfo *finfo ;
|
||||||
OSErr err = FSpGetFInfo( &spec , &fndrInfo ) ;
|
|
||||||
wxCHECK( err == noErr , false ) ;
|
|
||||||
|
|
||||||
*type = fndrInfo.fdType ;
|
if ( wxMacPathToFSRef( GetFullPath() , &fsRef ) == noErr )
|
||||||
*creator = fndrInfo.fdCreator ;
|
{
|
||||||
|
if ( FSGetCatalogInfo (&fsRef, kFSCatInfoFinderInfo, &catInfo, NULL, NULL, NULL) == noErr )
|
||||||
|
{
|
||||||
|
finfo = (FileInfo*)&catInfo.finderInfo;
|
||||||
|
*type = finfo->fileType ;
|
||||||
|
*creator = finfo->fileCreator ;
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
|
||||||
bool wxFileName::MacSetDefaultTypeAndCreator()
|
bool wxFileName::MacSetDefaultTypeAndCreator()
|
||||||
{
|
{
|
||||||
|
@@ -85,11 +85,7 @@
|
|||||||
#endif // __OS2__
|
#endif // __OS2__
|
||||||
|
|
||||||
#if defined(__WXMAC__)
|
#if defined(__WXMAC__)
|
||||||
# ifdef __DARWIN__
|
|
||||||
# include "MoreFilesX.h"
|
# include "MoreFilesX.h"
|
||||||
# else
|
|
||||||
# include "MoreFilesExtras.h"
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
#ifdef __BORLANDC__
|
||||||
@@ -202,87 +198,36 @@ size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayI
|
|||||||
#endif // __WIN32__/!__WIN32__
|
#endif // __WIN32__/!__WIN32__
|
||||||
|
|
||||||
#elif defined(__WXMAC__)
|
#elif defined(__WXMAC__)
|
||||||
#ifdef __DARWIN__
|
|
||||||
FSRef **theVolRefs;
|
|
||||||
ItemCount theVolCount;
|
|
||||||
char thePath[FILENAME_MAX];
|
|
||||||
|
|
||||||
if (FSGetMountedVolumes(&theVolRefs, &theVolCount) == noErr) {
|
ItemCount volumeIndex = 1;
|
||||||
ItemCount index;
|
OSErr err = noErr ;
|
||||||
::HLock( (Handle)theVolRefs ) ;
|
|
||||||
for (index = 0; index < theVolCount; ++index) {
|
|
||||||
// get the POSIX path associated with the FSRef
|
|
||||||
if ( FSRefMakePath(&((*theVolRefs)[index]),
|
|
||||||
(UInt8 *)thePath, sizeof(thePath)) != noErr ) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// add path separator at end if necessary
|
|
||||||
wxString path( thePath , wxConvLocal) ;
|
|
||||||
if (path.Last() != wxFILE_SEP_PATH) {
|
|
||||||
path += wxFILE_SEP_PATH;
|
|
||||||
}
|
|
||||||
// get Mac volume name for display
|
|
||||||
FSVolumeRefNum vRefNum ;
|
|
||||||
HFSUniStr255 volumeName ;
|
|
||||||
|
|
||||||
if ( FSGetVRefNum(&((*theVolRefs)[index]), &vRefNum) != noErr ) {
|
while( noErr == err )
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ( FSGetVInfo(vRefNum, &volumeName, NULL, NULL) != noErr ) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// get C string from Unicode HFS name
|
|
||||||
// see: http://developer.apple.com/carbon/tipsandtricks.html
|
|
||||||
CFStringRef cfstr = CFStringCreateWithCharacters( kCFAllocatorDefault,
|
|
||||||
volumeName.unicode,
|
|
||||||
volumeName.length );
|
|
||||||
// Do something with str
|
|
||||||
char *cstr = NewPtr(CFStringGetLength(cfstr) + 1);
|
|
||||||
if (( cstr == NULL ) ||
|
|
||||||
!CFStringGetCString(cfstr, cstr, CFStringGetLength(cfstr) + 1,
|
|
||||||
kCFStringEncodingMacRoman))
|
|
||||||
{
|
{
|
||||||
CFRelease( cfstr );
|
HFSUniStr255 volumeName ;
|
||||||
continue;
|
FSRef fsRef ;
|
||||||
}
|
FSVolumeInfo volumeInfo ;
|
||||||
wxString name( cstr , wxConvLocal );
|
err = FSGetVolumeInfo(0, volumeIndex, NULL, kFSVolInfoFlags , &volumeInfo , &volumeName, &fsRef);
|
||||||
DisposePtr( cstr );
|
if( noErr == err )
|
||||||
CFRelease( cfstr );
|
{
|
||||||
|
wxString path = wxMacFSRefToPath( &fsRef ) ;
|
||||||
|
wxString name = wxMacHFSUniStrToString( &volumeName ) ;
|
||||||
|
|
||||||
GetVolParmsInfoBuffer volParmsInfo;
|
if ( (volumeInfo.flags & kFSVolFlagSoftwareLockedMask) || (volumeInfo.flags & kFSVolFlagHardwareLockedMask) )
|
||||||
UInt32 actualSize;
|
{
|
||||||
if ( FSGetVolParms(vRefNum, sizeof(volParmsInfo), &volParmsInfo, &actualSize) != noErr ) {
|
icon_ids.Add(wxFileIconsTable::cdrom);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
icon_ids.Add(wxFileIconsTable::drive);
|
||||||
|
}
|
||||||
|
// todo other removable
|
||||||
|
|
||||||
paths.Add(path);
|
paths.Add(path);
|
||||||
names.Add(name);
|
names.Add(name);
|
||||||
|
volumeIndex++ ;
|
||||||
if ( VolIsEjectable(&volParmsInfo) )
|
|
||||||
icon_ids.Add(wxFileIconsTable::cdrom);
|
|
||||||
else
|
|
||||||
icon_ids.Add(wxFileIconsTable::drive);
|
|
||||||
}
|
}
|
||||||
::HUnlock( (Handle)theVolRefs );
|
|
||||||
::DisposeHandle( (Handle)theVolRefs );
|
|
||||||
}
|
}
|
||||||
#else // !__DARWIN__
|
|
||||||
FSSpec volume;
|
|
||||||
short index = 1;
|
|
||||||
while(1)
|
|
||||||
{
|
|
||||||
short actualCount = 0 ;
|
|
||||||
if (OnLine(&volume, 1, &actualCount, &index ) != noErr || actualCount==0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxString name = wxMacFSSpec2MacFilename( &volume );
|
|
||||||
paths.Add(name + wxFILE_SEP_PATH);
|
|
||||||
names.Add(name);
|
|
||||||
icon_ids.Add(wxFileIconsTable::drive);
|
|
||||||
}
|
|
||||||
#endif // __DARWIN__
|
|
||||||
|
|
||||||
#elif defined(__UNIX__)
|
#elif defined(__UNIX__)
|
||||||
paths.Add(wxT("/"));
|
paths.Add(wxT("/"));
|
||||||
|
@@ -165,7 +165,6 @@ short wxApp::MacHandleAEODoc(const WXEVENTREF event, WXEVENTREF WXUNUSED(reply))
|
|||||||
DescType returnedType;
|
DescType returnedType;
|
||||||
Size actualSize;
|
Size actualSize;
|
||||||
long itemsInList;
|
long itemsInList;
|
||||||
FSSpec theSpec;
|
|
||||||
OSErr err;
|
OSErr err;
|
||||||
short i;
|
short i;
|
||||||
err = AEGetParamDesc((AppleEvent *)event, keyDirectObject, typeAEList,&docList);
|
err = AEGetParamDesc((AppleEvent *)event, keyDirectObject, typeAEList,&docList);
|
||||||
@@ -181,10 +180,15 @@ short wxApp::MacHandleAEODoc(const WXEVENTREF event, WXEVENTREF WXUNUSED(reply))
|
|||||||
PSN.lowLongOfPSN = kCurrentProcess ;
|
PSN.lowLongOfPSN = kCurrentProcess ;
|
||||||
SetFrontProcess( &PSN ) ;
|
SetFrontProcess( &PSN ) ;
|
||||||
|
|
||||||
for (i = 1; i <= itemsInList; i++) {
|
for (i = 1; i <= itemsInList; i++)
|
||||||
AEGetNthPtr(&docList, i, typeFSS, &keywd, &returnedType,
|
{
|
||||||
(Ptr) & theSpec, sizeof(theSpec), &actualSize);
|
wxString fName ;
|
||||||
wxString fName = wxMacFSSpec2MacFilename(&theSpec);
|
|
||||||
|
FSRef theRef ;
|
||||||
|
AEGetNthPtr(&docList, i, typeFSRef, &keywd, &returnedType,
|
||||||
|
(Ptr) & theRef, sizeof(theRef), &actualSize);
|
||||||
|
fName = wxMacFSRefToPath( &theRef ) ;
|
||||||
|
|
||||||
MacOpenFile(fName);
|
MacOpenFile(fName);
|
||||||
}
|
}
|
||||||
return noErr;
|
return noErr;
|
||||||
@@ -199,7 +203,6 @@ short wxApp::MacHandleAEPDoc(const WXEVENTREF event , WXEVENTREF WXUNUSED(reply)
|
|||||||
DescType returnedType;
|
DescType returnedType;
|
||||||
Size actualSize;
|
Size actualSize;
|
||||||
long itemsInList;
|
long itemsInList;
|
||||||
FSSpec theSpec;
|
|
||||||
OSErr err;
|
OSErr err;
|
||||||
short i;
|
short i;
|
||||||
err = AEGetParamDesc((AppleEvent *)event, keyDirectObject, typeAEList,&docList);
|
err = AEGetParamDesc((AppleEvent *)event, keyDirectObject, typeAEList,&docList);
|
||||||
@@ -216,9 +219,13 @@ short wxApp::MacHandleAEPDoc(const WXEVENTREF event , WXEVENTREF WXUNUSED(reply)
|
|||||||
SetFrontProcess( &PSN ) ;
|
SetFrontProcess( &PSN ) ;
|
||||||
|
|
||||||
for (i = 1; i <= itemsInList; i++) {
|
for (i = 1; i <= itemsInList; i++) {
|
||||||
AEGetNthPtr(&docList, i, typeFSS, &keywd, &returnedType,
|
wxString fName ;
|
||||||
(Ptr) & theSpec, sizeof(theSpec), &actualSize);
|
|
||||||
wxString fName = wxMacFSSpec2MacFilename(&theSpec);
|
FSRef theRef ;
|
||||||
|
AEGetNthPtr(&docList, i, typeFSRef, &keywd, &returnedType,
|
||||||
|
(Ptr) & theRef, sizeof(theRef), &actualSize);
|
||||||
|
fName = wxMacFSRefToPath( &theRef ) ;
|
||||||
|
|
||||||
MacPrintFile(fName);
|
MacPrintFile(fName);
|
||||||
}
|
}
|
||||||
return noErr;
|
return noErr;
|
||||||
|
@@ -98,47 +98,20 @@ int wxDirDialog::ShowModal()
|
|||||||
|
|
||||||
if (mNavReply.validRecord) { // User chose a folder
|
if (mNavReply.validRecord) { // User chose a folder
|
||||||
|
|
||||||
FSSpec folderInfo;
|
FSRef folderInfo;
|
||||||
FSSpec outFileSpec ;
|
|
||||||
AEDesc specDesc ;
|
AEDesc specDesc ;
|
||||||
|
|
||||||
OSErr err = ::AECoerceDesc( &mNavReply.selection , typeFSS, &specDesc);
|
OSErr err = ::AECoerceDesc( &mNavReply.selection , typeFSRef, &specDesc);
|
||||||
if ( err != noErr ) {
|
if ( err != noErr ) {
|
||||||
m_path = wxT("") ;
|
m_path = wxT("") ;
|
||||||
return wxID_CANCEL ;
|
return wxID_CANCEL ;
|
||||||
}
|
}
|
||||||
folderInfo = **(FSSpec**) specDesc.dataHandle;
|
folderInfo = **(FSRef**) specDesc.dataHandle;
|
||||||
if (specDesc.dataHandle != nil) {
|
if (specDesc.dataHandle != nil) {
|
||||||
::AEDisposeDesc(&specDesc);
|
::AEDisposeDesc(&specDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// mNavReply.GetFileSpec(folderInfo);
|
m_path = wxMacFSRefToPath( &folderInfo ) ;
|
||||||
|
|
||||||
// The FSSpec from NavChooseFolder is NOT the file spec
|
|
||||||
// for the folder. The parID field is actually the DirID
|
|
||||||
// of the folder itself, not the folder's parent, and
|
|
||||||
// the name field is empty. We must call PBGetCatInfo
|
|
||||||
// to get the parent DirID and folder name
|
|
||||||
|
|
||||||
Str255 name;
|
|
||||||
CInfoPBRec thePB; // Directory Info Parameter Block
|
|
||||||
thePB.dirInfo.ioCompletion = nil;
|
|
||||||
thePB.dirInfo.ioVRefNum = folderInfo.vRefNum; // Volume is right
|
|
||||||
thePB.dirInfo.ioDrDirID = folderInfo.parID; // Folder's DirID
|
|
||||||
thePB.dirInfo.ioNamePtr = name;
|
|
||||||
thePB.dirInfo.ioFDirIndex = -1; // Lookup using Volume and DirID
|
|
||||||
|
|
||||||
err = ::PBGetCatInfoSync(&thePB);
|
|
||||||
if ( err != noErr ) {
|
|
||||||
m_path = wxT("") ;
|
|
||||||
return wxID_CANCEL ;
|
|
||||||
}
|
|
||||||
// Create cannonical FSSpec
|
|
||||||
::FSMakeFSSpec(thePB.dirInfo.ioVRefNum, thePB.dirInfo.ioDrParID,
|
|
||||||
name, &outFileSpec);
|
|
||||||
|
|
||||||
// outFolderDirID = thePB.dirInfo.ioDrDirID;
|
|
||||||
m_path = wxMacFSSpec2MacFilename( &outFileSpec ) ;
|
|
||||||
return wxID_OK ;
|
return wxID_OK ;
|
||||||
}
|
}
|
||||||
return wxID_CANCEL;
|
return wxID_CANCEL;
|
||||||
|
@@ -40,14 +40,10 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "wx/filename.h"
|
||||||
#include "wx/mac/private.h"
|
#include "wx/mac/private.h"
|
||||||
|
|
||||||
#ifdef __DARWIN__
|
|
||||||
#include "MoreFilesX.h"
|
#include "MoreFilesX.h"
|
||||||
#else
|
|
||||||
# include "MoreFiles.h"
|
|
||||||
# include "MoreFilesExtras.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// constants
|
// constants
|
||||||
@@ -74,6 +70,7 @@ public:
|
|||||||
wxDirData(const wxString& dirname);
|
wxDirData(const wxString& dirname);
|
||||||
~wxDirData();
|
~wxDirData();
|
||||||
|
|
||||||
|
void Close() ;
|
||||||
void SetFileSpec(const wxString& filespec) { m_filespec = filespec; }
|
void SetFileSpec(const wxString& filespec) { m_filespec = filespec; }
|
||||||
void SetFlags(int flags) { m_flags = flags; }
|
void SetFlags(int flags) { m_flags = flags; }
|
||||||
|
|
||||||
@@ -83,11 +80,7 @@ public:
|
|||||||
const wxString& GetName() const { return m_dirname; }
|
const wxString& GetName() const { return m_dirname; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CInfoPBRec m_CPB ;
|
FSIterator m_iterator ;
|
||||||
wxInt16 m_index ;
|
|
||||||
long m_dirId ;
|
|
||||||
Str255 m_name ;
|
|
||||||
Boolean m_isDir ;
|
|
||||||
|
|
||||||
wxString m_dirname;
|
wxString m_dirname;
|
||||||
wxString m_filespec;
|
wxString m_filespec;
|
||||||
@@ -106,8 +99,6 @@ private:
|
|||||||
wxDirData::wxDirData(const wxString& dirname)
|
wxDirData::wxDirData(const wxString& dirname)
|
||||||
: m_dirname(dirname)
|
: m_dirname(dirname)
|
||||||
{
|
{
|
||||||
OSErr err;
|
|
||||||
|
|
||||||
// throw away the trailing slashes
|
// throw away the trailing slashes
|
||||||
size_t n = m_dirname.length();
|
size_t n = m_dirname.length();
|
||||||
wxCHECK_RET( n, _T("empty dir name in wxDir") );
|
wxCHECK_RET( n, _T("empty dir name in wxDir") );
|
||||||
@@ -116,96 +107,88 @@ wxDirData::wxDirData(const wxString& dirname)
|
|||||||
;
|
;
|
||||||
|
|
||||||
m_dirname.Truncate(n + 1);
|
m_dirname.Truncate(n + 1);
|
||||||
|
m_iterator = NULL ;
|
||||||
#ifdef __DARWIN__
|
|
||||||
FSRef theRef;
|
|
||||||
|
|
||||||
// get the FSRef associated with the POSIX path
|
|
||||||
err = FSPathMakeRef((const UInt8 *) m_dirname.c_str(), &theRef, NULL);
|
|
||||||
FSGetVRefNum(&theRef, &(m_CPB.hFileInfo.ioVRefNum));
|
|
||||||
|
|
||||||
err = FSGetNodeID( &theRef , &m_dirId , &m_isDir ) ;
|
|
||||||
#else
|
|
||||||
FSSpec fsspec ;
|
|
||||||
|
|
||||||
wxMacFilename2FSSpec( m_dirname , &fsspec ) ;
|
|
||||||
m_CPB.hFileInfo.ioVRefNum = fsspec.vRefNum ;
|
|
||||||
|
|
||||||
err = FSpGetDirectoryID( &fsspec , &m_dirId , &m_isDir ) ;
|
|
||||||
#endif
|
|
||||||
wxASSERT_MSG( (err == noErr) || (err == nsvErr) , wxT("Error accessing directory " + m_dirname)) ;
|
|
||||||
|
|
||||||
m_CPB.hFileInfo.ioNamePtr = m_name ;
|
|
||||||
m_index = 0 ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDirData::~wxDirData()
|
wxDirData::~wxDirData()
|
||||||
{
|
{
|
||||||
|
Close() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxDirData::Close()
|
||||||
|
{
|
||||||
|
if ( m_iterator )
|
||||||
|
{
|
||||||
|
FSCloseIterator( m_iterator ) ;
|
||||||
|
m_iterator = NULL ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDirData::Rewind()
|
void wxDirData::Rewind()
|
||||||
{
|
{
|
||||||
m_index = 0 ;
|
Close() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDirData::Read(wxString *filename)
|
bool wxDirData::Read(wxString *filename)
|
||||||
{
|
{
|
||||||
if ( !m_isDir )
|
|
||||||
return FALSE ;
|
|
||||||
|
|
||||||
wxString result;
|
wxString result;
|
||||||
|
OSStatus err = noErr ;
|
||||||
short err = noErr ;
|
if ( NULL == m_iterator )
|
||||||
|
|
||||||
while ( err == noErr )
|
|
||||||
{
|
{
|
||||||
m_index++ ;
|
FSRef dirRef;
|
||||||
m_CPB.dirInfo.ioFDirIndex = m_index;
|
err = wxMacPathToFSRef( m_dirname , &dirRef ) ;
|
||||||
m_CPB.dirInfo.ioDrDirID = m_dirId; /* we need to do this every time */
|
if ( err == noErr )
|
||||||
err = PBGetCatInfoSync((CInfoPBPtr)&m_CPB);
|
{
|
||||||
if ( err != noErr )
|
err = FSOpenIterator(&dirRef, kFSIterateFlat, &m_iterator);
|
||||||
|
}
|
||||||
|
if ( err )
|
||||||
|
{
|
||||||
|
Close() ;
|
||||||
|
return FALSE ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString name ;
|
||||||
|
|
||||||
|
while( noErr == err )
|
||||||
|
{
|
||||||
|
HFSUniStr255 uniname ;
|
||||||
|
FSRef fileRef;
|
||||||
|
FSCatalogInfo catalogInfo;
|
||||||
|
UInt32 fetched = 0;
|
||||||
|
|
||||||
|
err = FSGetCatalogInfoBulk( m_iterator, 1, &fetched, NULL, kFSCatInfoNodeFlags | kFSCatInfoFinderInfo , &catalogInfo , &fileRef, NULL, &uniname );
|
||||||
|
if ( errFSNoMoreItems == err )
|
||||||
|
return false ;
|
||||||
|
|
||||||
|
wxASSERT( noErr == err ) ;
|
||||||
|
|
||||||
|
if ( noErr != err )
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
// its hidden but we don't want it
|
name = wxMacHFSUniStrToString( &uniname ) ;
|
||||||
if ( ( m_CPB.hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible ) && !(m_flags & wxDIR_HIDDEN) )
|
|
||||||
|
if ( ( name == wxT(".") || name == wxT("..") ) && !(m_flags & wxDIR_DOTDOT) )
|
||||||
continue;
|
continue;
|
||||||
#ifdef __DARWIN__
|
|
||||||
// under X, names that start with '.' are hidden
|
if ( ( name[0U] == '.' ) && !(m_flags & wxDIR_HIDDEN ) )
|
||||||
if ( ( m_name[1] == '.' ) && !(m_flags & wxDIR_HIDDEN) )
|
|
||||||
continue ;
|
continue ;
|
||||||
#endif
|
|
||||||
#if TARGET_CARBON
|
if ( (((FileInfo*)&catalogInfo.finderInfo)->finderFlags & kIsInvisible ) && !(m_flags & wxDIR_HIDDEN ) )
|
||||||
// under X thats the way the mounting points look like
|
continue ;
|
||||||
if ( ( m_CPB.dirInfo.ioDrDirID == 0 ) && ( m_flags & wxDIR_DIRS) )
|
|
||||||
break ;
|
// its a dir and we want it
|
||||||
#endif
|
if ( (catalogInfo.nodeFlags & kFSNodeIsDirectoryMask) && (m_flags & wxDIR_DIRS) )
|
||||||
// we have a directory
|
|
||||||
if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) != 0 && (m_flags & wxDIR_DIRS) )
|
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
// its a file but we don't want it
|
// its a file but we don't want it
|
||||||
if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) == 0 && !(m_flags & wxDIR_FILES ) )
|
if ( (catalogInfo.nodeFlags & kFSNodeIsDirectoryMask) == 0 && !(m_flags & wxDIR_FILES ) )
|
||||||
continue ;
|
continue ;
|
||||||
|
|
||||||
wxString file = wxMacMakeStringFromPascal( m_name ) ;
|
|
||||||
if ( m_filespec.IsEmpty() || m_filespec == wxT("*.*") || m_filespec == wxT("*") )
|
if ( m_filespec.IsEmpty() || m_filespec == wxT("*.*") || m_filespec == wxT("*") )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
else if ( m_filespec.Length() > 1 && m_filespec.Left(1) == wxT("*") )
|
else if ( !wxMatchWild(m_filespec, name , FALSE) )
|
||||||
{
|
|
||||||
if ( file.Right( m_filespec.Length() - 1 ).Upper() != m_filespec.Mid(1).Upper() )
|
|
||||||
{
|
|
||||||
continue ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( m_filespec.Length() > 1 && m_filespec.Right(1) == wxT("*") )
|
|
||||||
{
|
|
||||||
if ( file.Left( m_filespec.Length() - 1 ).Upper() != m_filespec.Left( m_filespec.Length() - 1 ).Upper() )
|
|
||||||
{
|
|
||||||
continue ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( file.Upper() != m_filespec.Upper() )
|
|
||||||
{
|
{
|
||||||
continue ;
|
continue ;
|
||||||
}
|
}
|
||||||
@@ -217,8 +200,7 @@ bool wxDirData::Read(wxString *filename)
|
|||||||
return FALSE ;
|
return FALSE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
*filename = wxMacMakeStringFromPascal( m_name ) ;
|
*filename = name ;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -329,7 +329,7 @@ wxDragResult wxDropSource::DoDragDrop(int WXUNUSED(flags))
|
|||||||
OSErr err = noErr;
|
OSErr err = noErr;
|
||||||
CInfoPBRec cat;
|
CInfoPBRec cat;
|
||||||
|
|
||||||
wxMacFilename2FSSpec( dataPtr , &theFlavor.fileSpec ) ;
|
wxMacFilename2FSSpec( wxString( dataPtr , *wxConvCurrent ) , &theFlavor.fileSpec ) ;
|
||||||
|
|
||||||
cat.hFileInfo.ioNamePtr = theFlavor.fileSpec.name;
|
cat.hFileInfo.ioNamePtr = theFlavor.fileSpec.name;
|
||||||
cat.hFileInfo.ioVRefNum = theFlavor.fileSpec.vRefNum;
|
cat.hFileInfo.ioVRefNum = theFlavor.fileSpec.vRefNum;
|
||||||
|
@@ -36,12 +36,7 @@ IMPLEMENT_CLASS(wxFileDialog, wxFileDialogBase)
|
|||||||
|
|
||||||
#include <Navigation.h>
|
#include <Navigation.h>
|
||||||
|
|
||||||
#ifdef __DARWIN__
|
|
||||||
#include "MoreFilesX.h"
|
#include "MoreFilesX.h"
|
||||||
#else
|
|
||||||
# include "MoreFiles.h"
|
|
||||||
# include "MoreFilesExtras.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern bool gUseNavServices ;
|
extern bool gUseNavServices ;
|
||||||
|
|
||||||
@@ -58,11 +53,7 @@ struct OpenUserDataRec {
|
|||||||
wxArrayString extensions ;
|
wxArrayString extensions ;
|
||||||
wxArrayLong filtermactypes ;
|
wxArrayLong filtermactypes ;
|
||||||
wxString defaultLocation;
|
wxString defaultLocation;
|
||||||
#if TARGET_CARBON
|
|
||||||
CFArrayRef menuitems ;
|
CFArrayRef menuitems ;
|
||||||
#else
|
|
||||||
NavMenuItemSpecArrayHandle menuitems ;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct OpenUserDataRec
|
typedef struct OpenUserDataRec
|
||||||
@@ -73,11 +64,7 @@ static pascal void NavEventProc(
|
|||||||
NavCBRecPtr ioParams,
|
NavCBRecPtr ioParams,
|
||||||
NavCallBackUserData ioUserData);
|
NavCallBackUserData ioUserData);
|
||||||
|
|
||||||
#if TARGET_CARBON
|
|
||||||
static NavEventUPP sStandardNavEventFilter = NewNavEventUPP(NavEventProc);
|
static NavEventUPP sStandardNavEventFilter = NewNavEventUPP(NavEventProc);
|
||||||
#else
|
|
||||||
static NavEventUPP sStandardNavEventFilter = NewNavEventProc(NavEventProc);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static pascal void
|
static pascal void
|
||||||
NavEventProc(
|
NavEventProc(
|
||||||
@@ -87,14 +74,9 @@ NavEventProc(
|
|||||||
{
|
{
|
||||||
OpenUserDataRec * data = ( OpenUserDataRec *) ioUserData ;
|
OpenUserDataRec * data = ( OpenUserDataRec *) ioUserData ;
|
||||||
if (inSelector == kNavCBEvent) {
|
if (inSelector == kNavCBEvent) {
|
||||||
#if TARGET_CARBON
|
|
||||||
#else
|
|
||||||
wxTheApp->MacHandleOneEvent(ioParams->eventData.eventDataParms.event);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if ( inSelector == kNavCBStart )
|
else if ( inSelector == kNavCBStart )
|
||||||
{
|
{
|
||||||
#if TARGET_CARBON
|
|
||||||
if (data && !(data->defaultLocation).IsEmpty())
|
if (data && !(data->defaultLocation).IsEmpty())
|
||||||
{
|
{
|
||||||
// Set default location for the modern Navigation APIs
|
// Set default location for the modern Navigation APIs
|
||||||
@@ -112,22 +94,13 @@ NavEventProc(
|
|||||||
menuItem.menuType = data->currentfilter;
|
menuItem.menuType = data->currentfilter;
|
||||||
wxMacStringToPascal( data->name[data->currentfilter] , (StringPtr)(menuItem.menuItemName) ) ;
|
wxMacStringToPascal( data->name[data->currentfilter] , (StringPtr)(menuItem.menuItemName) ) ;
|
||||||
::NavCustomControl(ioParams->context, kNavCtlSelectCustomType, &menuItem);
|
::NavCustomControl(ioParams->context, kNavCtlSelectCustomType, &menuItem);
|
||||||
|
|
||||||
#else
|
|
||||||
if ( data->menuitems )
|
|
||||||
NavCustomControl(ioParams->context, kNavCtlSelectCustomType, &(*data->menuitems)[data->currentfilter]);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if ( inSelector == kNavCBPopupMenuSelect )
|
else if ( inSelector == kNavCBPopupMenuSelect )
|
||||||
{
|
{
|
||||||
NavMenuItemSpec * menu = (NavMenuItemSpec *) ioParams->eventData.eventDataParms.param ;
|
NavMenuItemSpec * menu = (NavMenuItemSpec *) ioParams->eventData.eventDataParms.param ;
|
||||||
#if TARGET_CARBON
|
|
||||||
const size_t numFilters = data->extensions.GetCount();
|
const size_t numFilters = data->extensions.GetCount();
|
||||||
|
|
||||||
if ( menu->menuType < numFilters )
|
if ( menu->menuType < numFilters )
|
||||||
#else
|
|
||||||
if ( menu->menuCreator == 'WXNG' )
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
data->currentfilter = menu->menuType ;
|
data->currentfilter = menu->menuType ;
|
||||||
if ( data->saveMode )
|
if ( data->saveMode )
|
||||||
@@ -137,27 +110,15 @@ NavEventProc(
|
|||||||
extension.MakeLower() ;
|
extension.MakeLower() ;
|
||||||
wxString sfilename ;
|
wxString sfilename ;
|
||||||
|
|
||||||
#if TARGET_CARBON
|
|
||||||
wxMacCFStringHolder cfString( NavDialogGetSaveFileName( ioParams->context ) , false );
|
wxMacCFStringHolder cfString( NavDialogGetSaveFileName( ioParams->context ) , false );
|
||||||
sfilename = cfString.AsString() ;
|
sfilename = cfString.AsString() ;
|
||||||
#else
|
|
||||||
Str255 filename ;
|
|
||||||
// get the current filename
|
|
||||||
NavCustomControl(ioParams->context, kNavCtlGetEditFileName, &filename);
|
|
||||||
sfilename = wxMacMakeStringFromPascal( filename ) ;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int pos = sfilename.Find('.', true) ;
|
int pos = sfilename.Find('.', true) ;
|
||||||
if ( pos != wxNOT_FOUND )
|
if ( pos != wxNOT_FOUND )
|
||||||
{
|
{
|
||||||
sfilename = sfilename.Left(pos+1)+extension ;
|
sfilename = sfilename.Left(pos+1)+extension ;
|
||||||
#if TARGET_CARBON
|
|
||||||
cfString.Assign( sfilename , wxFONTENCODING_DEFAULT ) ;
|
cfString.Assign( sfilename , wxFONTENCODING_DEFAULT ) ;
|
||||||
NavDialogSetSaveFileName( ioParams->context , cfString ) ;
|
NavDialogSetSaveFileName( ioParams->context , cfString ) ;
|
||||||
#else
|
|
||||||
wxMacStringToPascal( sfilename , filename ) ;
|
|
||||||
NavCustomControl(ioParams->context, kNavCtlSetEditFileName, &filename);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -268,7 +229,7 @@ static Boolean CheckFile( const wxString &filename , OSType type , OpenUserDataR
|
|||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __DARWIN__
|
#if !TARGET_API_MAC_OSX
|
||||||
static pascal Boolean CrossPlatformFileFilter(CInfoPBPtr myCInfoPBPtr, void *dataPtr)
|
static pascal Boolean CrossPlatformFileFilter(CInfoPBPtr myCInfoPBPtr, void *dataPtr)
|
||||||
{
|
{
|
||||||
OpenUserDataRecPtr data = (OpenUserDataRecPtr) dataPtr ;
|
OpenUserDataRecPtr data = (OpenUserDataRecPtr) dataPtr ;
|
||||||
@@ -328,28 +289,13 @@ pascal Boolean CrossPlatformFilterCallback (
|
|||||||
wxString file = wxMacMakeStringFromPascal( spec.name ) ;
|
wxString file = wxMacMakeStringFromPascal( spec.name ) ;
|
||||||
display = CheckFile( file , theInfo->fileAndFolder.fileInfo.finderInfo.fdType , data ) ;
|
display = CheckFile( file , theInfo->fileAndFolder.fileInfo.finderInfo.fdType , data ) ;
|
||||||
}
|
}
|
||||||
#if TARGET_CARBON
|
|
||||||
else if ( theItem->descriptorType == typeFSRef )
|
else if ( theItem->descriptorType == typeFSRef )
|
||||||
{
|
{
|
||||||
FSRef fsref ;
|
FSRef fsref ;
|
||||||
memcpy( &fsref , *theItem->dataHandle , sizeof(FSRef) ) ;
|
memcpy( &fsref , *theItem->dataHandle , sizeof(FSRef) ) ;
|
||||||
|
wxString file = wxMacFSRefToPath( &fsref ) ;
|
||||||
|
|
||||||
|
|
||||||
CFURLRef fullURLRef;
|
|
||||||
fullURLRef = ::CFURLCreateFromFSRef(NULL, &fsref);
|
|
||||||
#ifdef __UNIX__
|
|
||||||
CFURLPathStyle pathstyle = kCFURLPOSIXPathStyle;
|
|
||||||
#else
|
|
||||||
CFURLPathStyle pathstyle = kCFURLHFSPathStyle;
|
|
||||||
#endif
|
|
||||||
CFStringRef cfString = CFURLCopyFileSystemPath(fullURLRef, pathstyle);
|
|
||||||
::CFRelease( fullURLRef ) ;
|
|
||||||
wxString file = wxMacCFStringHolder(cfString).AsString(wxFont::GetDefaultEncoding());
|
|
||||||
|
|
||||||
display = CheckFile( file , theInfo->fileAndFolder.fileInfo.finderInfo.fdType , data ) ;
|
display = CheckFile( file , theInfo->fileAndFolder.fileInfo.finderInfo.fdType , data ) ;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,7 +304,6 @@ pascal Boolean CrossPlatformFilterCallback (
|
|||||||
|
|
||||||
int wxFileDialog::ShowModal()
|
int wxFileDialog::ShowModal()
|
||||||
{
|
{
|
||||||
#if TARGET_CARBON
|
|
||||||
OSErr err;
|
OSErr err;
|
||||||
NavDialogCreationOptions dialogCreateOptions;
|
NavDialogCreationOptions dialogCreateOptions;
|
||||||
// set default options
|
// set default options
|
||||||
@@ -474,30 +419,10 @@ int wxFileDialog::ShowModal()
|
|||||||
|
|
||||||
CFURLRef fullURLRef = 0 ;
|
CFURLRef fullURLRef = 0 ;
|
||||||
if (m_dialogStyle & wxSAVE)
|
if (m_dialogStyle & wxSAVE)
|
||||||
{
|
thePath = wxMacFSRefToPath( &theFSRef , navReply.saveFileName ) ;
|
||||||
CFURLRef parentURLRef = ::CFURLCreateFromFSRef(NULL, &theFSRef);
|
|
||||||
|
|
||||||
if (parentURLRef)
|
|
||||||
{
|
|
||||||
fullURLRef =
|
|
||||||
::CFURLCreateCopyAppendingPathComponent(NULL,
|
|
||||||
parentURLRef,
|
|
||||||
navReply.saveFileName,
|
|
||||||
false);
|
|
||||||
::CFRelease(parentURLRef);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
thePath = wxMacFSRefToPath( &theFSRef ) ;
|
||||||
fullURLRef = ::CFURLCreateFromFSRef(NULL, &theFSRef);
|
|
||||||
}
|
|
||||||
#ifdef __UNIX__
|
|
||||||
CFURLPathStyle pathstyle = kCFURLPOSIXPathStyle;
|
|
||||||
#else
|
|
||||||
CFURLPathStyle pathstyle = kCFURLHFSPathStyle;
|
|
||||||
#endif
|
|
||||||
CFStringRef cfString = CFURLCopyFileSystemPath(fullURLRef, pathstyle);
|
|
||||||
thePath = wxMacCFStringHolder(cfString).AsString(m_font.GetEncoding());
|
|
||||||
if (!thePath)
|
if (!thePath)
|
||||||
{
|
{
|
||||||
::NavDisposeReply(&navReply);
|
::NavDisposeReply(&navReply);
|
||||||
@@ -516,163 +441,5 @@ int wxFileDialog::ShowModal()
|
|||||||
::NavDisposeReply(&navReply);
|
::NavDisposeReply(&navReply);
|
||||||
|
|
||||||
return (err == noErr) ? wxID_OK : wxID_CANCEL;
|
return (err == noErr) ? wxID_OK : wxID_CANCEL;
|
||||||
#else // TARGET_CARBON
|
|
||||||
|
|
||||||
NavDialogOptions mNavOptions;
|
|
||||||
NavObjectFilterUPP mNavFilterUPP = NULL;
|
|
||||||
NavPreviewUPP mNavPreviewUPP = NULL ;
|
|
||||||
NavReplyRecord mNavReply;
|
|
||||||
AEDesc mDefaultLocation ;
|
|
||||||
bool mSelectDefault = false ;
|
|
||||||
OSStatus err = noErr ;
|
|
||||||
// setup dialog
|
|
||||||
|
|
||||||
mNavFilterUPP = nil;
|
|
||||||
mNavPreviewUPP = nil;
|
|
||||||
mSelectDefault = false;
|
|
||||||
mDefaultLocation.descriptorType = typeNull;
|
|
||||||
mDefaultLocation.dataHandle = nil;
|
|
||||||
|
|
||||||
NavGetDefaultDialogOptions(&mNavOptions);
|
|
||||||
wxMacStringToPascal( m_message , (StringPtr)mNavOptions.message ) ;
|
|
||||||
wxMacStringToPascal( m_fileName , (StringPtr)mNavOptions.savedFileName ) ;
|
|
||||||
|
|
||||||
// Set default location, the location
|
|
||||||
// that's displayed when the dialog
|
|
||||||
// first appears
|
|
||||||
|
|
||||||
FSSpec location ;
|
|
||||||
wxMacFilename2FSSpec( m_dir , &location ) ;
|
|
||||||
|
|
||||||
err = ::AECreateDesc(typeFSS, &location, sizeof(FSSpec), &mDefaultLocation );
|
|
||||||
|
|
||||||
if ( mDefaultLocation.dataHandle )
|
|
||||||
{
|
|
||||||
if (mSelectDefault)
|
|
||||||
{
|
|
||||||
mNavOptions.dialogOptionFlags |= kNavSelectDefaultLocation;
|
|
||||||
} else {
|
|
||||||
mNavOptions.dialogOptionFlags &= ~kNavSelectDefaultLocation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
memset( &mNavReply , 0 , sizeof( mNavReply ) ) ;
|
|
||||||
mNavReply.validRecord = false;
|
|
||||||
mNavReply.replacing = false;
|
|
||||||
mNavReply.isStationery = false;
|
|
||||||
mNavReply.translationNeeded = false;
|
|
||||||
mNavReply.selection.descriptorType = typeNull;
|
|
||||||
mNavReply.selection.dataHandle = nil;
|
|
||||||
mNavReply.keyScript = smSystemScript;
|
|
||||||
mNavReply.fileTranslation = nil;
|
|
||||||
mNavReply.version = kNavReplyRecordVersion ;
|
|
||||||
|
|
||||||
// zero all data
|
|
||||||
|
|
||||||
m_path = wxEmptyString ;
|
|
||||||
m_fileName = wxEmptyString ;
|
|
||||||
m_paths.Empty();
|
|
||||||
m_fileNames.Empty();
|
|
||||||
|
|
||||||
OpenUserDataRec myData;
|
|
||||||
MakeUserDataRec( &myData , m_wildCard ) ;
|
|
||||||
myData.currentfilter = m_filterIndex ;
|
|
||||||
if ( myData.extensions.GetCount() > 0 )
|
|
||||||
{
|
|
||||||
mNavOptions.popupExtension = (NavMenuItemSpecArrayHandle) NewHandle( sizeof( NavMenuItemSpec ) * myData.extensions.GetCount() ) ;
|
|
||||||
myData.menuitems = mNavOptions.popupExtension ;
|
|
||||||
for ( size_t i = 0 ; i < myData.extensions.GetCount() ; ++i )
|
|
||||||
{
|
|
||||||
(*mNavOptions.popupExtension)[i].version = kNavMenuItemSpecVersion ;
|
|
||||||
(*mNavOptions.popupExtension)[i].menuCreator = 'WXNG' ;
|
|
||||||
// TODO : according to the new docs -1 to 10 are reserved for the OS
|
|
||||||
(*mNavOptions.popupExtension)[i].menuType = i ;
|
|
||||||
wxMacStringToPascal( myData.name[i] , (StringPtr)(*mNavOptions.popupExtension)[i].menuItemName ) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( m_dialogStyle & wxSAVE )
|
|
||||||
{
|
|
||||||
myData.saveMode = true ;
|
|
||||||
|
|
||||||
mNavOptions.dialogOptionFlags |= kNavDontAutoTranslate ;
|
|
||||||
mNavOptions.dialogOptionFlags |= kNavDontAddTranslateItems ;
|
|
||||||
|
|
||||||
err = ::NavPutFile(
|
|
||||||
&mDefaultLocation,
|
|
||||||
&mNavReply,
|
|
||||||
&mNavOptions,
|
|
||||||
sStandardNavEventFilter ,
|
|
||||||
NULL,
|
|
||||||
kNavGenericSignature,
|
|
||||||
&myData); // User Data
|
|
||||||
m_filterIndex = myData.currentfilter ;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
myData.saveMode = false ;
|
|
||||||
|
|
||||||
mNavFilterUPP = NewNavObjectFilterUPP( CrossPlatformFilterCallback ) ;
|
|
||||||
if ( m_dialogStyle & wxMULTIPLE )
|
|
||||||
mNavOptions.dialogOptionFlags |= kNavAllowMultipleFiles ;
|
|
||||||
else
|
|
||||||
mNavOptions.dialogOptionFlags &= ~kNavAllowMultipleFiles ;
|
|
||||||
|
|
||||||
err = ::NavGetFile(
|
|
||||||
&mDefaultLocation,
|
|
||||||
&mNavReply,
|
|
||||||
&mNavOptions,
|
|
||||||
sStandardNavEventFilter ,
|
|
||||||
mNavPreviewUPP,
|
|
||||||
mNavFilterUPP,
|
|
||||||
NULL ,
|
|
||||||
&myData);
|
|
||||||
m_filterIndex = myData.currentfilter ;
|
|
||||||
}
|
|
||||||
|
|
||||||
DisposeNavObjectFilterUPP(mNavFilterUPP);
|
|
||||||
if ( mDefaultLocation.dataHandle != nil )
|
|
||||||
{
|
|
||||||
::AEDisposeDesc(&mDefaultLocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( (err != noErr) && (err != userCanceledErr) ) {
|
|
||||||
return wxID_CANCEL ;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mNavReply.validRecord)
|
|
||||||
{
|
|
||||||
FSSpec outFileSpec ;
|
|
||||||
AEDesc specDesc ;
|
|
||||||
AEKeyword keyWord ;
|
|
||||||
|
|
||||||
long count ;
|
|
||||||
::AECountItems( &mNavReply.selection , &count ) ;
|
|
||||||
for ( long i = 1 ; i <= count ; ++i )
|
|
||||||
{
|
|
||||||
OSErr err = ::AEGetNthDesc( &mNavReply.selection , i , typeFSS, &keyWord , &specDesc);
|
|
||||||
if ( err != noErr )
|
|
||||||
{
|
|
||||||
m_path = wxT("") ;
|
|
||||||
return wxID_CANCEL ;
|
|
||||||
}
|
|
||||||
outFileSpec = **(FSSpec**) specDesc.dataHandle;
|
|
||||||
if (specDesc.dataHandle != nil) {
|
|
||||||
::AEDisposeDesc(&specDesc);
|
|
||||||
}
|
|
||||||
m_path = wxMacFSSpec2MacFilename( &outFileSpec ) ;
|
|
||||||
|
|
||||||
m_paths.Add( m_path ) ;
|
|
||||||
m_fileName = wxFileNameFromPath(m_path);
|
|
||||||
m_fileNames.Add(m_fileName);
|
|
||||||
}
|
|
||||||
// set these to the first hit
|
|
||||||
m_path = m_paths[ 0 ] ;
|
|
||||||
m_fileName = wxFileNameFromPath(m_path);
|
|
||||||
m_dir = wxPathOnly(m_path);
|
|
||||||
NavDisposeReply( &mNavReply ) ;
|
|
||||||
return wxID_OK ;
|
|
||||||
}
|
|
||||||
return wxID_CANCEL;
|
|
||||||
#endif // TARGET_CARBON
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -41,7 +41,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
#include "wx/mac/private.h"
|
#include "wx/mac/uma.h"
|
||||||
#include <Movies.h>
|
#include <Movies.h>
|
||||||
#include <Gestalt.h>
|
#include <Gestalt.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -375,9 +375,27 @@ bool wxSound::DoPlay(unsigned flags) const
|
|||||||
if (!wxInitQT())
|
if (!wxInitQT())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
OSErr err = noErr ;
|
||||||
|
#if defined( __WXMAC__ ) && TARGET_API_MAC_OSX && ( MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2 )
|
||||||
|
if ( UMAGetSystemVersion() >= 0x1030 )
|
||||||
|
{
|
||||||
|
Handle dataRef = NULL;
|
||||||
|
OSType dataRefType;
|
||||||
|
|
||||||
|
err = QTNewDataReferenceFromFullPathCFString(wxMacCFStringHolder(m_sndname,wxLocale::GetSystemEncoding()),
|
||||||
|
kQTNativeDefaultPathStyle, 0, &dataRef, &dataRefType);
|
||||||
|
|
||||||
|
if (NULL != dataRef)
|
||||||
|
{
|
||||||
|
err = NewMovieFromDataRef( &movie, newMovieDontAskUnresolvedDataRefs , NULL, dataRef, dataRefType );
|
||||||
|
DisposeHandle(dataRef);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
short movieResFile;
|
short movieResFile;
|
||||||
FSSpec sfFile;
|
FSSpec sfFile;
|
||||||
|
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
wxMacFilename2FSSpec( m_sndname , &sfFile ) ;
|
wxMacFilename2FSSpec( m_sndname , &sfFile ) ;
|
||||||
#else
|
#else
|
||||||
@@ -389,17 +407,13 @@ bool wxSound::DoPlay(unsigned flags) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (OpenMovieFile (&sfFile, &movieResFile, fsRdPerm) != noErr)
|
if (OpenMovieFile (&sfFile, &movieResFile, fsRdPerm) != noErr)
|
||||||
{
|
{
|
||||||
wxLogSysError(wxT("Quicktime couldn't open the file"));
|
wxLogSysError(wxT("Quicktime couldn't open the file"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
short movieResID = 0;
|
short movieResID = 0;
|
||||||
Str255 movieName;
|
Str255 movieName;
|
||||||
OSErr err;
|
|
||||||
|
|
||||||
err = NewMovieFromFile (
|
err = NewMovieFromFile (
|
||||||
&movie,
|
&movie,
|
||||||
@@ -410,6 +424,7 @@ bool wxSound::DoPlay(unsigned flags) const
|
|||||||
NULL); //wasChanged
|
NULL); //wasChanged
|
||||||
|
|
||||||
CloseMovieFile (movieResFile);
|
CloseMovieFile (movieResFile);
|
||||||
|
}
|
||||||
|
|
||||||
if (err != noErr)
|
if (err != noErr)
|
||||||
{
|
{
|
||||||
|
@@ -33,12 +33,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#ifdef __DARWIN__
|
|
||||||
#include "MoreFilesX.h"
|
#include "MoreFilesX.h"
|
||||||
#else
|
|
||||||
# include "MoreFiles.h"
|
|
||||||
# include "MoreFilesExtras.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __DARWIN__
|
#ifndef __DARWIN__
|
||||||
#include <Threads.h>
|
#include <Threads.h>
|
||||||
@@ -524,18 +519,12 @@ wxString wxMacFindFolder( short vol,
|
|||||||
OSType folderType,
|
OSType folderType,
|
||||||
Boolean createFolder)
|
Boolean createFolder)
|
||||||
{
|
{
|
||||||
short vRefNum ;
|
FSRef fsRef ;
|
||||||
long dirID ;
|
|
||||||
wxString strDir ;
|
wxString strDir ;
|
||||||
|
|
||||||
if ( FindFolder( vol, folderType, createFolder, &vRefNum, &dirID) == noErr)
|
if ( FSFindFolder( vol, folderType, createFolder, &fsRef) == noErr)
|
||||||
{
|
strDir = wxMacFSRefToPath( &fsRef ) ;
|
||||||
FSSpec file ;
|
|
||||||
if ( FSMakeFSSpec( vRefNum , dirID , "\p" , &file ) == noErr )
|
|
||||||
{
|
|
||||||
strDir = wxMacFSSpec2MacFilename( &file ) + wxFILE_SEP_PATH ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return strDir ;
|
return strDir ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -667,17 +656,25 @@ bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree)
|
|||||||
|
|
||||||
p = p + wxT(":") ;
|
p = p + wxT(":") ;
|
||||||
|
|
||||||
Str255 volumeName ;
|
OSErr err = noErr ;
|
||||||
XVolumeParam pb ;
|
|
||||||
|
|
||||||
wxMacStringToPascal( p , volumeName ) ;
|
FSRef fsRef ;
|
||||||
OSErr err = XGetVolumeInfoNoName( volumeName , 0 , &pb ) ;
|
err = wxMacPathToFSRef( p , &fsRef ) ;
|
||||||
if ( err == noErr ) {
|
if ( noErr == err )
|
||||||
if ( pTotal ) {
|
{
|
||||||
(*pTotal) = wxLongLong( pb.ioVTotalBytes ) ;
|
FSVolumeRefNum vRefNum ;
|
||||||
|
err = FSGetVRefNum( &fsRef , &vRefNum ) ;
|
||||||
|
if ( noErr == err )
|
||||||
|
{
|
||||||
|
UInt64 freeBytes , totalBytes ;
|
||||||
|
err = FSGetVInfo( vRefNum , NULL , &freeBytes , &totalBytes ) ;
|
||||||
|
if ( noErr == err )
|
||||||
|
{
|
||||||
|
if ( pTotal )
|
||||||
|
*pTotal = wxLongLong( totalBytes ) ;
|
||||||
|
if ( pFree )
|
||||||
|
*pFree = wxLongLong( freeBytes ) ;
|
||||||
}
|
}
|
||||||
if ( pFree ) {
|
|
||||||
(*pFree) = wxLongLong( pb.ioVFreeBytes ) ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -30,106 +30,27 @@ extern "C" {
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifndef __DARWIN__
|
#ifndef __DARWIN__
|
||||||
#define wxEXECUTE_WIN_MESSAGE 10000
|
|
||||||
|
|
||||||
#include "wx/mac/private.h"
|
#include "wx/mac/private.h"
|
||||||
|
#include "LaunchServices.h"
|
||||||
/*
|
|
||||||
Below FinderLaunch function comes from:
|
|
||||||
http://developer.apple.com/technotes/tn/tn1002.html#fndrask
|
|
||||||
*/
|
|
||||||
/* FinderLaunch converts a list of nTargets FSSpec records
|
|
||||||
pointed to by the targetList parameter and converts the
|
|
||||||
list to an Apple Event. It then sends that event to the
|
|
||||||
Finder. The array of FSSpec records pointed to by the
|
|
||||||
targetList parameter may contain references to files,
|
|
||||||
folders, or applications. The net effect of this command
|
|
||||||
is equivalent to the user selecting an icon in one of the
|
|
||||||
Finder's windows and then choosing the open command from
|
|
||||||
the Finder's file menu. */
|
|
||||||
static OSErr FinderLaunch(long nTargets, FSSpec *targetList) {
|
|
||||||
OSErr err;
|
|
||||||
AppleEvent theAEvent, theReply;
|
|
||||||
AEAddressDesc fndrAddress;
|
|
||||||
AEDescList targetListDesc;
|
|
||||||
OSType fndrCreator;
|
|
||||||
Boolean wasChanged;
|
|
||||||
AliasHandle targetAlias;
|
|
||||||
long index;
|
|
||||||
|
|
||||||
/* set up locals */
|
|
||||||
AECreateDesc(typeNull, NULL, 0, &theAEvent);
|
|
||||||
AECreateDesc(typeNull, NULL, 0, &fndrAddress);
|
|
||||||
AECreateDesc(typeNull, NULL, 0, &theReply);
|
|
||||||
AECreateDesc(typeNull, NULL, 0, &targetListDesc);
|
|
||||||
targetAlias = NULL;
|
|
||||||
fndrCreator = 'MACS';
|
|
||||||
|
|
||||||
/* verify parameters */
|
|
||||||
if ((nTargets == 0) || (targetList == NULL)) {
|
|
||||||
err = paramErr;
|
|
||||||
goto bail;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* create an open documents event targeting the
|
|
||||||
finder */
|
|
||||||
err = AECreateDesc(typeApplSignature, (Ptr) &fndrCreator,
|
|
||||||
sizeof(fndrCreator), &fndrAddress);
|
|
||||||
if (err != noErr) goto bail;
|
|
||||||
err = AECreateAppleEvent(kCoreEventClass, kAEOpenDocuments,
|
|
||||||
&fndrAddress, kAutoGenerateReturnID,
|
|
||||||
kAnyTransactionID, &theAEvent);
|
|
||||||
if (err != noErr) goto bail;
|
|
||||||
|
|
||||||
/* create the list of files to open */
|
|
||||||
err = AECreateList(NULL, 0, false, &targetListDesc);
|
|
||||||
if (err != noErr) goto bail;
|
|
||||||
for ( index=0; index < nTargets; index++) {
|
|
||||||
if (targetAlias == NULL)
|
|
||||||
err = NewAlias(NULL, (targetList + index),
|
|
||||||
&targetAlias);
|
|
||||||
else err = UpdateAlias(NULL, (targetList + index),
|
|
||||||
targetAlias, &wasChanged);
|
|
||||||
if (err != noErr) goto bail;
|
|
||||||
HLock((Handle) targetAlias);
|
|
||||||
err = AEPutPtr(&targetListDesc, (index + 1),
|
|
||||||
typeAlias, *targetAlias,
|
|
||||||
GetHandleSize((Handle) targetAlias));
|
|
||||||
HUnlock((Handle) targetAlias);
|
|
||||||
if (err != noErr) goto bail;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* add the file list to the Apple Event */
|
|
||||||
err = AEPutParamDesc(&theAEvent, keyDirectObject,
|
|
||||||
&targetListDesc);
|
|
||||||
if (err != noErr) goto bail;
|
|
||||||
|
|
||||||
/* send the event to the Finder */
|
|
||||||
err = AESend(&theAEvent, &theReply, kAENoReply,
|
|
||||||
kAENormalPriority, kAEDefaultTimeout, NULL, NULL);
|
|
||||||
|
|
||||||
/* clean up and leave */
|
|
||||||
bail:
|
|
||||||
if (targetAlias != NULL) DisposeHandle((Handle) targetAlias);
|
|
||||||
AEDisposeDesc(&targetListDesc);
|
|
||||||
AEDisposeDesc(&theAEvent);
|
|
||||||
AEDisposeDesc(&fndrAddress);
|
|
||||||
AEDisposeDesc(&theReply);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
long wxExecute(const wxString& command, int flags, wxProcess *WXUNUSED(handler))
|
long wxExecute(const wxString& command, int flags, wxProcess *WXUNUSED(handler))
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( flags == wxEXEC_ASYNC,
|
wxASSERT_MSG( flags == wxEXEC_ASYNC,
|
||||||
wxT("wxExecute: Only wxEXEC_ASYNC is supported") );
|
wxT("wxExecute: Only wxEXEC_ASYNC is supported") );
|
||||||
|
|
||||||
FSSpec fsSpec;
|
FSRef fsRef ;
|
||||||
wxMacFilename2FSSpec(command, &fsSpec);
|
OSErr err = noErr ;
|
||||||
|
err = wxMacPathToFSRef( command , &fsRef ) ;
|
||||||
|
if ( noErr == err )
|
||||||
|
{
|
||||||
|
err = LSOpenFSRef( &fsRef , NULL ) ;
|
||||||
|
}
|
||||||
|
|
||||||
// 0 means execution failed. Returning non-zero is a PID, but not
|
// 0 means execution failed. Returning non-zero is a PID, but not
|
||||||
// on Mac where PIDs are 64 bits and won't fit in a long, so we
|
// on Mac where PIDs are 64 bits and won't fit in a long, so we
|
||||||
// return a dummy value for now.
|
// return a dummy value for now.
|
||||||
return ( FinderLaunch(1 /*one file*/, &fsSpec) == noErr ) ? -1 : 0;
|
return ( err == noErr ) ? -1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user