iutil/vfs.h Source File (Crystal Space 2.0 Public API Reference)

| ## Public API Reference

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

iutil/vfs.h
Go to the documentation of this file.

    00001 /*
    00002     Crystal Space Virtual File System SCF interface
    00003     Copyright (C) 1998,1999 by Andrew Zabolotny <bit@eltech.ru>
    00004
    00005     This library is free software; you can redistribute it and/or
    00006     modify it under the terms of the GNU Library General Public
    00007     License as published by the Free Software Foundation; either
    00008     version 2 of the License, or (at your option) any later version.
    00009
    00010     This library is distributed in the hope that it will be useful,
    00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013     Library General Public License for more details.
    00014
    00015     You should have received a copy of the GNU Library General Public
    00016     License along with this library; if not, write to the Free
    00017     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    00018 */
    00019
    00020 #ifndef __CS_IUTIL_VFS_H__
    00021 #define __CS_IUTIL_VFS_H__
    00022
    00028 #include "csutil/scf.h"
    00029 #include "iutil/databuff.h"
    00030 #include <time.h>
    00031
    00032 namespace CS
    00033 {
    00034   namespace Memory
    00035   {
    00036     struct iAllocator;
    00037   } // namespace Memory
    00038 } // namespace CS
    00039 struct iConfigFile;
    00040
    00041 class csStringArray;
    00042
    00047 struct csFileTime
    00048 {
    00050   int sec;
    00052   int min;
    00054   int hour;
    00056   int day;
    00058   int mon;
    00060   int year;
    00061
    00063   csFileTime() {}
    00064
    00066   csFileTime(const struct tm& time)
    00067   {
    00068       *this = time;
    00069   }
    00070
    00072   void operator=(const struct tm& time)
    00073   {
    00074     sec  = time.tm_sec;
    00075     min  = time.tm_sec;
    00076     hour = time.tm_hour;
    00077     day  = time.tm_mday;
    00078     mon  = time.tm_mon;
    00079     year = time.tm_year + 1900;
    00080   }
    00081
    00083   operator struct tm() const
    00084   {
    00085     struct tm time;
    00086     time.tm_sec = sec;
    00087     time.tm_min = min;
    00088     time.tm_hour = hour;
    00089     time.tm_mday = day;
    00090     time.tm_mon = mon;
    00091     time.tm_year = year - 1900;
    00092     return time;
    00093   }
    00094 };
    00095
    00096 namespace CS
    00097 {
    00098   namespace Deprecated
    00099   {
    00100     CS_DEPRECATED_METHOD_MSG("Use assign operator of csFileTime.")
    00101     static inline void ASSIGN_FILETIME (csFileTime &ft, const struct tm &time)
    00102     {
    00103       ft = time;
    00104     }
    00105   }
    00106 }
    00110 #define ASSIGN_FILETIME(ft,tm)  \
    00111   CS::Deprecated::ASSIGN_FILETIME(ft, tm);
    00112
    00114 #define VFS_PATH_DIVIDER        ','
    00115
    00116 #define VFS_PATH_SEPARATOR      '/'
    00117
    00118 #define VFS_MAX_PATH_LEN        256
    00119
    00122
    00123 #define VFS_FILE_MODE           0x0000000f
    00124
    00125 #define VFS_FILE_READ           0x00000000
    00126
    00127 #define VFS_FILE_WRITE          0x00000001
    00128
    00129 #define VFS_FILE_APPEND         0x00000002
    00130
    00131 #define VFS_FILE_UNCOMPRESSED   0x80000000
    00132
    00136
    00137 #define VFS_STATUS_OK           0
    00138
    00139 #define VFS_STATUS_OTHER        1
    00140
    00141 #define VFS_STATUS_NOSPACE      2
    00142
    00143 #define VFS_STATUS_RESOURCES    3
    00144
    00148 #define VFS_STATUS_ACCESSDENIED 4
    00149
    00150 #define VFS_STATUS_IOERROR      5
    00151
    00159 struct iFile : public virtual iBase
    00160 {
    00161   SCF_INTERFACE(iFile, 2, 2, 0);
    00162
    00164   virtual const char *GetName () = 0;
    00165
    00167   virtual size_t GetSize () = 0;
    00168
    00173   virtual int GetStatus () = 0;
    00174
    00183   virtual size_t Read (char *Data, size_t DataSize) = 0;
    00184
    00192   virtual size_t Write (const char *Data, size_t DataSize) = 0;
    00193
    00195   virtual void Flush () = 0;
    00196
    00198   virtual bool AtEOF () = 0;
    00199
    00201   virtual size_t GetPos () = 0;
    00202
    00208   virtual bool SetPos (size_t newpos) = 0;
    00209
    00221   virtual csPtr<iDataBuffer> GetAllData (bool nullterm = false) = 0;
    00222
    00231   virtual csPtr<iDataBuffer> GetAllData (CS::Memory::iAllocator* allocator) = 0;
    00232
    00241   virtual csPtr<iFile> GetPartialView (size_t offset, size_t size = (size_t)~0) = 0;
    00242 };
    00243
    00244
    00274 struct iVFS : public virtual iBase
    00275 {
    00276   SCF_INTERFACE(iVFS, 3, 1, 0);
    00277
    00279   virtual bool ChDir (const char *Path) = 0;
    00280
    00282   virtual const char *GetCwd () = 0;
    00283
    00293   virtual void PushDir (char const* Path = 0) = 0;
    00301   virtual bool PopDir () = 0;
    00302
    00310   virtual csPtr<iDataBuffer> ExpandPath (
    00311     const char *Path, bool IsDir = false) = 0;
    00312
    00314   virtual bool Exists (const char *Path) = 0;
    00315
    00320   virtual csPtr<iStringArray> FindFiles (const char *Path) = 0;
    00321
    00330   virtual csPtr<iFile> Open (const char *FileName, int Mode) = 0;
    00331
    00346   virtual csPtr<iDataBuffer> ReadFile (const char *FileName,
    00347     bool nullterm = true) = 0;
    00348
    00356   virtual bool WriteFile (const char *Name, const char *Data, size_t Size) = 0;
    00357
    00362   virtual bool DeleteFile (const char *FileName) = 0;
    00363
    00368   virtual bool Sync () = 0;
    00369
    00382   virtual bool SymbolicLink(const char *Target, const char *Link = 0,
    00383     int priority = 0) = 0;
    00384
    00394   virtual bool Mount (const char *VirtualPath, const char *RealPath) = 0;
    00395
    00410   virtual bool Unmount (const char *VirtualPath, const char *RealPath) = 0;
    00411
    00422   virtual csRef<iStringArray> MountRoot (const char *VirtualPath) = 0;
    00423
    00428   virtual bool SaveMounts (const char *FileName) = 0;
    00433   virtual bool LoadMountsFromFile (iConfigFile* file) = 0;
    00434
    00461   virtual bool ChDirAuto (const char* path, const csStringArray* paths = 0,
    00462         const char* vfspath = 0, const char* filename = 0) = 0;
    00463
    00468   virtual bool GetFileTime (const char *FileName, csFileTime &oTime) = 0;
    00473   virtual bool SetFileTime (const char *FileName, const csFileTime &iTime) = 0;
    00474
    00479   virtual bool GetFileSize (const char *FileName, size_t &oSize) = 0;
    00480
    00493   virtual csPtr<iDataBuffer> GetRealPath (const char *FileName) = 0;
    00494
    00499   virtual csRef<iStringArray> GetMounts () = 0;
    00500
    00508   virtual csRef<iStringArray> GetRealMountPaths (const char *VirtualPath) = 0;
    00509 };
    00510
    00513 #endif // __CS_IUTIL_VFS_H__