2000-12-27 19:00:32 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: filename.h
|
|
|
|
// Purpose: wxFileName - encapsulates ice cream
|
|
|
|
// Author: Robert Roebling
|
|
|
|
// Modified by:
|
|
|
|
// Created: 28.12.00
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) 2000 Robert Roebling
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_FILENAME_H_
|
|
|
|
#define _WX_FILENAME_H_
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface "filename.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include "wx/string.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// ridiculously enough, this will replace DirExists with wxDirExists etc
|
2000-12-29 12:39:00 -05:00
|
|
|
#include "wx/filefn.h"
|
2000-12-27 19:00:32 -05:00
|
|
|
|
|
|
|
enum wxPathFormat
|
|
|
|
{
|
|
|
|
wxPATH_NATIVE = 0,
|
|
|
|
wxPATH_UNIX,
|
|
|
|
wxPATH_MAC,
|
|
|
|
wxPATH_DOS,
|
2000-12-29 12:39:00 -05:00
|
|
|
|
2000-12-27 19:00:32 -05:00
|
|
|
wxPATH_BEOS = wxPATH_UNIX,
|
|
|
|
wxPATH_WIN = wxPATH_DOS,
|
|
|
|
wxPATH_OS2 = wxPATH_DOS
|
2000-12-29 12:39:00 -05:00
|
|
|
|
2000-12-27 19:00:32 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxFileName
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// constructors and assignment
|
2000-12-29 12:39:00 -05:00
|
|
|
wxFileName()
|
2000-12-27 19:00:32 -05:00
|
|
|
{ }
|
|
|
|
wxFileName( const wxFileName &filename );
|
|
|
|
wxFileName( const wxString &path, bool dir_only = FALSE, wxPathFormat format = wxPATH_NATIVE )
|
|
|
|
{ Assign( path, dir_only, format ); }
|
|
|
|
void Assign( const wxString &path, bool dir_only = FALSE, wxPathFormat format = wxPATH_NATIVE );
|
2000-12-29 12:39:00 -05:00
|
|
|
|
2000-12-27 19:00:32 -05:00
|
|
|
// Only native form
|
|
|
|
bool FileExists();
|
|
|
|
bool DirExists();
|
2000-12-29 12:39:00 -05:00
|
|
|
|
2000-12-27 19:00:32 -05:00
|
|
|
void AssignCwd();
|
|
|
|
void SetCwd();
|
2000-12-29 12:39:00 -05:00
|
|
|
|
2000-12-27 19:00:32 -05:00
|
|
|
void AssignTempFileName( const wxString &prefix );
|
2000-12-29 12:39:00 -05:00
|
|
|
|
2000-12-27 19:00:32 -05:00
|
|
|
void Mkdir( int perm = 0777 );
|
|
|
|
void Rmdir();
|
2000-12-29 12:39:00 -05:00
|
|
|
|
2000-12-27 19:00:32 -05:00
|
|
|
// Remove . and .. (under Unix ~ as well)
|
|
|
|
void MakeAbsolute();
|
2000-12-29 12:39:00 -05:00
|
|
|
|
2000-12-27 19:00:32 -05:00
|
|
|
// Comparison
|
|
|
|
bool SameAs( const wxFileName &filename, bool upper_on_dos = TRUE );
|
2000-12-29 12:39:00 -05:00
|
|
|
|
2000-12-27 19:00:32 -05:00
|
|
|
// Tests
|
|
|
|
bool IsCaseSensitive( wxPathFormat format = wxPATH_NATIVE );
|
|
|
|
bool IsRelative( wxPathFormat format = wxPATH_NATIVE );
|
|
|
|
bool IsAbsolute( wxPathFormat format = wxPATH_NATIVE );
|
|
|
|
bool IsWild( wxPathFormat format = wxPATH_NATIVE );
|
2000-12-29 12:39:00 -05:00
|
|
|
|
2000-12-27 19:00:32 -05:00
|
|
|
// Dir accessors
|
|
|
|
void AppendDir( const wxString &dir );
|
|
|
|
void PrependDir( const wxString &dir );
|
|
|
|
void InsertDir( int before, const wxString &dir );
|
|
|
|
void RemoveDir( int pos );
|
|
|
|
size_t GetDirCount() { return m_dirs.GetCount(); }
|
2000-12-29 12:39:00 -05:00
|
|
|
|
2000-12-27 19:00:32 -05:00
|
|
|
// Other accessors
|
|
|
|
void SetExt( const wxString &ext ) { m_ext = ext; }
|
|
|
|
wxString GetExt() const { return m_ext; }
|
|
|
|
bool HasExt() const { return !m_ext.IsEmpty(); }
|
2000-12-29 12:39:00 -05:00
|
|
|
|
2000-12-27 19:00:32 -05:00
|
|
|
void SetName( const wxString &name ) { m_name = name; }
|
|
|
|
wxString GetName() const { return m_name; }
|
|
|
|
bool HasName() const { return !m_name.IsEmpty(); }
|
2000-12-29 12:39:00 -05:00
|
|
|
|
2000-12-27 19:00:32 -05:00
|
|
|
const wxArrayString &GetDirs() const { return m_dirs; }
|
2000-12-29 12:39:00 -05:00
|
|
|
|
2000-12-27 19:00:32 -05:00
|
|
|
// Construct path only
|
|
|
|
wxString GetPath( wxPathFormat format = wxPATH_NATIVE ) const;
|
2000-12-29 12:39:00 -05:00
|
|
|
|
2000-12-27 19:00:32 -05:00
|
|
|
// Construct full path with name and ext
|
|
|
|
wxString GetFullPath( wxPathFormat format = wxPATH_NATIVE ) const;
|
2000-12-29 12:39:00 -05:00
|
|
|
|
|
|
|
|
2000-12-27 19:00:32 -05:00
|
|
|
static wxPathFormat GetFormat( wxPathFormat format = wxPATH_NATIVE );
|
2000-12-29 12:39:00 -05:00
|
|
|
|
2000-12-27 19:00:32 -05:00
|
|
|
private:
|
|
|
|
wxArrayString m_dirs;
|
|
|
|
wxString m_name;
|
|
|
|
wxString m_ext;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _WX_FFILENAME_H_
|
|
|
|
|