reverting to native mac pathnames

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10314 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2001-05-24 21:22:04 +00:00
parent 504aaaad1d
commit bedaf53eaf
20 changed files with 154 additions and 101 deletions

View File

@@ -169,11 +169,13 @@ WXDLLEXPORT void wxUnix2DosFilename(wxChar *s);
#if defined(__WXMAC__) && !defined(__UNIX__)
WXDLLEXPORT wxString wxMacFSSpec2MacFilename( const FSSpec *spec ) ;
WXDLLEXPORT void wxMacFilename2FSSpec( const char *path , FSSpec *spec ) ;
/*
WXDLLEXPORT wxString wxMacFSSpec2UnixFilename( const FSSpec *spec ) ;
WXDLLEXPORT void wxUnixFilename2FSSpec( const char *path , FSSpec *spec ) ;
WXDLLEXPORT void wxMacFilename2FSSpec( const char *path , FSSpec *spec ) ;
WXDLLEXPORT wxString wxMac2UnixFilename( const char *s) ;
WXDLLEXPORT wxString wxUnix2MacFilename( const char *s);
*/
#endif
// Strip the extension, in situ
@@ -268,10 +270,7 @@ WXDLLEXPORT bool wxRmdir(const wxString& dir, int flags = 0);
#define wxFILE_SEP_PATH wxFILE_SEP_PATH_UNIX
#define wxPATH_SEP wxPATH_SEP_UNIX
#elif defined(__MAC__)
// TODO find out whether we can really switch back to native file names
// previously this mac was emulating unix/win filename structures
// #define wxFILE_SEP_PATH wxFILE_SEP_PATH_MAC
#define wxFILE_SEP_PATH wxFILE_SEP_PATH_DOS
#define wxFILE_SEP_PATH wxFILE_SEP_PATH_MAC
#define wxPATH_SEP wxPATH_SEP_DOS
#else // Windows and OS/2
#define wxFILE_SEP_PATH wxFILE_SEP_PATH_DOS

View File

@@ -794,6 +794,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
(void)new wxToggleButton(panel, ID_BUTTON_LABEL,
"&Toggle label", wxPoint(250, 20));
#endif // wxUSE_TOGGLEBTN
m_label = new wxStaticText(panel, -1, "Label with some long text",
wxPoint(250, 60), wxDefaultSize,
wxALIGN_RIGHT /*| wxST_NO_AUTORESIZE*/);

View File

@@ -64,20 +64,12 @@ bool wxFFile::Open(const wxChar *filename, const char *mode)
tmp_fname = new char[fname_len];
wxWX2MB(tmp_fname, filename, fname_len);
#if defined(__WXMAC__) && !defined(__UNIX__)
m_fp = fopen(wxUnix2MacFilename( tmp_fname ), mode);
#else
m_fp = fopen(tmp_fname, mode);
#endif
delete tmp_fname;
#else
#if defined(__WXMAC__) && !defined(__UNIX__)
m_fp = fopen(wxUnix2MacFilename( filename ), mode);
#else
m_fp = fopen(filename, mode);
#endif
#endif
if ( !m_fp )

View File

