00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef OSDL_EMBEDDED_FILE_H_
00028 #define OSDL_EMBEDDED_FILE_H_
00029
00030
00031
00032 #include "Ceylan.h"
00033
00034
00035
00036 #if ! defined(OSDL_USES_PHYSICSFS) || OSDL_USES_PHYSICSFS
00037
00038
00039 struct PHYSFS_File ;
00040
00041 #endif // ! defined(OSDL_USES_PHYSICSFS) || OSDL_USES_PHYSICSFS
00042
00043
00044
00045
00046 namespace OSDL
00047 {
00048
00049
00050
00052 class OSDL_DLL EmbeddedFileException: public Ceylan::System::FileException
00053 {
00054
00055 public:
00056
00057 explicit EmbeddedFileException( const std::string & reason ) ;
00058
00059 virtual ~EmbeddedFileException() throw() ;
00060
00061 } ;
00062
00063
00064
00065
00081 class OSDL_DLL EmbeddedFile: public Ceylan::System::File
00082 {
00083
00084
00085 public:
00086
00087
00088
00100 virtual ~EmbeddedFile() throw() ;
00101
00102
00103
00104
00105
00106
00107
00108
00113 virtual bool isOpen() const ;
00114
00115
00116
00130 virtual bool close() ;
00131
00132
00133
00144 virtual void saveAs( const std::string & newName ) ;
00145
00146
00147
00148
00149
00150
00151
00152
00160 virtual void lockForReading() const ;
00161
00162
00163
00171 virtual void unlockForReading() const ;
00172
00173
00174
00182 virtual void lockForWriting() const ;
00183
00184
00185
00193 virtual void unlockForWriting() const ;
00194
00195
00196
00205 virtual bool isLocked() const ;
00206
00207
00208
00209
00210
00211
00212
00220 virtual time_t getLastChangeTime() const ;
00221
00222
00223
00245 virtual Ceylan::System::Size read( Ceylan::Byte * buffer,
00246 Ceylan::System::Size maxLength ) ;
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00273 virtual Ceylan::System::Size write( const std::string & message ) ;
00274
00275
00276
00295 virtual Ceylan::System::Size write( const Ceylan::Byte * buffer,
00296 Ceylan::System::Size maxLength ) ;
00297
00298
00299
00308 virtual Ceylan::System::Position tell() ;
00309
00310
00311
00321 virtual void seek( Ceylan::System::Position targetPosition ) ;
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00345 virtual Ceylan::System::Size size() const ;
00346
00347
00348
00357 virtual void serialize( PHYSFS_File & handle ) ;
00358
00359
00360
00368 PHYSFS_File & getPhysicsFSHandle() const ;
00369
00370
00371
00385 static void CypherBuffer( Ceylan::Byte * buffer,
00386 Ceylan::System::Size size ) ;
00387
00388
00389
00403 static void DecypherBuffer( Ceylan::Byte * buffer,
00404 Ceylan::System::Size size ) ;
00405
00406
00407
00408
00409
00410
00411
00412
00420 virtual Ceylan::System::StreamID getStreamID() const ;
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00443 virtual const std::string toString(
00444 Ceylan::VerbosityLevels level = Ceylan::high ) const ;
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00485 static EmbeddedFile & Create( const std::string & filename,
00486 Ceylan::System::OpeningFlag createFlag
00487 = Ceylan::System::File::CreateToWriteBinary,
00488 Ceylan::System::PermissionFlag permissionFlag
00489 = Ceylan::System::File::OwnerReadWrite ) ;
00490
00491
00492
00531 static EmbeddedFile & Open( const std::string & filename,
00532 Ceylan::System::OpeningFlag openFlag
00533 = Ceylan::System::File::OpenToReadBinary ) ;
00534
00535
00536
00537
00538 protected:
00539
00540
00541
00574 explicit EmbeddedFile( const std::string & name,
00575 Ceylan::System::OpeningFlag openFlag
00576 = Ceylan::System::File::CreateToWriteBinary,
00577 Ceylan::System::PermissionFlag permissionFlag
00578 = Ceylan::System::File::OwnerReadWrite ) ;
00579
00580
00581
00582
00583
00584
00585
00586
00587
00594 virtual Ceylan::System::FileSystemManager &
00595 getCorrespondingFileSystemManager() const ;
00596
00597
00598
00605 virtual void reopen() ;
00606
00607
00608
00613 virtual std::string interpretState() const ;
00614
00615
00616
00617
00618 private:
00619
00620
00621
00626 PHYSFS_File * _physfsHandle ;
00627
00628
00634 bool _cypher ;
00635
00636
00637
00646 EmbeddedFile( const EmbeddedFile & source ) ;
00647
00648
00649
00658 EmbeddedFile & operator = ( const EmbeddedFile & source ) ;
00659
00660
00661
00676 static void FromHandletoHandle( PHYSFS_File & from,
00677 PHYSFS_File & to, Ceylan::System::Size length ) ;
00678
00679
00680 } ;
00681
00682
00683 }
00684
00685
00686
00687 #endif // OSDL_EMBEDDED_FILE_H_
00688