libmoldeo (Moldeo 1.0 Core)  1.0
libmoldeo is the group of objects and functions that executes the basic operations of Moldeo 1.0 Platform.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
moFileManager.h
Go to the documentation of this file.
1 /*******************************************************************************
2 
3  moFileManager.h
4 
5  ****************************************************************************
6  * *
7  * This source is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This code is distributed in the hope that it will be useful, but *
13  * WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
15  * General Public License for more details. *
16  * *
17  * A copy of the GNU General Public License is available on the World *
18  * Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
19  * obtain it by writing to the Free Software Foundation, *
20  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  * *
22  ****************************************************************************
23 
24  Copyright(C) 2006 Fabricio Costa
25 
26  Authors:
27  Fabricio Costa
28 
29 *******************************************************************************/
30 
31 #ifndef __MOFILEMANAGER_H
32 #define __MOFILEMANAGER_H
33 
34 #include "moTypes.h"
35 #include "moAbstract.h"
36 #include "moText.h"
37 #include "moResourceManager.h"
38 #include "moBuckets.h"
39 #include "moParam.h"
40 
41 
46 enum moFileType {
54 };
55 
56 typedef long moFileDate;
57 typedef long moFileSize;
58 
59 #ifdef MO_WIN32
60  #include "io.h"
61  #define moSlash moText("\\")
62  #define moThm moText("/.thm")
63  #define moSlashChar '\\'
64 #endif
65 
66 #ifdef MO_LINUX
67  #define moSlash moText("/")
68  #define moThm moText("/.thm")
69  #define moSlashChar '/'
70 #endif
71 
72 #ifdef MO_MACOSX
73  #define moSlash moText("/")
74  #define moThm moText("/.thm")
75  #define moSlashChar '/'
76 #endif
77 
78 
87 };
88 
94 
95  public:
96  moFile();
97  moFile( moText p_CompletePath );//could be: http://.... or ftp://... or c:\... or ...
98  virtual ~moFile();
99 
100  virtual MOboolean Init();
101  virtual MOboolean Finish();
102 
103  MOboolean Exists();
104 
105  moFileType GetType();
106  MOboolean IsRemote();
107  void SetType( moFileType p_filetype );
108  void SetCompletePath( moText p_completepath );
109 
110  moText GetFileName();
111  moText GetFullName();
112  moText GetPath();
113  moText GetFolderName();
114  moText GetCompletePath();
115  moText GetAbsolutePath();
116  moText GetExtension();
117  moText GetProtocol();
118 
119  moFileDate GetDate();
120  moFileSize GetSize();
121 
122  moFileStatus GetStatus();
123 
124  MOubyte* GetData();
125  void Update();
126 
127  private:
128 
129  moFileType m_FileType;
130  moFileStatus m_FileStatus;
131 
132  moFileDate m_FileDate;
133  moFileSize m_FileSize;
134 
135  moText m_CompletePath;
136  moText m_Drive;
137 
138  moText m_Path;
139  moText m_FileName;
140 
141  moText m_Extension;
142  moText m_Protocol;
143 
144  MOboolean m_bExists;
145  MOboolean m_bRemote;
146  //buckets...for downloading...
147  moBucketsPool *m_pBucketsPool;
148  //
149  MOubyte *m_pData;
150 
151  moTextArray m_Dirs;
152 
153 };
154 
155 moDeclareExportedDynamicArray( moFile*, moFileArray );
156 
160 class moDirectory;
161 
162 moDeclareExportedDynamicArray( moDirectory*, moDirectoryArray );
163 
165 
166  public:
167  moDirectory();
168  moDirectory( moText p_CompletePath, moFileManager* p_pFileManager = NULL );//could be: http://.... or ftp://... or c:\... or ...
169  virtual ~moDirectory();
170 
171  virtual MOboolean Init();
172  virtual MOboolean Init( moFileManager *p_FileManager );
173  virtual MOboolean Finish();
174 
175  MOboolean Open( moText p_CompletePath, moText p_Search = "/*.*" );
176 
177  MOboolean Exists();
178  MOboolean IsRemote();
179  MOboolean HasSubdirs();
180  void SetType( moFileType p_filetype );
181  void SetCompletePath( moText p_completepath );
182 
183  moFileType GetType();
184  moFileStatus GetStatus();
185  moText GetCompletePath();
186  moText GetDirName();
187  moText GetProtocol();
188 
189  moFile* FindFirst( );
190  moFile* FindNext( );
191  moFile* FindLast( );
192  moFile* Find( MOint index );
193  moFile* Find( moText filename);
194 
195  void Update();
196 
197  moFileArray& GetFiles();
198  moDirectoryArray& GetSubDirs();
199 
200  protected:
201 
205 
207  moTextArray m_DirNameArray;
210 
213 
215 
216  moFileArray m_Files;
217  moDirectoryArray m_SubDirs;
218 };
219 
220 typedef moDirectoryArray moDirectories;
221 
223 
227 #undef CopyFile
228 #undef CreateDirectory
229 
231 {
232  public:
233 
234  moFileManager();
235  virtual ~moFileManager();
236 
237  virtual MOboolean Init();
238  virtual MOboolean Finish();
239 
240 
241  MOboolean Load( moText p_FileName, MOboolean bWaitForDownload = false );
242  moFile* GetFile( moText p_FileName );
243 
244  MOboolean Open ( moText p_Path, MOboolean bWaitForDownload = false );
245  moDirectory* GetDirectory( moText p_Path );
246 
247  static bool CreateDirectory( moDirectory Dir );
248  static bool CopyFile( moText FileSrc, moText FileDst );
249  static bool CopyDirectory( const moText& DirSrc, const moText& DirDst );
250 
251  static moText GetExePath();
252  static moText GetWorkPath();
253  static bool FileExists( moText filename );
254  static bool DirectoryExists( moText dirname );
255 
256  protected:
257 
258  moFileArray m_Files;
259  moDirectoryArray m_Directories;
260 
261 };
262 
263 #endif
264 
Manejador de archivos.
moText m_Protocol
Recurso ( objeto para cargar y manipular objetos físicos de datos de imágenes, audio, video, 3d, 2d, fuentes, shaders y de cualquier otro tipo extendible por un plugin )
virtual MOboolean Finish()
Finaliza el objeto, libera recursos.
Definition: moAbstract.cpp:147
long moFileDate
Definition: moFileManager.h:56
#define MOboolean
Definition: moTypes.h:385
MOboolean m_bExists
MOboolean m_bRemote
moFileStatus m_DirStatus
moDeclareExportedDynamicArray(moFile *, moFileArray)
Clase base abstracta de donde deben derivar los objetos [virtual pura].
Definition: moAbstract.h:191
virtual MOboolean Init()
Inicializa el objeto.
Definition: moAbstract.cpp:141
moFileArray m_Files
#define LIBMOLDEO_API
Definition: moTypes.h:180
virtual MOboolean Init()
MOint m_FileIndex
clase de para manejar textos
Definition: moText.h:75
long moFileSize
Definition: moFileManager.h:57
moText m_CompletePath
#define MOint
Definition: moTypes.h:388
moFileManager * m_pFileManager
Administrador de moBucket 's.
Definition: moBuckets.h:152
moFileArray m_Files
moDirectoryArray m_Directories
moTextArray m_DirNameArray
virtual MOboolean Finish()
moDirectoryArray moDirectories
moText m_DirName
moFileStatus
Definition: moFileManager.h:82
moFileType m_DirType
#define MOubyte
Definition: moTypes.h:399
moFileType
Definition: moFileManager.h:46
moDirectoryArray m_SubDirs