@@ -136,22 +136,15 @@ bool wxFile::Exists(const wxChar *name)
#if wxUSE_UNICODE && wxMBFILES
wxCharBuffer fname = wxConvFile.cWC2MB(name);
#if defined(__WXMAC__) && !defined(__UNIX__)
return !access(wxUnix2MacFilename( name ) , 0) && !stat(wxUnix2MacFilename( name ), &st) && (st.st_mode & S_IFREG);
#else
return !wxAccess(fname, 0) &&
!wxStat(wxMBSTRINGCAST fname, &st) &&
(st.st_mode & S_IFREG);
#endif
#else
#if defined(__WXMAC__) && !defined(__UNIX__)
return !access(wxUnix2MacFilename( name ) , 0) && !stat(wxUnix2MacFilename( name ), &st) && (st.st_mode & S_IFREG);
#else
return !wxAccess(name, 0) &&
!wxStat(name, &st) &&
(st.st_mode & S_IFREG);
#endif
#endif
}
bool wxFile::Access(const wxChar *name, OpenMode mode)
@@ -195,7 +188,7 @@ bool wxFile::Create(const wxChar *szFileName, bool bOverwrite, int accessMode)
#if defined(__WXMAC__) && !defined(__UNIX__)
// 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 = creat(wxUnix2MacFilename( szFileName ), accessMode);
int fd = creat( szFileName , accessMode);
#else
int fd = wxOpen(wxFNCONV(szFileName),
O_BINARY | O_WRONLY | O_CREAT |
@@ -240,11 +233,7 @@ bool wxFile::Open(const wxChar *szFileName, OpenMode mode, int accessMode)
break;
}
#if defined(__WXMAC__) && !defined(__UNIX__)
int fd = open(wxUnix2MacFilename( szFileName ), flags, access);
#else
int fd = wxOpen(wxFNCONV(szFileName), flags ACCESS(accessMode));
#endif
if ( fd == -1 ) {
wxLogSysError(_("can't open file '%s'"), szFileName);
return FALSE;
@@ -555,7 +544,6 @@ bool wxTempFile::Commit()
{
m_file.Close();
#if !defined(__WXMAC__) || defined(__UNIX__)
if ( wxFile::Exists(m_strName) && wxRemove(m_strName) != 0 ) {
wxLogSysError(_("can't remove file '%s'"), m_strName.c_str());
return FALSE;
@@ -565,17 +553,6 @@ bool wxTempFile::Commit()
wxLogSysError(_("can't commit changes to file '%s'"), m_strName.c_str());
return FALSE;
}
#else
if ( wxFile::Exists(m_strName) && remove(wxUnix2MacFilename( m_strName )) != 0 ) {
wxLogSysError(_("can't remove file '%s'"), m_strName.c_str());
return FALSE;
}
if ( rename(wxUnix2MacFilename( m_strTemp ), wxUnix2MacFilename( m_strName )) != 0 ) {
wxLogSysError(_("can't commit changes to file '%s'"), m_strName.c_str());
return FALSE;
}
#endif
return TRUE;
}
@@ -583,13 +560,8 @@ bool wxTempFile::Commit()
void wxTempFile::Discard()
{
m_file.Close();
#if !defined(__WXMAC__) || defined(__UNIX__)
if ( wxRemove(m_strTemp) != 0 )
wxLogSysError(_("can't remove temporary file '%s'"), m_strTemp.c_str());
#else
if ( remove( wxUnix2MacFilename(m_strTemp.fn_str())) != 0 )
wxLogSysError(_("can't remove temporary file '%s'"), m_strTemp.c_str());
#endif
}
#endif

View File

@@ -802,7 +802,7 @@ bool wxFileConfig::Flush(bool /* bCurrentOnly */)
{
FSSpec spec ;
wxUnixFilename2FSSpec( m_strLocalFile , &spec ) ;
wxMacFilename2FSSpec( m_strLocalFile , &spec ) ;
FInfo finfo ;
if ( FSpGetFInfo( &spec , &finfo ) == noErr )
{

View File

@@ -142,11 +142,7 @@ const off_t wxInvalidOffset = (off_t)-1;
// ----------------------------------------------------------------------------
// we need to translate Mac filenames before passing them to OS functions
#ifdef __MAC__
#define OS_FILENAME(s) (wxUnix2MacFilename(s))
#else
#define OS_FILENAME(s) (s.fn_str())
#endif
// ============================================================================
// implementation
@@ -652,11 +648,15 @@ wxChar *wxFileNameFromPath (wxChar *path)
tcp = path + wxStrlen (path);
while (--tcp >= path)
{
#ifdef __WXMAC__
if (*tcp == wxT(':') )
#else
if (*tcp == wxT('/') || *tcp == wxT('\\')
#ifdef __VMS__
|| *tcp == wxT(':') || *tcp == wxT(']'))
#else
)
#endif
#endif
return tcp + 1;
} /* while */
@@ -679,11 +679,15 @@ wxString wxFileNameFromPath (const wxString& path1)
tcp = path + wxStrlen (path);
while (--tcp >= path)
{
#ifdef __WXMAC__
if (*tcp == wxT(':') )
#else
if (*tcp == wxT('/') || *tcp == wxT('\\')
#ifdef __VMS__
|| *tcp == wxT(':') || *tcp == wxT(']'))
#else
)
#endif
#endif
return wxString(tcp + 1);
} /* while */
@@ -717,7 +721,11 @@ wxPathOnly (wxChar *path)
while (!done && i > -1)
{
// ] is for VMS
#ifdef __WXMAC__
if (path[i] == wxT(':') )
#else
if (path[i] == wxT('/') || path[i] == wxT('\\') || path[i] == wxT(']'))
#endif
{
done = TRUE;
#ifdef __VMS__
@@ -766,7 +774,11 @@ wxString wxPathOnly (const wxString& path)
while (!done && i > -1)
{
// ] is for VMS
#ifdef __WXMAC__
if (path[i] == wxT(':') )
#else
if (path[i] == wxT('/') || path[i] == wxT('\\') || path[i] == wxT(']'))
#endif
{
done = TRUE;
#ifdef __VMS__
@@ -801,7 +813,30 @@ wxString wxPathOnly (const wxString& path)
// Also, convert to lower case, since case is significant in UNIX.
#if defined(__WXMAC__) && !defined(__UNIX__)
wxString wxMacFSSpec2MacFilename( const FSSpec *spec )
{
Handle myPath ;
short length ;
FSpGetFullPath( spec , &length , &myPath ) ;
::SetHandleSize( myPath , length + 1 ) ;
::HLock( myPath ) ;
(*myPath)[length] = 0 ;
if ( length > 0 && (*myPath)[length-1] ==':' )
(*myPath)[length-1] = 0 ;
wxString result( (char*) *myPath ) ;
::HUnlock( myPath ) ;
::DisposeHandle( myPath ) ;
return result ;
}
void wxMacFilename2FSSpec( const char *path , FSSpec *spec )
{
FSpLocationFromFullPath( strlen(path ) , path , spec ) ;
}
/*
static char sMacFileNameConversion[ 1000 ] ;
wxString wxMac2UnixFilename (const char *str)
@@ -868,24 +903,6 @@ wxString wxUnix2MacFilename (const char *str)
return wxString (sMacFileNameConversion) ;
}
wxString wxMacFSSpec2MacFilename( const FSSpec *spec )
{
Handle myPath ;
short length ;
FSpGetFullPath( spec , &length , &myPath ) ;
::SetHandleSize( myPath , length + 1 ) ;
::HLock( myPath ) ;
(*myPath)[length] = 0 ;
if ( length > 0 && (*myPath)[length-1] ==':' )
(*myPath)[length-1] = 0 ;
wxString result( (char*) *myPath ) ;
::HUnlock( myPath ) ;
::DisposeHandle( myPath ) ;
return result ;
}
wxString wxMacFSSpec2UnixFilename( const FSSpec *spec )
{
return wxMac2UnixFilename( wxMacFSSpec2MacFilename( spec) ) ;
@@ -901,7 +918,7 @@ void wxUnixFilename2FSSpec( const char *path , FSSpec *spec )
wxString var = wxUnix2MacFilename( path ) ;
wxMacFilename2FSSpec( var , spec ) ;
}
*/
#endif
void
wxDos2UnixFilename (char *s)
@@ -1099,7 +1116,7 @@ bool wxRemoveFile(const wxString& file)
bool wxMkdir(const wxString& dir, int perm)
{
#if defined(__WXMAC__) && !defined(__UNIX__)
return (mkdir(wxUnix2MacFilename( dir ) , 0 ) == 0);
return (mkdir( dir , 0 ) == 0);
#else // !Mac
const wxChar *dirname = dir.c_str();
@@ -1395,7 +1412,7 @@ wxString wxFindFirstFile(const wxChar *spec, int flags)
FSSpec fsspec ;
wxUnixFilename2FSSpec( result , &fsspec ) ;
wxMacFilename2FSSpec( result , &fsspec ) ;
g_iter.m_CPB.hFileInfo.ioVRefNum = fsspec.vRefNum ;
g_iter.m_CPB.hFileInfo.ioNamePtr = g_iter.m_name ;
g_iter.m_index = 0 ;
@@ -1443,7 +1460,7 @@ wxString wxFindNextFile()
g_iter.m_name,
&spec) ;
return wxMacFSSpec2UnixFilename( &spec ) ;
return wxMacFSSpec2MacFilename( &spec ) ;
}
#elif defined(__WXMSW__)
@@ -1697,7 +1714,7 @@ wxChar *wxGetWorkingDirectory(wxChar *buf, int sz)
cwdSpec.vRefNum = pb.ioFCBVRefNum;
cwdSpec.parID = pb.ioFCBParID;
cwdSpec.name[0] = 0 ;
wxString res = wxMacFSSpec2UnixFilename( &cwdSpec ) ;
wxString res = wxMacFSSpec2MacFilename( &cwdSpec ) ;
strcpy( buf , res ) ;
buf[res.length()-1]=0 ;

View File

@@ -227,11 +227,7 @@ bool wxResourceTable::ParseResourceFile(const wxString& filename)
{
wxExprDatabase db;
#if defined(__WXMAC__) && !defined(__UNIX__)
FILE *fd = fopen(wxUnix2MacFilename(filename.fn_str()), "r");
#else
FILE *fd = wxFopen(filename, _T("r"));
#endif
if (!fd)
return FALSE;
bool eof = FALSE;

View File

@@ -67,6 +67,10 @@
#endif // __WXPM__
#ifdef __WXMAC__
#include "moreextr.h"
#endif
#ifdef __BORLANDC__
#include "dos.h"
#endif
@@ -593,7 +597,17 @@ void wxGenericDirCtrl::SetupSections()
}
}
#endif
#elif defined(__WXMAC__)
FSSpec volume ;
short index = 1 ;
while(1) {
short actualCount = 0 ;
if ( OnLine( &volume , 1 , &actualCount , &index ) != noErr || actualCount == 0 )
break ;
wxString name = wxMacFSSpec2MacFilename( &volume ) ;
AddSection(name+":", name, 0);
}
#else
AddSection(wxT("/"), _("The Computer"), 0);
AddSection(wxGetHomeDir(), _("My Home"), 0 );

View File

@@ -492,7 +492,7 @@ int wxDirDialog::ShowModal()
}
else
{
m_path = wxMacFSSpec2UnixFilename( &reply.sfFile ) ;
m_path = wxMacFSSpec2MacFilename( &reply.sfFile ) ;
return wxID_OK ;
}
return wxID_CANCEL;
@@ -589,7 +589,7 @@ int wxDirDialog::ShowModal()
name, &outFileSpec);
// outFolderDirID = thePB.dirInfo.ioDrDirID;
m_path = wxMacFSSpec2UnixFilename( &outFileSpec ) ;
m_path = wxMacFSSpec2MacFilename( &outFileSpec ) ;
return wxID_OK ;
}
return wxID_CANCEL;

