+ wxFileHandle f(filename, wxFileHandle::Read);
+ if (!f.IsOk())
+ return wxInvalidSize;
+
+ DWORD lpFileSizeHigh;
+ DWORD ret = GetFileSize(f, &lpFileSizeHigh);
+ if ( ret == INVALID_FILE_SIZE && ::GetLastError() != NO_ERROR )
+ return wxInvalidSize;
+
+ return wxULongLong(lpFileSizeHigh, ret);
+#else // ! __WIN32__
+ wxStructStat st;
+#ifndef wxNEED_WX_UNISTD_H
+ if (wxStat( filename.fn_str() , &st) != 0)
+#else
+ if (wxStat( filename, &st) != 0)
+#endif
+ return wxInvalidSize;
+ return wxULongLong(st.st_size);
+#endif
+}
+
+/* static */
+wxString wxFileName::GetHumanReadableSize(const wxULongLong &bs,
+ const wxString &nullsize,
+ int precision)
+{
+ static const double KILOBYTESIZE = 1024.0;
+ static const double MEGABYTESIZE = 1024.0*KILOBYTESIZE;
+ static const double GIGABYTESIZE = 1024.0*MEGABYTESIZE;
+ static const double TERABYTESIZE = 1024.0*GIGABYTESIZE;
+
+ if (bs == 0 || bs == wxInvalidSize)
+ return nullsize;
+
+ double bytesize = bs.ToDouble();
+ if (bytesize < KILOBYTESIZE)
+ return wxString::Format(_("%s B"), bs.ToString().c_str());
+ if (bytesize < MEGABYTESIZE)
+ return wxString::Format(_("%.*f kB"), precision, bytesize/KILOBYTESIZE);
+ if (bytesize < GIGABYTESIZE)
+ return wxString::Format(_("%.*f MB"), precision, bytesize/MEGABYTESIZE);
+ if (bytesize < TERABYTESIZE)
+ return wxString::Format(_("%.*f GB"), precision, bytesize/GIGABYTESIZE);
+
+ return wxString::Format(_("%.*f TB"), precision, bytesize/TERABYTESIZE);
+}
+
+wxULongLong wxFileName::GetSize() const
+{
+ return GetSize(GetFullPath());
+}
+
+wxString wxFileName::GetHumanReadableSize(const wxString &failmsg, int precision) const
+{
+ return GetHumanReadableSize(GetSize(), failmsg, precision);
+}
+
+#endif // wxUSE_LONGLONG
+
+// ----------------------------------------------------------------------------
+// Mac-specific functions
+// ----------------------------------------------------------------------------
+
+#ifdef __WXMAC__
+
+const short kMacExtensionMaxLength = 16 ;
+class MacDefaultExtensionRecord
+{
+public :
+ MacDefaultExtensionRecord()
+ {
+ m_ext[0] = 0 ;
+ m_type = m_creator = 0 ;
+ }
+ MacDefaultExtensionRecord( const MacDefaultExtensionRecord& from )
+ {
+ wxStrcpy( m_ext , from.m_ext ) ;
+ m_type = from.m_type ;
+ m_creator = from.m_creator ;
+ }
+ MacDefaultExtensionRecord( const wxChar * extension , OSType type , OSType creator )
+ {
+ wxStrncpy( m_ext , extension , kMacExtensionMaxLength ) ;
+ m_ext[kMacExtensionMaxLength] = 0 ;
+ m_type = type ;
+ m_creator = creator ;
+ }
+ wxChar m_ext[kMacExtensionMaxLength] ;
+ OSType m_type ;
+ OSType m_creator ;
+} ;
+
+WX_DECLARE_OBJARRAY(MacDefaultExtensionRecord, MacDefaultExtensionArray) ;
+
+bool gMacDefaultExtensionsInited = false ;
+
+#include "wx/arrimpl.cpp"
+
+WX_DEFINE_EXPORTED_OBJARRAY(MacDefaultExtensionArray) ;
+
+MacDefaultExtensionArray gMacDefaultExtensions ;
+
+// load the default extensions
+MacDefaultExtensionRecord gDefaults[] =
+{
+ MacDefaultExtensionRecord( wxT("txt") , 'TEXT' , 'ttxt' ) ,
+ MacDefaultExtensionRecord( wxT("tif") , 'TIFF' , '****' ) ,
+ MacDefaultExtensionRecord( wxT("jpg") , 'JPEG' , '****' ) ,
+} ;
+
+static void MacEnsureDefaultExtensionsLoaded()
+{
+ if ( !gMacDefaultExtensionsInited )