MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
filename.h
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/libraries/libmbutil/filename.h,v 1.21 2017/01/12 14:44:04 masarati Exp $ */
2 /*
3  * This library comes with MBDyn (C), a multibody analysis code.
4  * http://www.mbdyn.org
5  *
6  * Copyright (C) 1996-2017
7  *
8  * Pierangelo Masarati <masarati@aero.polimi.it>
9  *
10  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
11  * via La Masa, 34 - 20156 Milano, Italy
12  * http://www.aero.polimi.it
13  *
14  * Changing this copyright notice is forbidden.
15  *
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation (version 2 of the License).
19  *
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program; if not, write to the Free Software
28  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29  */
30 
31 /* Classe che consente la manipolazione dei nomi di files
32  * e delle estensioni.
33  * Uso consigliato:
34  * derivare una classe da questa, aggiungendo funzioni
35  * che generino direttamente i nomi del file con l'estensione desiderata
36  * Ad esempio:
37 
38 
39  class MyFile : public FileName {
40  public:
41  MyFile(char* sFName) : FileName(sFName) {
42  NULL
43  };
44 
45  char* sOldFile(void) {
46  return _sPutExt(NULL);
47  };
48 
49  char* sDatFile(void) {
50  return _sPutExt(".dat");
51  };
52  };
53 
54 */
55 
56 #ifndef FILENAME_H
57 #define FILENAME_H
58 
59 #include <cstdlib>
60 #include <cstring>
61 
62 
63 const char EXT_SEP = '.';
64 
65 #if 0
66 
67 const char DIR_SEP = '\\';
68 
69 class FileName {
70  protected:
71  mutable char* sName;
72  char sExt[4];
73  mutable char* sRef;
74 
75  public:
76  FileName(char* n = NULL); // Acquisisce e seziona il nome del file
77  virtual ~FileName(void); // Dealloca le stringhe usate
78  int iInit(char* n); // Acquisisce e seziona il nome del file
79  const char *const _sPutExt(char* n = NULL); // Aggiunge una nuova estensione (di default attacca la vecchia)
80  const char *const sGet(void) const; // Restituisce il nome del file con la vecchia estensione
81 };
82 
83 #endif
84 
85 #ifdef _WIN32
86 const char DIR_SEP = '\\';
87 #else // ! _WIN32
88 const char DIR_SEP = '/';
89 #endif // ! _WIN32
90 
91 class FileName {
92  private:
93  mutable char* sName;
94  mutable char* sExt;
95  mutable char* sRef;
96  mutable unsigned int iMaxSize;
97  mutable unsigned int iCurSize;
98 
99  public:
100  FileName(const char* n = NULL, int i = 0);
101  virtual ~FileName(void);
102  int iInit(const char* n, int i = 0);
103  const char *const _sPutExt(const char* n);
104  const char *const sGet(void) const;
105 };
106 
107 extern int is_abs_path(const char *const p);
108 
109 #endif // FILENAME_H
110 
char * sRef
Definition: filename.h:95
char * sExt
Definition: filename.h:94
const char *const _sPutExt(const char *n)
Definition: fn_UNIX.cc:161
int is_abs_path(const char *const p)
Definition: fn_UNIX.cc:206
FileName(const char *n=NULL, int i=0)
Definition: fn_UNIX.cc:41
const char *const sGet(void) const
Definition: fn_UNIX.cc:200
char * sName
Definition: filename.h:93
unsigned int iCurSize
Definition: filename.h:97
const char DIR_SEP
Definition: filename.h:88
const char EXT_SEP
Definition: filename.h:63
unsigned int iMaxSize
Definition: filename.h:96
virtual ~FileName(void)
Definition: fn_UNIX.cc:49
int iInit(const char *n, int i=0)
Definition: fn_UNIX.cc:63