View File

@@ -113,7 +113,7 @@ wxDirData::wxDirData(const wxString& dirname)
FSSpec fsspec ;
wxUnixFilename2FSSpec( m_dirname , &fsspec ) ;
wxMacFilename2FSSpec( m_dirname , &fsspec ) ;
m_CPB.hFileInfo.ioVRefNum = fsspec.vRefNum ;
m_CPB.hFileInfo.ioNamePtr = m_name ;
m_index = 0 ;

View File

@@ -533,7 +533,7 @@ int wxFileDialog::ShowModal()
}
else
{
m_path = wxMacFSSpec2UnixFilename( &reply.sfFile ) ;
m_path = wxMacFSSpec2MacFilename( &reply.sfFile ) ;
return wxID_OK ;
}
}
@@ -574,7 +574,7 @@ int wxFileDialog::ShowModal()
}
else
{
m_path = wxMacFSSpec2UnixFilename( &reply.sfFile ) ;
m_path = wxMacFSSpec2MacFilename( &reply.sfFile ) ;
return wxID_OK ;
}
}
@@ -609,7 +609,7 @@ int wxFileDialog::ShowModal()
// first appears
FSSpec location ;
wxUnixFilename2FSSpec( m_dir , &location ) ;
wxMacFilename2FSSpec( m_dir , &location ) ;
OSErr err = noErr ;
mDefaultLocation.descriptorType = typeNull;
@@ -704,7 +704,7 @@ int wxFileDialog::ShowModal()
// outFolderDirID = thePB.dirInfo.ioDrDirID;
m_path = wxMacFSSpec2UnixFilename( &outFileSpec ) ;
m_path = wxMacFSSpec2MacFilename( &outFileSpec ) ;
m_paths.Add( m_path ) ;
m_fileNames.Add(m_fileName);
}

