Add skeleton utils, dir and mimetype for dos.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33873 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
119
src/msdos/dir.cpp
Normal file
119
src/msdos/dir.cpp
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: src/palmos/dir.cpp
|
||||||
|
// Purpose: wxDir implementation for PalmOS
|
||||||
|
// Author: William Osborne - minimal working wxPalmOS port
|
||||||
|
// Modified by:
|
||||||
|
// Created: 10.13.04
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) William Osborne
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// declarations
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// headers
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
||||||
|
#pragma implementation "dir.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// For compilers that support precompilation, includes "wx.h".
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/intl.h"
|
||||||
|
#include "wx/log.h"
|
||||||
|
#endif // PCH
|
||||||
|
|
||||||
|
#include "wx/dir.h"
|
||||||
|
#include "wx/filefn.h" // for wxDirExists()
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// define the types and functions used for file searching
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// constants
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifndef MAX_PATH
|
||||||
|
#define MAX_PATH 260 // from VC++ headers
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// macros
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#define M_DIR ((wxDirData *)m_data)
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// private classes
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// implementation
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxDir helpers
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/* static */
|
||||||
|
bool wxDir::Exists(const wxString& dir)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxDir construction/destruction
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxDir::wxDir(const wxString& dirname)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxDir::Open(const wxString& dirname)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxDir::IsOpened() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString wxDir::GetName() const
|
||||||
|
{
|
||||||
|
wxString name;
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDir::~wxDir()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxDir enumerating
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool wxDir::GetFirst(wxString *filename,
|
||||||
|
const wxString& filespec,
|
||||||
|
int flags) const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxDir::GetNext(wxString *filename) const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
230
src/msdos/mimetype.cpp
Normal file
230
src/msdos/mimetype.cpp
Normal file
@@ -0,0 +1,230 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: mac/mimetype.cpp
|
||||||
|
// Purpose: classes and functions to manage MIME types
|
||||||
|
// Author: Vadim Zeitlin
|
||||||
|
// Modified by:
|
||||||
|
// Created: 23.09.98
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||||
|
// Licence: wxWindows licence (part of wxExtra library)
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation "mimetype.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// for compilers that support precompilation, includes "wx.h".
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/defs.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/string.h"
|
||||||
|
#if wxUSE_GUI
|
||||||
|
#include "wx/icon.h"
|
||||||
|
#endif
|
||||||
|
#endif //WX_PRECOMP
|
||||||
|
|
||||||
|
#if wxUSE_MIMETYPE
|
||||||
|
|
||||||
|
#include "wx/log.h"
|
||||||
|
#include "wx/file.h"
|
||||||
|
#include "wx/intl.h"
|
||||||
|
#include "wx/dynarray.h"
|
||||||
|
#include "wx/confbase.h"
|
||||||
|
|
||||||
|
#include "wx/msdos/mimetype.h"
|
||||||
|
|
||||||
|
// other standard headers
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
// in case we're compiling in non-GUI mode
|
||||||
|
class WXDLLEXPORT wxIcon;
|
||||||
|
|
||||||
|
bool wxFileTypeImpl::SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxFileTypeImpl::SetDefaultIcon(const wxString& strIcon, int index)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxFileTypeImpl::GetCommand(wxString *command, const char *verb) const
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// @@ this function is half implemented
|
||||||
|
bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const
|
||||||
|
{
|
||||||
|
if ( m_strFileType.Length() > 0 )
|
||||||
|
{
|
||||||
|
*mimeType = m_strFileType ;
|
||||||
|
return TRUE ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const
|
||||||
|
{
|
||||||
|
wxString s;
|
||||||
|
|
||||||
|
if (GetMimeType(&s))
|
||||||
|
{
|
||||||
|
mimeTypes.Clear();
|
||||||
|
mimeTypes.Add(s);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxFileTypeImpl::GetIcon(wxIconLocation *WXUNUSED(icon)) const
|
||||||
|
{
|
||||||
|
// no such file type or no value or incorrect icon entry
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxFileTypeImpl::GetDescription(wxString *desc) const
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
wxFileTypeImpl::GetAllCommands(wxArrayString * verbs, wxArrayString * commands,
|
||||||
|
const wxFileType::MessageParameters& params) const
|
||||||
|
{
|
||||||
|
wxFAIL_MSG( _T("wxFileTypeImpl::GetAllCommands() not yet implemented") );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
wxMimeTypesManagerImpl::Initialize(int mailcapStyles, const wxString& extraDir)
|
||||||
|
{
|
||||||
|
wxFAIL_MSG( _T("wxMimeTypesManagerImpl::Initialize() not yet implemented") );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
wxMimeTypesManagerImpl::ClearData()
|
||||||
|
{
|
||||||
|
wxFAIL_MSG( _T("wxMimeTypesManagerImpl::ClearData() not yet implemented") );
|
||||||
|
}
|
||||||
|
|
||||||
|
// extension -> file type
|
||||||
|
wxFileType *
|
||||||
|
wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& e)
|
||||||
|
{
|
||||||
|
wxString ext = e ;
|
||||||
|
ext = ext.Lower() ;
|
||||||
|
if ( ext == wxT("txt") )
|
||||||
|
{
|
||||||
|
wxFileType *fileType = new wxFileType;
|
||||||
|
fileType->m_impl->SetFileType(wxT("text/text"));
|
||||||
|
fileType->m_impl->SetExt(ext);
|
||||||
|
return fileType;
|
||||||
|
}
|
||||||
|
else if ( ext == wxT("htm") || ext == wxT("html") )
|
||||||
|
{
|
||||||
|
wxFileType *fileType = new wxFileType;
|
||||||
|
fileType->m_impl->SetFileType(wxT("text/html"));
|
||||||
|
fileType->m_impl->SetExt(ext);
|
||||||
|
return fileType;
|
||||||
|
}
|
||||||
|
else if ( ext == wxT("gif") )
|
||||||
|
{
|
||||||
|
wxFileType *fileType = new wxFileType;
|
||||||
|
fileType->m_impl->SetFileType(wxT("image/gif"));
|
||||||
|
fileType->m_impl->SetExt(ext);
|
||||||
|
return fileType;
|
||||||
|
}
|
||||||
|
else if ( ext == wxT("png" ))
|
||||||
|
{
|
||||||
|
wxFileType *fileType = new wxFileType;
|
||||||
|
fileType->m_impl->SetFileType(wxT("image/png"));
|
||||||
|
fileType->m_impl->SetExt(ext);
|
||||||
|
return fileType;
|
||||||
|
}
|
||||||
|
else if ( ext == wxT("jpg" )|| ext == wxT("jpeg") )
|
||||||
|
{
|
||||||
|
wxFileType *fileType = new wxFileType;
|
||||||
|
fileType->m_impl->SetFileType(wxT("image/jpeg"));
|
||||||
|
fileType->m_impl->SetExt(ext);
|
||||||
|
return fileType;
|
||||||
|
}
|
||||||
|
else if ( ext == wxT("bmp") )
|
||||||
|
{
|
||||||
|
wxFileType *fileType = new wxFileType;
|
||||||
|
fileType->m_impl->SetFileType(wxT("image/bmp"));
|
||||||
|
fileType->m_impl->SetExt(ext);
|
||||||
|
return fileType;
|
||||||
|
}
|
||||||
|
else if ( ext == wxT("tif") || ext == wxT("tiff") )
|
||||||
|
{
|
||||||
|
wxFileType *fileType = new wxFileType;
|
||||||
|
fileType->m_impl->SetFileType(wxT("image/tiff"));
|
||||||
|
fileType->m_impl->SetExt(ext);
|
||||||
|
return fileType;
|
||||||
|
}
|
||||||
|
else if ( ext == wxT("xpm") )
|
||||||
|
{
|
||||||
|
wxFileType *fileType = new wxFileType;
|
||||||
|
fileType->m_impl->SetFileType(wxT("image/xpm"));
|
||||||
|
fileType->m_impl->SetExt(ext);
|
||||||
|
return fileType;
|
||||||
|
}
|
||||||
|
else if ( ext == wxT("xbm") )
|
||||||
|
{
|
||||||
|
wxFileType *fileType = new wxFileType;
|
||||||
|
fileType->m_impl->SetFileType(wxT("image/xbm"));
|
||||||
|
fileType->m_impl->SetExt(ext);
|
||||||
|
return fileType;
|
||||||
|
}
|
||||||
|
|
||||||
|
// unknown extension
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// MIME type -> extension -> file type
|
||||||
|
wxFileType *
|
||||||
|
wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& mimetypes)
|
||||||
|
{
|
||||||
|
// VZ: don't know anything about this for Mac
|
||||||
|
wxFAIL_MSG( _T("wxMimeTypesManagerImpl::EnumAllFileTypes() not yet implemented") );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxFileType *
|
||||||
|
wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo)
|
||||||
|
{
|
||||||
|
wxFAIL_MSG( _T("wxMimeTypesManagerImpl::Associate() not yet implemented") );
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
wxMimeTypesManagerImpl::Unassociate(wxFileType *ft)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_MIMETYPE
|
176
src/msdos/utilsdos.cpp
Normal file
176
src/msdos/utilsdos.cpp
Normal file
@@ -0,0 +1,176 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: utils.cpp
|
||||||
|
// Purpose: DOS implementations of utility functions
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Id: $Id$
|
||||||
|
// Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// For compilers that support precompilation, includes "wx.h".
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wx/utils.h"
|
||||||
|
#include "wx/string.h"
|
||||||
|
|
||||||
|
#include "wx/intl.h"
|
||||||
|
#include "wx/apptrait.h"
|
||||||
|
#include "wx/log.h"
|
||||||
|
#include "wx/process.h"
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
// misc.
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxSleep(int nSecs)
|
||||||
|
{
|
||||||
|
wxMilliSleep(1000 * nSecs);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxMilliSleep(unsigned long milliseconds)
|
||||||
|
{
|
||||||
|
#if HAVE_USLEEP || defined __DJGPP__
|
||||||
|
usleep(milliseconds * 1000);
|
||||||
|
#elif defined __WATCOMC__
|
||||||
|
delay(milliseconds);
|
||||||
|
#else
|
||||||
|
clock_t start = clock();
|
||||||
|
while ((clock() - start) * 1000 / CLOCKS_PER_SEC < (clock_t)milliseconds)
|
||||||
|
; // FIXME: need to yield here
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxMicroSleep(unsigned long microseconds)
|
||||||
|
{
|
||||||
|
#if HAVE_USLEEP || defined __DJGPP__
|
||||||
|
usleep(microseconds);
|
||||||
|
#else
|
||||||
|
wxMilliSleep(microseconds/1000);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get Process ID
|
||||||
|
unsigned long wxGetProcessId()
|
||||||
|
{
|
||||||
|
return (unsigned long)getpid();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxGetEnv(const wxString& var, wxString *value)
|
||||||
|
{
|
||||||
|
// wxGetenv is defined as getenv()
|
||||||
|
wxChar *p = wxGetenv(var);
|
||||||
|
if ( !p )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if ( value )
|
||||||
|
*value = p;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxSetEnv(const wxString& variable, const wxChar *value)
|
||||||
|
{
|
||||||
|
wxString s = variable;
|
||||||
|
if ( value )
|
||||||
|
s << _T('=') << value;
|
||||||
|
|
||||||
|
// transform to ANSI
|
||||||
|
const char *p = s.mb_str();
|
||||||
|
|
||||||
|
// the string will be free()d by libc
|
||||||
|
char *buf = (char *)malloc(strlen(p) + 1);
|
||||||
|
strcpy(buf, p);
|
||||||
|
|
||||||
|
return putenv(buf) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const wxChar* wxGetHomeDir(wxString *home)
|
||||||
|
{
|
||||||
|
*home = wxT(".");
|
||||||
|
return home->c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
const wxChar* wxGetUserHomeDir(wxString *home)
|
||||||
|
{
|
||||||
|
*home = wxT(".");
|
||||||
|
return home->c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
wxChar *wxGetUserHome(const wxString &user)
|
||||||
|
{
|
||||||
|
return wxT(".");
|
||||||
|
}
|
||||||
|
|
||||||
|
#if WXWIN_COMPATIBILITY_2_2
|
||||||
|
void wxFatalError(const wxString &msg, const wxString &title)
|
||||||
|
{
|
||||||
|
wxFprintf( stderr, _("Error ") );
|
||||||
|
if (!title.IsNull()) wxFprintf( stderr, wxT("%s "), WXSTRINGCAST(title) );
|
||||||
|
if (!msg.IsNull()) wxFprintf( stderr, wxT(": %s"), WXSTRINGCAST(msg) );
|
||||||
|
wxFprintf( stderr, wxT(".\n") );
|
||||||
|
exit(3); // the same exit code as for abort()
|
||||||
|
}
|
||||||
|
#endif // WXWIN_COMPATIBILITY_2_2
|
||||||
|
|
||||||
|
bool wxGetUserId(wxChar *WXUNUSED(buf), int WXUNUSED(sz))
|
||||||
|
{
|
||||||
|
wxFAIL_MSG( wxT("wxGetUserId not implemented under MS-DOS!") );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxGetUserName(wxChar *WXUNUSED(buf), int WXUNUSED(sz))
|
||||||
|
{
|
||||||
|
wxFAIL_MSG( wxT("wxGetUserName not implemented under MS-DOS!") );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxGetHostName(wxChar *WXUNUSED(buf), int WXUNUSED(sz))
|
||||||
|
{
|
||||||
|
wxFAIL_MSG( wxT("wxGetHostName not implemented under MS-DOS!") );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxGetFullHostName(wxChar *WXUNUSED(buf), int WXUNUSED(sz))
|
||||||
|
{
|
||||||
|
wxFAIL_MSG( wxT("wxGetFullHostName not implemented under MS-DOS!") );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxKill(long WXUNUSED(pid), wxSignal WXUNUSED(sig), wxKillError *WXUNUSED(rc), int WXUNUSED(flags))
|
||||||
|
{
|
||||||
|
wxFAIL_MSG( wxT("wxKill not implemented under MS-DOS!") );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
long wxExecute(const wxString& WXUNUSED(command), int WXUNUSED(flags), wxProcess *WXUNUSED(process))
|
||||||
|
{
|
||||||
|
wxFAIL_MSG( wxT("wxExecute not implemented under MS-DOS!") );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
long wxExecute(char **WXUNUSED(argv), int WXUNUSED(flags), wxProcess *WXUNUSED(process))
|
||||||
|
{
|
||||||
|
wxFAIL_MSG( wxT("wxExecute not implemented under MS-DOS!") );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxToolkitInfo& wxConsoleAppTraits::GetToolkitInfo()
|
||||||
|
{
|
||||||
|
static wxToolkitInfo info;
|
||||||
|
info.versionMajor = -1; // FIXME
|
||||||
|
info.versionMinor = -1;
|
||||||
|
info.name = _T("wxBase");
|
||||||
|
info.os = wxDOS;
|
||||||
|
return info;
|
||||||
|
}
|
Reference in New Issue
Block a user