4 * Author: Beat Forster (bfo@synthesis.ch)
7 * DBApi database adapter
8 * BLOB (Binary Large Object) access
10 * Copyright (c) 2005-2009 by Synthesis AG (www.synthesis.ch)
13 * E X A M P L E C O D E
20 #include "sync_dbapidef.h" // get some definitions
22 #include "platform_file.h"
31 /* NOTE: A BLOB object can be used for different BLOBs,
32 * but only for one BLOB simultaneously.
33 * If a new BLOB will be opened, the old one will
34 * be closed automatically, if still opened.
35 * read/write with <aFirst> = true will open a new one
36 * " " " " = false will ignore <aBlobName>
43 void Init( void* aCB, cAppCharP aDBName, string aBlobPath,
48 string BlobName ( cItemID aID, cAppCharP aBlobID );
50 size_t BlobSize ( string aBlobName ); // allowed also for open BLOBs
52 TSyError ReadBlob ( string aBlobName,
53 appPointer *blkPtr, memSize *blkSize, memSize *totSize,
54 bool aFirst, bool *aLast );
55 TSyError ReadBlob ( cItemID aID, cAppCharP aBlobID,
56 appPointer *blkPtr, memSize *blkSize, memSize *totSize,
57 bool aFirst, bool *aLast );
59 TSyError WriteBlob ( string aBlobName,
60 appPointer blkPtr, memSize blkSize, memSize totSize,
61 bool aFirst, bool aLast );
62 TSyError WriteBlob ( cItemID aID, cAppCharP aBlobID,
63 appPointer blkPtr, memSize blkSize, memSize totSize,
64 bool aFirst, bool aLast );
66 TSyError DeleteBlob( string aBlobName );
67 TSyError DeleteBlob( cItemID aID, cAppCharP aBlobID );
70 TSyError GetAttr ( string aBlobName, TAttr &aAttr, bool &isFolder ); // get BLOB's file attributes
71 TSyError SetAttr ( TAttr aAttr ); // set " " "
73 TSyError GetDates( string aBlobName, TDates &aDate ); // get BLOB's file dates
74 TSyError SetDates( string aBlobName, TDates aDate ); // set " " "
77 string getDBName() const { return fDBName; }
78 string getBlobPath() const { return fBlobPath; }
79 string getContextName() const { return fContextName; }
80 string getDevKey() const { return fDevKey; }
81 string getUsrKey() const { return fUsrKey; }
84 void* fCB; // callback structure, for debug logs
85 string fDBName; // database name, for debug logs
87 string fBlobPath; // params for creating BLOB's name
92 FILE* fFile; // assigned file
93 bool fOpened; // Is it currently opened ?
94 memSize fCurPos; // current position
95 memSize fSize; // BLOB's size
97 string fName; // BLOB's file name
100 TAttr fAttr; // BLOB's file attributes
103 TDates fDate; // BLOB's file dates
107 TSyError OpenBlob( const char* mode );
108 TSyError CloseBlob();