View File

@@ -414,11 +414,8 @@ bool wxPNGReader::ReadFile(char * ImageFileName)
wxPNGReaderIter iter(this);
/* open the file */
#ifndef __UNIX__
fp = fopen(wxUnix2MacFilename( ImageFileName ), "rb");
#else
fp = fopen( ImageFileName , "rb" );
#endif
if (!fp)
return FALSE;

View File

@@ -15,6 +15,8 @@
#include "wx/app.h"
#include "wx/stattext.h"
#include "wx/notebook.h"
#include "wx/tabctrl.h"
#include "wx/dc.h"
#include "wx/dcclient.h"
@@ -61,6 +63,38 @@ void wxStaticText::OnDraw( wxDC &dc )
return;
PrepareDC(dc);
bool doClear = true ;
WindowRef window = GetMacRootWindow() ;
if ( window )
{
wxWindow* win = wxFindWinFromMacWindow( window ) ;
if ( win )
{
wxWindow* parent = GetParent() ;
while ( parent )
{
if( parent->MacGetWindowData() )
{
break ;
}
if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
{
if ( ((wxControl*)parent)->GetMacControl() ) {
Rect rect = { -32767 , -32767 , 32767 , 32767 } ;
if ( DrawThemeTabPane != (void*)kUnresolvedCFragSymbolAddress )
DrawThemeTabPane ( &rect, kThemeStateActive);
doClear = false ;
}
break ;
}
parent = parent->GetParent() ;
}
}
}
if ( doClear )
dc.Clear() ;
int x = 0 ;

