OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [tools/] [configtool/] [standalone/] [wxwin/] [filename.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
// ####ECOSHOSTGPLCOPYRIGHTBEGIN####                                        
2
// -------------------------------------------                              
3
// This file is part of the eCos host tools.                                
4
// Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.            
5
//
6
// This program is free software; you can redistribute it and/or modify     
7
// it under the terms of the GNU General Public License as published by     
8
// the Free Software Foundation; either version 2 or (at your option) any   
9
// later version.                                                           
10
//
11
// This program is distributed in the hope that it will be useful, but      
12
// WITHOUT ANY WARRANTY; without even the implied warranty of               
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU        
14
// General Public License for more details.                                 
15
//
16
// You should have received a copy of the GNU General Public License        
17
// along with this program; if not, write to the                            
18
// Free Software Foundation, Inc., 51 Franklin Street,                      
19
// Fifth Floor, Boston, MA  02110-1301, USA.                                
20
// -------------------------------------------                              
21
// ####ECOSHOSTGPLCOPYRIGHTEND####                                          
22
//===========================================================================
23
//#####DESCRIPTIONBEGIN####
24
//
25
// Author(s):   sdf
26
// Contact(s):  sdf
27
// Date:                1998/09/11
28
// Version:             0.01
29
// Purpose:             Class to encapsulate filename operations (i.e. broadly on a file which probably do not involve opening
30
//              it).  Importantly, the + and += operators performs filename segment addition, making sure that only one '\\'
31
//                              comes between each piece.
32
//              Translated to wxWindows conventions by julians (in progress)
33
// Description: Interface of the filename class
34
// Requires:    
35
// Provides:    
36
// See also:    
37
// Known bugs:  
38
// Usage:       
39
//
40
//####DESCRIPTIONEND####
41
//
42
//===========================================================================
43
 
44
#ifndef _ECOS_FILENAME_H_
45
#define _ECOS_FILENAME_H_
46
 
47
#include "wx/wxchar.h"
48
#include "wx/dir.h"
49
 
50
/*
51
 * ecFileName
52
 *
53
 * This class extends wxString with functionality related
54
 * to filenames.
55
 */
56
 
57
class ecFileName : public wxString {
58
public:
59
    void ReplaceExtension (const wxString& newExt);
60
 
61
    // previous directory is returned:
62
    static ecFileName EC_SetCurrentDirectory (const wxChar* pszDir);
63
    const wxString Root() const;
64
    const wxString Extension() const;
65
    static ecFileName EC_GetTempPath();
66
    bool IsAbsolute() const;
67
 
68
    static const wxChar cSep;        // The path separator ('\' on windows)
69
 
70
    // Standard ctors
71
    ecFileName():wxString(){}
72
    ecFileName(const ecFileName& stringSrc):wxString(stringSrc){Normalize();}
73
    ecFileName(const wxString& stringSrc):wxString(stringSrc){Normalize();}
74
    ecFileName(wxChar ch, int nRepeat = 1):wxString(ch,nRepeat){Normalize();}
75
 
76
    ecFileName(/*LPCSTR*/ const wxChar* lpsz):wxString(lpsz){Normalize();}
77
 
78
    /* TODO
79
    ecFileName(LPCWSTR lpsz):wxString(lpsz){Normalize();}
80
    */
81
 
82
    ecFileName(/*LPCSTR*/ const wxChar* lpch, int nLength):wxString(lpch,nLength){Normalize();}
83
 
84
    /* TODO
85
    ecFileName(LPCWSTR lpch, int nLength):wxString(lpch,nLength){Normalize();}
86
    */
87
    ecFileName(const unsigned char* psz):wxString(psz){Normalize();}
88
 
89
    // Construct from path fragments
90
    ecFileName(const wxChar*,const wxChar*);
91
    ecFileName(const wxChar*,const wxChar*,const wxChar*);
92
    ecFileName(const wxChar*,const wxChar*,const wxChar*,const wxChar*);
93
    ecFileName(const wxChar*,const wxChar*,const wxChar*,const wxChar*,const wxChar*);
94
 
95
    //~ecFileName();
96
 
97
    // catenation operators: exactly one separator is placed between L and R
98
    const ecFileName& operator+=(const ecFileName& string);
99
    const ecFileName& operator+=(wxChar ch);
100
#ifdef _UNICODE
101
    const ecFileName& operator+=(char ch);
102
#endif
103
    const ecFileName& operator+=(const wxChar* lpsz);
104
    friend ecFileName operator+(const ecFileName& string1,const ecFileName& string2);
105
    friend ecFileName operator+(const ecFileName& string, wxChar ch);
106
    friend ecFileName operator+(wxChar ch, const ecFileName& string);
107
#ifdef _UNICODE
108
    friend ecFileName operator+(const ecFileName& string, char ch);
109
    friend ecFileName operator+(char ch, const ecFileName& string);
110
#endif
111
    friend ecFileName operator+(const ecFileName& string, const wxChar* lpsz);
112
    friend ecFileName operator+(const wxChar* lpsz, const ecFileName& string);
113
 
114
    // Textual append - no separator functionality
115
    const ecFileName& Append (wxChar ch);
116
    const ecFileName& Append (const wxChar* psz);
117
 
118
    // Utility functions
119
    const ecFileName FullName() const;   // full path name
120
    const ecFileName NoSpaceName() const;// sans spaces
121
    const ecFileName ShortName() const; // the type with ~s in it
122
    const ecFileName Tail() const;       // file name sans directory part
123
    const ecFileName Head() const;       // directory part
124
    const ecFileName CygPath() const;    // path mangled for CygWin
125
 
126
    static ecFileName EC_GetCurrentDirectory();
127
    const ecFileName& EC_ExpandEnvironmentStrings();
128
    static ecFileName EC_ExpandEnvironmentStrings(const wxChar* psz);
129
 
130
    // Form path name relative to given parameter (if NULL, current directory)
131
    const ecFileName& MakeRelative(const wxChar* pszRelativeTo=0);
132
    static ecFileName Relative(const wxChar* psz,const wxChar* pszRelativeTo=0);
133
 
134
    bool SameFile (const ecFileName &strOther) const;
135
 
136
    /* TODO
137
    bool SetFileAttributes (long dwFileAttributes) const;
138
 
139
      long Attributes() const { return ::GetFileAttributes(*this); }
140
    */
141
 
142
    bool Exists     () const ;
143
    bool IsDir      () const ;
144
    bool IsFile     () const ;
145
    bool IsReadOnly () const ;
146
 
147
    time_t LastModificationTime() const;
148
 
149
    bool RecursivelyDelete();
150
 
151
    bool EC_CreateDirectory (bool bParentsToo = TRUE, bool bFailIfAlreadyExists = FALSE) const;
152
 
153
    static int FindFiles (const wxString& pszDir,wxArrayString &ar,const wxString& pszPattern=wxT("*.*"),bool bRecurse=TRUE,long dwExclude=wxDIR_DIRS|wxDIR_HIDDEN);
154
 
155
protected:
156
 
157
   /* Don't appear to be necessary
158
    // Helpers for Relative():
159
    const wxChar* *Chop ();
160
    static ecFileName Drive(const wxChar* psz);
161
    */
162
 
163
    // Remove trailing '/' (helper for ctors)
164
    void Normalize();
165
 
166
    // Implementating catenation functionality:
167
    void ConcatInPlace(const wxString& src);
168
    void ConcatCopy(const wxString& src1, const wxString& src2);
169
};
170
 
171
class wxSaveExcursion {
172
    const ecFileName m_strPrevDir;
173
public:
174
    wxSaveExcursion(const wxChar* pszDir) : m_strPrevDir(ecFileName::EC_SetCurrentDirectory(pszDir)) {}
175
    ~wxSaveExcursion() { ecFileName::EC_SetCurrentDirectory(m_strPrevDir); }
176
    bool Ok() const { return !m_strPrevDir.IsEmpty(); }
177
};
178
 
179
#endif
180
// _ECOS_FILENAME_H_

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.