00001
00002
00003
00004
00005
00006
00007
00021 #ifndef OSCL_FILE_IO_H_INCLUDED
00022 #define OSCL_FILE_IO_H_INCLUDED
00023
00024 #ifndef OSCLCONFIG_IO_H_INCLUDED
00025 #include "osclconfig_io.h"
00026 #endif
00027
00028 #ifndef OSCL_BASE_H_INCLUDED
00029 #include "oscl_base.h"
00030 #endif
00031
00032 #ifndef OSCL_MEM_H_INCLUDED
00033 #include "oscl_mem.h"
00034 #endif
00035
00043 class PVLogger;
00044 class OsclFileCache;
00045 class Oscl_FileServer;
00046 class OsclFileHandle;
00047 class OsclNativeFile;
00048 class OsclFileStats;
00049 class OsclNativeFileParams;
00050 class OsclAsyncFile;
00051 #define TOsclFileOffsetInt32 int32
00052
00053 class Oscl_File : public HeapBase
00054 {
00055 public:
00056
00057 typedef enum
00058 {
00062 SEEKSET,
00066 SEEKCUR,
00070 SEEKEND
00071 } seek_type;
00072
00073 typedef enum
00074 {
00078 MODE_READ = 0x0001,
00084 MODE_READWRITE = 0x0002,
00091 MODE_APPEND = 0x0004,
00095 MODE_BINARY = 0x0008,
00099 MODE_TEXT = 0x0010,
00104 MODE_READ_PLUS = 0x0020
00105
00106 } mode_type;
00107
00111 OSCL_IMPORT_REF Oscl_File();
00112
00118 OSCL_IMPORT_REF Oscl_File(uint32 aCacheSize);
00125 OSCL_IMPORT_REF Oscl_File(uint32 aCacheSize, OsclFileHandle* aFileHandle);
00126
00130 OSCL_IMPORT_REF ~Oscl_File();
00131
00141 OSCL_IMPORT_REF void SetPVCacheSize(uint32 aSize);
00142
00153 OSCL_IMPORT_REF void SetNativeAccessMode(uint32 aMode);
00154
00158 enum TSymbianAccessMode
00159 {
00160 ESymbianAccessMode_Rfile = 0
00161 , ESymbianAccessMode_RfileBuf = 1
00162 };
00163
00178 OSCL_IMPORT_REF void SetNativeBufferSize(int32 aSize);
00179
00193 OSCL_IMPORT_REF void SetAsyncReadBufferSize(uint32 aSize);
00194
00217 OSCL_IMPORT_REF int32 SetFileHandle(OsclFileHandle* aHandle);
00218
00232 OSCL_IMPORT_REF int32 Open(const char *filename, uint32 mode, Oscl_FileServer& fileserv);
00233
00246 OSCL_IMPORT_REF int32 Open(const oscl_wchar *filename, uint32 mode, Oscl_FileServer& fileserv);
00247
00264 OSCL_IMPORT_REF uint32 Read(OsclAny *buffer,
00265 uint32 size,
00266 uint32 numelements);
00267
00279 OSCL_IMPORT_REF uint32 Write(const OsclAny *buffer,
00280 uint32 size,
00281 uint32 numelements);
00282
00283
00293 OSCL_IMPORT_REF int32 Seek(TOsclFileOffset offset,
00294 seek_type origin);
00295
00300 OSCL_IMPORT_REF TOsclFileOffset Tell();
00301
00302
00313 OSCL_IMPORT_REF int32 Close();
00314
00315
00323 OSCL_IMPORT_REF int32 Flush();
00324
00325
00333 OSCL_IMPORT_REF int32 EndOfFile();
00334
00335
00343 OSCL_IMPORT_REF int32 GetError();
00344
00350 OsclFileHandle* Handle()
00351 {
00352 return iOpenFileHandle;
00353 }
00354
00360 OSCL_IMPORT_REF TOsclFileOffset Size();
00361
00370 OSCL_IMPORT_REF void SetLoggingEnable(bool aEnable);
00371
00379 OSCL_IMPORT_REF void SetSummaryStatsLoggingEnable(bool aEnable);
00380
00381
00382 private:
00383 friend class OsclFileCache;
00384 friend class asyncfilereadwrite_test;
00385 friend class largeasyncfilereadwrite_test;
00386 friend class asyncfilereadcancel_test;
00387
00388 void Construct();
00389 void OldCacheDefaults();
00390 void OldCacheSelect(uint32);
00391
00392
00393 bool iIsOpen;
00394
00395
00396 PVLogger* iLogger;
00397 PVLogger* iStatsLogger;
00398 PVLogger* iNativeLogger;
00399 PVLogger* iAsyncLogger;
00400 OsclFileStats* iFileStats;
00401 void CreateFileStats();
00402
00403
00404 OsclFileHandle* iOpenFileHandle;
00405
00406
00407 uint32 iPVCacheSize;
00408 OsclFileCache* iFileCache;
00409
00410 int32 OpenFileCacheOrAsyncBuffer(const char *filename
00411 , const oscl_wchar* wfilename
00412 , uint32 mode
00413 , const OsclNativeFileParams& params
00414 , Oscl_FileServer& fileserv) ;
00415
00416
00417 OsclNativeFile* iNativeFile;
00418 int32 iNativeBufferSize;
00419 uint32 iNativeAccessMode;
00420
00421
00422 uint32 iAsyncReadBufferSize;
00423 OsclAsyncFile* iAsyncFile;
00424
00425
00426
00427
00428 int32 CallNativeOpen(const OsclFileHandle&, uint32 mode
00429 , const OsclNativeFileParams& params
00430 , Oscl_FileServer& fileserv);
00431 int32 CallNativeOpen(const oscl_wchar *filename, uint32 mode
00432 , const OsclNativeFileParams& params
00433 , Oscl_FileServer& fileserv);
00434 int32 CallNativeOpen(const char *filename, uint32 mode
00435 , const OsclNativeFileParams& params
00436 , Oscl_FileServer& fileserv);
00437 uint32 CallNativeRead(OsclAny *buffer, uint32 size, uint32 numelements);
00438 uint32 CallNativeWrite(const OsclAny *buffer, uint32 size, uint32 numelements);
00439 int32 CallNativeSeek(TOsclFileOffset offset, Oscl_File::seek_type origin);
00440 TOsclFileOffset CallNativeTell();
00441 int32 CallNativeFlush();
00442 int32 CallNativeEndOfFile();
00443 TOsclFileOffset CallNativeSize();
00444 int32 CallNativeClose();
00445 uint32 CallNativeMode();
00446 int32 CallNativeGetError();
00447 OSCL_IMPORT_REF uint32 GetAsyncFileNumOfRun();
00448 OSCL_IMPORT_REF uint32 GetAsyncFileNumOfRunError();
00449
00450 };
00451
00452
00453
00454 #include "oscl_file_server.h"
00455 #include "oscl_file_find.h"
00456 #include "oscl_file_dir_utils.h"
00457 #include "oscl_file_handle.h"
00458
00459 #endif // OSCL_FILE_IO_H_INCLUDED
00460