View File

@@ -329,7 +329,7 @@ wxString wxMacFindFolder( short vol,
FSSpec file ;
if ( FSMakeFSSpec( vRefNum , dirID , "\p" , &file ) == noErr )
{
strDir = wxMacFSSpec2UnixFilename( &file ) + "/" ;
strDir = wxMacFSSpec2MacFilename( &file ) + ":" ;
}
}
return strDir ;

View File

@@ -492,7 +492,7 @@ int wxDirDialog::ShowModal()
}
else
{
m_path = wxMacFSSpec2UnixFilename( &reply.sfFile ) ;
m_path = wxMacFSSpec2MacFilename( &reply.sfFile ) ;
return wxID_OK ;
}
return wxID_CANCEL;
@@ -589,7 +589,7 @@ int wxDirDialog::ShowModal()
name, &outFileSpec);
// outFolderDirID = thePB.dirInfo.ioDrDirID;
m_path = wxMacFSSpec2UnixFilename( &outFileSpec ) ;
m_path = wxMacFSSpec2MacFilename( &outFileSpec ) ;
return wxID_OK ;
}
return wxID_CANCEL;

View File

@@ -113,7 +113,7 @@ wxDirData::wxDirData(const wxString& dirname)
FSSpec fsspec ;
wxUnixFilename2FSSpec( m_dirname , &fsspec ) ;
wxMacFilename2FSSpec( m_dirname , &fsspec ) ;
m_CPB.hFileInfo.ioVRefNum = fsspec.vRefNum ;
m_CPB.hFileInfo.ioNamePtr = m_name ;
m_index = 0 ;

