Main Page Modules Class Hierarchy Data Structures File List Data Fields Globals Related Pages

# oscl_file_native.h

Go to the documentation of this file.

    00001 // -*- c++ -*-
    00002 // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
    00003
    00004 //                     O S C L _ F I L E  _ N A T I V E
    00005
    00006 // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
    00007
    00019 #ifndef OSCL_FILE_NATIVE_H_INCLUDED
    00020 #define OSCL_FILE_NATIVE_H_INCLUDED
    00021
    00022 #ifndef OSCLCONFIG_IO_H_INCLUDED
    00023 #include "osclconfig_io.h"
    00024 #endif
    00025
    00026 #ifndef OSCL_BASE_H_INCLUDED
    00027 #include "oscl_base.h"
    00028 #endif
    00029
    00030 #ifndef OSCL_AOSTATUS_H_INCLUDED
    00031 #include "oscl_aostatus.h"
    00032 #endif
    00033
    00034 #ifndef OSCL_FILE_IO_H_INCLUDED
    00035 #include "oscl_file_io.h"
    00036 #endif
    00037
    00038 #ifndef OSCL_FILE_TYPES_H_INCLUDED
    00039 #include "oscl_file_types.h"
    00040 #endif
    00041
    00042
    00048 class Oscl_FileServer;
    00049 class OsclNativeFile : public HeapBase
    00050 {
    00051     public:
    00052         OsclNativeFile();
    00053         ~OsclNativeFile();
    00054
    00055         // These are the Native OS File IO calls.
    00056         int32  Open(const OsclFileHandle&, uint32 mode
    00057                     , const OsclNativeFileParams& params
    00058                     , Oscl_FileServer& fileserv);
    00059         int32  Open(const oscl_wchar *filename, uint32 mode
    00060                     , const OsclNativeFileParams& params
    00061                     , Oscl_FileServer& fileserv);
    00062         int32  Open(const char *filename, uint32 mode
    00063                     , const OsclNativeFileParams& params
    00064                     , Oscl_FileServer& fileserv);
    00065         uint32 Read(OsclAny *buffer, uint32 size, uint32 numelements);
    00066         uint32 Write(const OsclAny *buffer, uint32 size, uint32 numelements);
    00067         int32 Seek(TOsclFileOffset offset, Oscl_File::seek_type origin);
    00068         TOsclFileOffset  Tell();
    00069         int32  Flush();
    00070         int32  EndOfFile();
    00071         TOsclFileOffset Size();
    00072         int32 Close();
    00073         int32 SetSize(uint32 size);
    00074
    00075         //query for current open mode.
    00076         uint32 Mode()
    00077         {
    00078             return iMode;
    00079         }
    00080
    00081         //get last filesystem error.
    00082         int32 GetError();
    00083
    00093         int32 ReadAsync(OsclAny*buffer, uint32 size, uint32 numelements, OsclAOStatus& status);
    00098         uint32 GetReadAsyncNumElements();
    00102         bool HasAsyncRead();
    00106         void ReadAsyncCancel();
    00107
    00108     private:
    00109
    00110 #ifdef ANDROID
    00111         int32 FindLargeFileOpenMode(uint32 mode);
    00112 #endif
    00113
    00114         //current open mode
    00115         uint32 iMode;
    00116
    00117         //was an open file handle passed in?
    00118         bool iOpenFileHandle;
    00119
    00120         //native file object.
    00121         FILE* iFile;
    00122 #ifdef ANDROID
    00123         pthread_mutex_t* iAssethandle_mutex;
    00124 #endif
    00125
    00126         //These are used for accessing individual assets that are bundled together
    00127         //into a single file, where each asset is treated as an independent file.
    00128         bool            iIsAsset;
    00129         bool            iIsAssetReadOnly;
    00130         TOsclFileOffset iAssetOffset;
    00131         TOsclFileOffset iAssetSize;
    00132         TOsclFileOffset iAssetLogicalFilePos;
    00133 #ifdef ANDROID
    00134         int32           iFileDescriptor;
    00135 #endif
    00136 };
    00137
    00138 #endif // OSCL_FILE_NATIVE_H_INCLUDED
    00139