#pragma once
// *********************************************************************
// *** C/C++ definitions to read out sidecar files ***
// *** Last modified: 2012JUN09 ***
// *** (c) Christian Schnettelker 2011, 2012 ***
// *** ***
// *** www.finefiles.com mail@finefiles.com ***
// *********************************************************************
#include "ffBasic.h"
// Stream names
#define __SC__NAME L":finefiles.Sidecar:$DATA"
#define __SC__TMPNAME L":finefiles.TmpSC:$DATA"
/* Important: Puts packing alignment value 1 on the internal compiler */
#pragma pack( push,1 )
/* stack and sets the current packing alignment value to 1 */
// Possible results of CheckSCbasics()
#define SCCHECK__RESULT__OK 0
#define SCCHECK__RESULT__OPENERR 10
#define SCCHECK__RESULT__SETPOSERR 11
#define SCCHECK__RESULT__MAINHERR 20
#define SCCHECK__RESULT__READFATHERR 30
#define SCCHECK__RESULT__WENTRIESERR 31
#define SCCHECK__RESULT__WDELENTRIESERR 32
#define SCCHECK__RESULT__PITCREATEDERR 33
#define SCCHECK__RESULT__PITLASTACCERR 34
#define SCCHECK__RESULT__WENTRIESCOUNTERR 35
#define SCCHECK__RESULT__WDELENTRIESCOUNTERR 36
#define SCCHECK__RESULT__WBYTESCOUNTERR 37
#define SCCHECK__RESULT__WDELBYTESCOUNTERR 38
#define SCCHECK__RESULT__READENTRYERR 40
#define SCCHECK__RESULT__ENTRYMAGICERR 41
#define SCCHECK__RESULT__ENTRYFNERR 42
#define SCCHECK__RESULT__ENTRYSIZEERR 43
#define SCCHECK__RESULT__ENTRYOFFSETERR 44
#define SCCHECK__RESULT__PITADDEDERR 45
#define SCCHECK__RESULT__READFILEHERR 50
#define SCCHECK__RESULT__FILEHMAGICERR 51
#define SCCHECK__RESULT__FILENAMELENERR 52
#define SCCHECK__RESULT__PITNTFSFILECREERR 53
#define __SC__SIGNATURE "ffSCS-201 finefiles sidecar stream"
typedef struct { UCHAR cStart; // 0x89
UCHAR cSignature[ 34 ]; // contains __SC__SIGNATURE
UCHAR cCRLF[ 2 ]; // 0x0D 0x0A (Carriage Return/Line Feed)
UCHAR cEOF; // 0x1A (EOF - End Of File)
UCHAR cLF; // 0x0A (LF - Line Feed)
UCHAR cReserved; // Reserved
}
SCMAINHEADER; // 40 bytes
#define __SCFAT__HEADER "ffSC-FAT-110"
typedef struct { UCHAR cSignature[ 12 ]; // Contains __SCFAT__HEADER
WORD wEntries; // Number of valid entries (files)
WORD wDelEntries; // Number of deleted entries
unsigned int u32BytesAllFiles; // Sum of all valid files, including their files headers
unsigned int u32BytesAllDelFiles; // Sum of all deleted files, including their files headers
PIT xPITdateCreated; // Sidecar creation date
PIT xPITlastAccess; // last (write) access
unsigned __int8 u8PrefThumbnailNr; // # preferred thumbnail image
UCHAR cReserved[ 9 ];
}
SCFATHEADER; // 50 bytes
#define SCFAT__ATT__NONE 0
#define SCFAT__ATT__WRITEPROT BIT0
#define SCFAT__ATT__HIDDEN BIT1
#define SCFAT__ATT__SYSTEM BIT2 // internal file (finefiles.registers)
#define SCFAT__ATT__VOLUME BIT3
#define SCFAT__ATT__FOLDER BIT4
#define SCFAT__ATT__ARCHIVE BIT5
#define SCFAT__ATT__DELETED BIT6 // The file have been deleted
// Sidecar (file) types
#define SCFAT__TYPE__NONE FT__FILETYPE__NONE
#define SCFAT__TYPE__TEXT FT__FILETYPE__ASCII
#define SCFAT__TYPE__PDF FT__FILETYPE__PDF
#define SCFAT__TYPE__HTML FT__FILETYPE__HTML
#define SCFAT__TYPE__IMAGE FT__MAINTYPE__IMAGE
#define SCFAT__TYPE__OFFICE FT__MAINTYPE__OFFICE
#define SCFAT__TYPE__BINARY FT__MAINTYPE__BINARY
#define SCFAT__TYPE__AUDIO FT__MAINTYPE__AUDIO
#define SCFAT__TYPE__VIDEO FT__MAINTYPE__VIDEO
#define __SCFAT__TYPE__INTERNAL__ 19000 // Marker for internal types
#define SCFAT__TYPE__FFREG 19001
#define SCFAT__TYPE__FOLDER 19010
#define SCFAT__TYPE__ENC 19011
#define SCFAT__TYPE__ADD 19012
#define SCFAT__TYPE__CREATE 19013
#define __SCFAT__RESERVED__REG L"finefiles.Registers"
// The sidecar FatEntry structure contains information about a single file. This structure is
// stored in the internal "FAT"
#define SCFAT__FNAME__MAX 20
typedef struct { UCHAR cMagic; // contains '#'
wchar_t cwFileName[ SCFAT__FNAME__MAX ]; // internal filename, 20 chars (40 Bytes)
UCHAR cAttribute; // Attribute
WORD wFileType; // File type, z.B. SCFAT__TYPE__FFREG
unsigned int u32Offset; // Offset to the file
unsigned int u32FileSize; // File size (+ optional padding byte)
PIT xPITadded; // Embedding date and time
UCHAR cReserved[ 10 ];
}
SCFATENTRY; // 70 bytes
// The file header contains information about the source file like the original file name
// and the orginal creation date of the source file
typedef struct { UCHAR cMagic; // contains 'F'
UCHAR cReserved1;
WORD wHeaderLen; // Header length
DWORD dwOrgAttribute; // Original file attribute
WORD wOrgFileNameLen; // org. filename length (in chars, not bytes!!)
PIT xPITorgFileCreated; // Source file creation date + time
UCHAR cReserved2[ 12 ];
/* the original filename + EOS follows as wide-string */
}
SCFILEHEADER; // 30 bytes fix + ( length of original filename * 2 )
#define SCREG__VALID__MD5 BIT0
#define SCREG__VALID__DATESTAMP BIT1
#define SCREG__VALID__TIMESTAMP BIT2
#define SCREG__VALID__FILETYPE BIT3
#define SCREG__VALID__VIDEOSPECS BIT4
#define SCREG__VALID__AUDIOSPECS BIT5
#define SCREG__VALID__IMAGESPECS BIT6
#define SCREG__VALID__SHA1 BIT7 // Added in 2.51.0
#define SCREG__FILEFLAG__FIXED BIT0 // Added in 3.02.0
#define __SCFAT__FFREG102 "ff-REG-102"
typedef struct { UCHAR cSignature[ 10 ]; // contains __SCFAT__FFREG102
UCHAR cEOS;
UCHAR cFileFlags; // file flags
// ---------------- Data ---------------------------
unsigned int uValidFlags;
char sMD5[ MD5__LEN ]; // MD5 hash as text
DATETAG xDateTag; // 6 byte DATESTAMP
TIMETAG xTimeTag; // 6 byte TIMESTAMP
WORD wFileType; // file type
WORD wReserved2;
WORD wVideoWidth, wVideoHeight; // Video width and height
double dVideoFPS; // Video framerate (fps)
WORD wVideoHour, wVideoMin, wVideoSec; // Video length
WORD wAudioHour, wAudioMin, wAudioSec; // Audio length
WORD wImageWidth, wImageHeight; // Image width and height
char sSHA1[ SHA1__LEN ]; // SHA-1 hash as text
// -------------------------------------------------
UCHAR cReserved[ 376 ];
}
SCFFREG102; // 512 bytes
/* Important: undo packing alignment value 1 */
#pragma pack()
/* Important: undo packing alignment value 1 */
/* eof */