View File

@@ -533,7 +533,7 @@ int wxFileDialog::ShowModal()
}
else
{
m_path = wxMacFSSpec2UnixFilename( &reply.sfFile ) ;
m_path = wxMacFSSpec2MacFilename( &reply.sfFile ) ;
return wxID_OK ;
}
}
@@ -574,7 +574,7 @@ int wxFileDialog::ShowModal()
}
else
{
m_path = wxMacFSSpec2UnixFilename( &reply.sfFile ) ;
m_path = wxMacFSSpec2MacFilename( &reply.sfFile ) ;
return wxID_OK ;
}
}
@@ -609,7 +609,7 @@ int wxFileDialog::ShowModal()
// first appears
FSSpec location ;
wxUnixFilename2FSSpec( m_dir , &location ) ;
wxMacFilename2FSSpec( m_dir , &location ) ;
OSErr err = noErr ;
mDefaultLocation.descriptorType = typeNull;
@@ -704,7 +704,7 @@ int wxFileDialog::ShowModal()
// outFolderDirID = thePB.dirInfo.ioDrDirID;
m_path = wxMacFSSpec2UnixFilename( &outFileSpec ) ;
m_path = wxMacFSSpec2MacFilename( &outFileSpec ) ;
m_paths.Add( m_path ) ;
m_fileNames.Add(m_fileName);
}

View File

@@ -414,11 +414,8 @@ bool wxPNGReader::ReadFile(char * ImageFileName)
wxPNGReaderIter iter(this);
/* open the file */
#ifndef __UNIX__
fp = fopen(wxUnix2MacFilename( ImageFileName ), "rb");
#else
fp = fopen( ImageFileName , "rb" );
#endif
if (!fp)
return FALSE;

View File

@@ -15,6 +15,8 @@
#include "wx/app.h"
#include "wx/stattext.h"
#include "wx/notebook.h"
#include "wx/tabctrl.h"
#include "wx/dc.h"
#include "wx/dcclient.h"
@@ -61,6 +63,38 @@ void wxStaticText::OnDraw( wxDC &dc )
return;
PrepareDC(dc);
bool doClear = true ;
WindowRef window = GetMacRootWindow() ;
if ( window )
{
wxWindow* win = wxFindWinFromMacWindow( window ) ;
if ( win )
{
wxWindow* parent = GetParent() ;
while ( parent )
{
if( parent->MacGetWindowData() )
{
break ;
}
if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
{
if ( ((wxControl*)parent)->GetMacControl() ) {
Rect rect = { -32767 , -32767 , 32767 , 32767 } ;
if ( DrawThemeTabPane != (void*)kUnresolvedCFragSymbolAddress )
DrawThemeTabPane ( &rect, kThemeStateActive);
doClear = false ;
}
break ;
}
parent = parent->GetParent() ;
}
}
}
if ( doClear )
dc.Clear() ;
int x = 0 ;

View File

@@ -329,7 +329,7 @@ wxString wxMacFindFolder( short vol,
FSSpec file ;
if ( FSMakeFSSpec( vRefNum , dirID , "\p" , &file ) == noErr )
{
strDir = wxMacFSSpec2UnixFilename( &file ) + "/" ;
strDir = wxMacFSSpec2MacFilename( &file ) + ":" ;
}
}
return strDir ;