[97] | 1 | /* |
---|
| 2 | This is part of the OTF library. Copyright by ZIH, TU Dresden 2005-2008. |
---|
| 3 | Authors: Andreas Knuepfer, Holger Brunst, Ronny Brendel, Thomas Kriebitzsch |
---|
| 4 | */ |
---|
| 5 | |
---|
| 6 | /** |
---|
| 7 | * @file OTF_File.h |
---|
| 8 | * |
---|
| 9 | * @brief Provides a low-level API for accessing files. |
---|
| 10 | * |
---|
| 11 | * \ingroup internal |
---|
| 12 | */ |
---|
| 13 | |
---|
| 14 | |
---|
| 15 | #ifndef OTF_FILE_H |
---|
| 16 | #define OTF_FILE_H |
---|
| 17 | |
---|
| 18 | |
---|
| 19 | #include "OTF_FileManager.h" |
---|
| 20 | #include "OTF_Filenames.h" |
---|
| 21 | |
---|
| 22 | |
---|
| 23 | #ifdef __cplusplus |
---|
| 24 | extern "C" { |
---|
| 25 | #endif /* __cplusplus */ |
---|
| 26 | |
---|
| 27 | /** mode determining what to do with a file */ |
---|
| 28 | enum enum_OTF_FileMode { |
---|
| 29 | |
---|
| 30 | OTF_FILEMODE_NOTHING = 0, |
---|
| 31 | OTF_FILEMODE_READ= 1, |
---|
| 32 | OTF_FILEMODE_WRITE= 2, |
---|
| 33 | OTF_FILEMODE_SEEK= 3 |
---|
| 34 | }; |
---|
| 35 | typedef enum enum_OTF_FileMode OTF_FileMode; |
---|
| 36 | |
---|
| 37 | /** status of a file */ |
---|
| 38 | enum enum_OTF_FileStatus { |
---|
| 39 | |
---|
| 40 | OTF_FILESTATUS_ACTIVE= 1, |
---|
| 41 | OTF_FILESTATUS_SUSPENDED= 2, |
---|
| 42 | OTF_FILESTATUS_CLOSED= 3 |
---|
| 43 | }; |
---|
| 44 | typedef enum enum_OTF_FileStatus OTF_FileStatus; |
---|
| 45 | |
---|
| 46 | /** initialize a OTF_File object */ |
---|
| 47 | void OTF_File_init( OTF_File* o ); |
---|
| 48 | |
---|
| 49 | /** finalize a OTF_File object */ |
---|
| 50 | void OTF_File_finalize( OTF_File* o ); |
---|
| 51 | |
---|
| 52 | /** open an OTF_File */ |
---|
| 53 | OTF_File* OTF_File_open( const char* filename, OTF_FileManager* manager, |
---|
| 54 | OTF_FileMode mode ); |
---|
| 55 | |
---|
| 56 | /** OTF_File to an OTF_File */ |
---|
| 57 | size_t OTF_File_write( OTF_File* file, const void* ptr, size_t size ); |
---|
| 58 | |
---|
| 59 | /** read from an OTF_File */ |
---|
| 60 | size_t OTF_File_read( OTF_File* file, void* ptr, size_t size ); |
---|
| 61 | |
---|
| 62 | /** seek absolute position in an OTF_File */ |
---|
| 63 | int OTF_File_seek( OTF_File* file, uint64_t pos ); |
---|
| 64 | |
---|
| 65 | /** get absolut position from an OTF_File */ |
---|
| 66 | uint64_t OTF_File_tell( OTF_File* file ); |
---|
| 67 | |
---|
| 68 | /** return the file size in bytes*/ |
---|
| 69 | uint64_t OTF_File_size( OTF_File* file ); |
---|
| 70 | |
---|
| 71 | /** close OTF_File */ |
---|
| 72 | int OTF_File_close( OTF_File* file ); |
---|
| 73 | |
---|
| 74 | /** return OTF_File status */ |
---|
| 75 | OTF_FileStatus OTF_File_status( OTF_File* file ); |
---|
| 76 | |
---|
| 77 | |
---|
| 78 | /** suspend OTF_File - internal use only. */ |
---|
| 79 | void OTF_File_suspend( OTF_File* file ); |
---|
| 80 | |
---|
| 81 | /** re-open the file when closed or suspended - internal use only. |
---|
| 82 | return 1 on success, 0 otherwise */ |
---|
| 83 | int OTF_File_revive( OTF_File* file, OTF_FileMode mode ); |
---|
| 84 | |
---|
| 85 | void OTF_File_setZBufferSize( OTF_File* file, uint32_t size ); |
---|
| 86 | |
---|
| 87 | |
---|
| 88 | /** internal use */ |
---|
| 89 | OTF_File* OTF_File_open_zlevel( const char* filename, OTF_FileManager* manager, |
---|
| 90 | OTF_FileMode mode, OTF_FileCompression compression ); |
---|
| 91 | |
---|
| 92 | #ifdef __cplusplus |
---|
| 93 | } |
---|
| 94 | #endif /* __cplusplus */ |
---|
| 95 | |
---|
| 96 | #endif /* OTF_FILE_H */ |
---|