| ## Public API Reference

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

- 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
    00031 struct iConfigFile;
    00032
    00033 class csStringArray;
    00034
    00039 struct csFileTime
    00040 {
    00042   int sec;
    00044   int min;
    00046   int hour;
    00048   int day;
    00050   int mon;
    00052   int year;
    00053 };
    00054
    00056 #define ASSIGN_FILETIME(ft,tm)  \
    00057   (ft).sec = (tm).tm_sec;       \
    00058   (ft).min = (tm).tm_min;       \
    00059   (ft).hour = (tm).tm_hour;     \
    00060   (ft).day = (tm).tm_mday;      \
    00061   (ft).mon = (tm).tm_mon;       \
    00062   (ft).year = (tm).tm_year + 1900;
    00063
    00065 #define VFS_PATH_DIVIDER        ','
    00067 #define VFS_PATH_SEPARATOR      '/'
    00069 #define VFS_MAX_PATH_LEN        256
    00070
    00073
    00074 #define VFS_FILE_MODE           0x0000000f
    00076 #define VFS_FILE_READ           0x00000000
    00078 #define VFS_FILE_WRITE          0x00000001
    00080 #define VFS_FILE_APPEND         0x00000002
    00082 #define VFS_FILE_UNCOMPRESSED   0x80000000
    00083
    00087
    00088 #define VFS_STATUS_OK           0
    00090 #define VFS_STATUS_OTHER        1
    00092 #define VFS_STATUS_NOSPACE      2
    00094 #define VFS_STATUS_RESOURCES    3
    00095
    00099 #define VFS_STATUS_ACCESSDENIED 4
    00101 #define VFS_STATUS_IOERROR      5
    00102
    00110 struct iFile : public virtual iBase
    00111 {
    00112   SCF_INTERFACE(iFile, 2, 0, 0);
    00113
    00115   virtual const char *GetName () = 0;
    00116
    00118   virtual size_t GetSize () = 0;
    00119
    00124   virtual int GetStatus () = 0;
    00125
    00134   virtual size_t Read (char *Data, size_t DataSize) = 0;
    00135
    00143   virtual size_t Write (const char *Data, size_t DataSize) = 0;
    00144
    00146   virtual void Flush () = 0;
    00147
    00149   virtual bool AtEOF () = 0;
    00150
    00152   virtual size_t GetPos () = 0;
    00153
    00159   virtual bool SetPos (size_t newpos) = 0;
    00160
    00172   virtual csPtr<iDataBuffer> GetAllData (bool nullterm = false) = 0;
    00173 };
    00174
    00175
    00205 struct iVFS : public virtual iBase
    00206 {
    00207   SCF_INTERFACE(iVFS, 2, 0, 0);
    00208
    00210   virtual bool ChDir (const char *Path) = 0;
    00211
    00213   virtual const char *GetCwd () const = 0;
    00214
    00224   virtual void PushDir (char const* Path = 0) = 0;
    00232   virtual bool PopDir () = 0;
    00233
    00241   virtual csPtr<iDataBuffer> ExpandPath (
    00242     const char *Path, bool IsDir = false) const = 0;
    00243
    00245   virtual bool Exists (const char *Path) const = 0;
    00246
    00251   virtual csPtr<iStringArray> FindFiles (const char *Path) const = 0;
    00252
    00261   virtual csPtr<iFile> Open (const char *FileName, int Mode) = 0;
    00262
    00277   virtual csPtr<iDataBuffer> ReadFile (const char *FileName,
    00278     bool nullterm = true) = 0;
    00279
    00287   virtual bool WriteFile (const char *Name, const char *Data, size_t Size) = 0;
    00288
    00293   virtual bool DeleteFile (const char *FileName) = 0;
    00294
    00299   virtual bool Sync () = 0;
    00300
    00310   virtual bool Mount (const char *VirtualPath, const char *RealPath) = 0;
    00311
    00326   virtual bool Unmount (const char *VirtualPath, const char *RealPath) = 0;
    00327
    00338   virtual csRef<iStringArray> MountRoot (const char *VirtualPath) = 0;
    00339
    00344   virtual bool SaveMounts (const char *FileName) = 0;
    00349   virtual bool LoadMountsFromFile (iConfigFile* file) = 0;
    00350
    00377   virtual bool ChDirAuto (const char* path, const csStringArray* paths = 0,
    00378         const char* vfspath = 0, const char* filename = 0) = 0;
    00379
    00384   virtual bool GetFileTime (const char *FileName, csFileTime &oTime) const = 0;
    00389   virtual bool SetFileTime (const char *FileName, const csFileTime &iTime) = 0;
    00390
    00395   virtual bool GetFileSize (const char *FileName, size_t &oSize) = 0;
    00396
    00409   virtual csPtr<iDataBuffer> GetRealPath (const char *FileName) = 0;
    00410
    00415   virtual csRef<iStringArray> GetMounts () = 0;
    00416
    00424   virtual csRef<iStringArray> GetRealMountPaths (const char *VirtualPath) = 0;
    00425 };
    00426
    00429 #endif // __CS_IUTIL_VFS_H__