m_hFile = ::CreateFile
(
filename, // name
- mode == Read ? GENERIC_READ // access mask
+ mode == Read ? GENERIC_READ // access mask
: GENERIC_WRITE,
0, // no sharing
NULL, // no secutity attr
_T("the path shouldn't contain file name nor extension") );
#else // !__WXDEBUG__
- SplitPath(fullname, NULL /* no path */, &name, &ext, format);
+ SplitPath(fullname, NULL /* no path */, &name, &ext, format);
SplitPath(fullpath, &volume, &path, NULL, NULL, format);
#endif // __WXDEBUG__/!__WXDEBUG__
filename.AssignDir(dir);
wxString currPath;
- if ( filename.HasVolume())
- {
+ if ( filename.HasVolume())
+ {
currPath << wxGetVolumeString(filename.GetVolume(), wxPATH_NATIVE);
- }
+ }
wxArrayString dirs = filename.GetDirs();
size_t count = dirs.GetCount();
if ( m_dirs.IsEmpty() && IsDir() )
{
m_dirs.Add(_T('.'));
- }
+ }
}
m_relative = TRUE;
}
else if ( format == wxPATH_UNIX )
{
- if (!m_relative)
- fullpath += wxFILE_SEP_PATH_UNIX;
+ if ( !m_relative )
+ {
+ // normally the absolute file names starts with a slash with one
+ // exception: file names like "~/foo.bar" don't have it
+ if ( m_dirs.IsEmpty() || m_dirs[0u] != _T('~') )
+ {
+ fullpath += wxFILE_SEP_PATH_UNIX;
+ }
+ }
}
// then concatenate all the path components using the path separator
for ( size_t i = 0; i < dirCount; i++ )
{
- // TODO: What to do with ".." under VMS
-
switch (format)
{
case wxPATH_MAC:
- {
- if (m_dirs[i] == wxT("."))
- break;
- if (m_dirs[i] != wxT("..")) // convert back from ".." to nothing
+ if ( m_dirs[i] == wxT(".") )
+ {
+ // skip appending ':', this shouldn't be done in this
+ // case as "::" is interpreted as ".." under Unix
+ continue;
+ }
+
+ // convert back from ".." to nothing
+ if ( m_dirs[i] != wxT("..") )
fullpath += m_dirs[i];
- fullpath += wxT(':');
break;
- }
+
+ default:
+ wxFAIL_MSG( wxT("unexpected path format") );
+ // still fall through
+
case wxPATH_DOS:
- {
- fullpath += m_dirs[i];
- fullpath += wxT('\\');
- break;
- }
case wxPATH_UNIX:
- {
fullpath += m_dirs[i];
- fullpath += wxT('/');
break;
- }
+
case wxPATH_VMS:
- {
- if (m_dirs[i] != wxT("..")) // convert back from ".." to nothing
+ // TODO: What to do with ".." under VMS
+ // convert back from ".." to nothing
+ if ( m_dirs[i] != wxT("..") )
fullpath += m_dirs[i];
- if (i == dirCount-1)
- fullpath += wxT(']');
- else
- fullpath += wxT('.');
break;
- }
- default:
- {
- wxFAIL_MSG( wxT("error") );
- }
}
+
+ if ( i != dirCount - 1 )
+ fullpath += GetPathSeparator(format);
+ }
+
+ if ( format == wxPATH_VMS )
+ {
+ fullpath += wxT(']');
}
}
- if ( (flags & wxPATH_GET_SEPARATOR) && !fullpath.empty() )
+ if ( (flags & wxPATH_GET_SEPARATOR) && !fullpath.empty() && fullpath.Last() != GetPathSeparator(format))
{
fullpath += GetPathSeparator(format);
}
wxString wxFileName::GetFullPath( wxPathFormat format ) const
{
- format = GetFormat(format);
-
- // first put the volume
- wxString fullpath = wxGetVolumeString(m_volume, format);
-
- // the leading character
- if ( format == wxPATH_MAC )
- {
- if ( m_relative )
- fullpath += wxFILE_SEP_PATH_MAC;
- }
- else if ( format == wxPATH_DOS )
- {
- if ( !m_relative )
- fullpath += wxFILE_SEP_PATH_DOS;
- }
- else if ( format == wxPATH_UNIX )
- {
- if ( !m_relative )
- {
- // normally the absolute file names starts with a slash with one
- // exception: file names like "~/foo.bar" don't have it
- if ( m_dirs.IsEmpty() || m_dirs[0u] != _T('~') )
- {
- fullpath += wxFILE_SEP_PATH_UNIX;
- }
- }
- }
+ // we already have a function to get the path
+ wxString fullpath = GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR,
+ format);
- // then concatenate all the path components using the path separator
- size_t dirCount = m_dirs.GetCount();
- if ( dirCount )
- {
- if ( format == wxPATH_VMS )
- {
- fullpath += wxT('[');
- }
-
-
- for ( size_t i = 0; i < dirCount; i++ )
- {
- // TODO: What to do with ".." under VMS
-
- switch (format)
- {
- case wxPATH_MAC:
- {
- if (m_dirs[i] == wxT("."))
- break;
- if (m_dirs[i] != wxT("..")) // convert back from ".." to nothing
- fullpath += m_dirs[i];
- fullpath += wxT(':');
- break;
- }
- case wxPATH_DOS:
- {
- fullpath += m_dirs[i];
- fullpath += wxT('\\');
- break;
- }
- case wxPATH_UNIX:
- {
- fullpath += m_dirs[i];
- fullpath += wxT('/');
- break;
- }
- case wxPATH_VMS:
- {
- if (m_dirs[i] != wxT("..")) // convert back from ".." to nothing
- fullpath += m_dirs[i];
- if (i == dirCount-1)
- fullpath += wxT(']');
- else
- fullpath += wxT('.');
- break;
- }
- default:
- {
- wxFAIL_MSG( wxT("error") );
- }
- }
- }
- }
-
- // finally add the file name and extension
+ // now just add the file name and extension to it
fullpath += GetFullName();
return fullpath;
FILETIME ftAccess, ftCreate, ftWrite;
if ( ::GetFileTime(fh,
- dtMod ? &ftCreate : NULL,
+ dtCreate ? &ftCreate : NULL,
dtAccess ? &ftAccess : NULL,
- dtCreate ? &ftWrite : NULL) )
+ dtMod ? &ftWrite : NULL) )
{
- if ( dtMod )
- ConvertFileTimeToWx(dtMod, ftCreate);
+ if ( dtCreate )
+ ConvertFileTimeToWx(dtCreate, ftCreate);
if ( dtAccess )
ConvertFileTimeToWx(dtAccess, ftAccess);
- if ( dtCreate )
- ConvertFileTimeToWx(dtCreate, ftWrite);
+ if ( dtMod )
+ ConvertFileTimeToWx(dtMod, ftWrite);
return TRUE;
}
#ifdef __WXMAC__
const short kMacExtensionMaxLength = 16 ;
-typedef struct
+class MacDefaultExtensionRecord
{
+public :
+ MacDefaultExtensionRecord()
+ {
+ m_ext[0] = 0 ;
+ m_type = m_creator = NULL ;
+ }
+ MacDefaultExtensionRecord( const MacDefaultExtensionRecord& from )
+ {
+ strcpy( m_ext , from.m_ext ) ;
+ m_type = from.m_type ;
+ m_creator = from.m_creator ;
+ }
+ MacDefaultExtensionRecord( char * extension , OSType type , OSType creator )
+ {
+ strncpy( m_ext , extension , kMacExtensionMaxLength ) ;
+ m_ext[kMacExtensionMaxLength] = 0 ;
+ m_type = type ;
+ m_creator = creator ;
+ }
char m_ext[kMacExtensionMaxLength] ;
OSType m_type ;
OSType m_creator ;
-} MacDefaultExtensionRecord ;
+} ;
#include "wx/dynarray.h"
WX_DECLARE_OBJARRAY(MacDefaultExtensionRecord, MacDefaultExtensionArray) ;
+
+bool gMacDefaultExtensionsInited = false ;
+
#include "wx/arrimpl.cpp"
-WX_DEFINE_OBJARRAY(MacDefaultExtensionArray) ;
+
+WX_DEFINE_EXPORTED_OBJARRAY(MacDefaultExtensionArray) ;
MacDefaultExtensionArray gMacDefaultExtensions ;
-bool gMacDefaultExtensionsInited = false ;
static void MacEnsureDefaultExtensionsLoaded()
{
if ( !gMacDefaultExtensionsInited )
{
+
// load the default extensions
- MacDefaultExtensionRecord defaults[] =
+ MacDefaultExtensionRecord defaults[1] =
{
- { "txt" , 'TEXT' , 'ttxt' } ,
-
+ MacDefaultExtensionRecord( "txt" , 'TEXT' , 'ttxt' ) ,
+
} ;
// we could load the pc exchange prefs here too
-
+
for ( int i = 0 ; i < WXSIZEOF( defaults ) ; ++i )
{
gMacDefaultExtensions.Add( defaults[i] ) ;
- }
+ }
gMacDefaultExtensionsInited = true ;
}
}
-bool wxFileName::MacSetTypeAndCreator( wxUint32 type , wxUint32 creator )
+bool wxFileName::MacSetTypeAndCreator( wxUint32 type , wxUint32 creator )
{
FInfo fndrInfo ;
FSSpec spec ;
return true ;
}
-bool wxFileName::MacGetTypeAndCreator( wxUint32 *type , wxUint32 *creator )
+bool wxFileName::MacGetTypeAndCreator( wxUint32 *type , wxUint32 *creator )
{
FInfo fndrInfo ;
FSSpec spec ;
return false;
}
-bool wxFileName::MacFindDefaultTypeAndCreator( const wxString& ext , wxUint32 *type , wxUint32 *creator )
+bool wxFileName::MacFindDefaultTypeAndCreator( const wxString& ext , wxUint32 *type , wxUint32 *creator )
{
MacEnsureDefaultExtensionsLoaded() ;
wxString extl = ext.Lower() ;