Home

Resume

Blog

Teikitu


/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/*  »Project«   Teikitu Gaming System (TgS) (∂)
    »File«      TgS Common - Base - Type [File].h
    »Author«    Andrew Aye (EMail: mailto:andrew.aye@gmail.com, Web: http://www.andrewaye.com)
    »Version«   4.51 / »GUID« A9981407-3EC9-42AF-8B6F-8BE6DD919615                                                                                                        */
/*   -------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
/*  Copyright: © 2002-2017, Andrew Aye.  All Rights Reserved.
    This software is free for non-commercial use.  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
      following conditions are met:
        Redistribution of source code must retain this copyright notice, this list of conditions and the following disclaimers.
        Redistribution in binary form must reproduce this copyright notice, this list of conditions and the following disclaimers in the documentation and other materials
          provided with the distribution.
    The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
    The intellectual property rights of the algorithms used reside with Andrew Aye.
    You may not use this software, in whole or in part, in support of any commercial product without the express written consent of the author.
    There is no warranty or other guarantee of fitness of this software for any purpose. It is provided solely "as is".                                                   */
/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
#if !defined(TGS_COMMON_BASE_TYPE_FILE_H)
#define TGS_COMMON_BASE_TYPE_FILE_H
#pragma once


/* == Common ============================================================================================================================================================ */

/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Public Constants                                                                                                                                                      */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

enum { KTgMAX_NUM_FILE                      = 512 };
enum { KTgMAX_FILE_PATH                     = 240 };
enum { KTgMAX_FILE_NAME                     =  32 };

TgTYPE_ENUM( ETgFILE_PLATFORM, TgSINT32,

    ETgFILE_PLATFORM_W32    = 1<<0, ETgFILE_PLATFORM_W64    = 1<<1, ETgFILE_PLATFORM_XB2    = 1<<2, ETgFILE_PLATFORM_PS3    = 1<<3, ETgFILE_PLATFORM_XB3    = 1<<4,
    ETgFILE_PLATFORM_PS4    = 1<<5, ETgFILE_PLATFORM_IPHONE = 1<<6, ETgFILE_PLATFORM_IPAD   = 1<<7
);

TgTYPE_ENUM( ETgFILE_FLAG, TgSINT32,

    ETgFILE_FLAG_ENDIAN    = 1<<0
);


/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Public Types                                                                                                                                                          */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

/* Describes the type and location of a data section in the file.  These follow a STg2_File_Block to describe all of the data in the block  */
TgTYPE_STRUCT_ALIGN(STg2_File_Section,16,)
{
    TgUINT64                                    m_uiFourCC; /*« Descriptor of the file section */
    TgUINT64                                    m_uiOffset; /*« Offset in file, from file header, to the data header. */
};

/* The file block marks the beginning of a block uniquely identified by the Kernel File OS.  In a traditional IO system this would be a discrete file on the recorded media. */
/* However, because of loading requirements on various hardware platforms, the mapping of a discrete file block is not guaranteed to map 1:1 to a specific file on the media */
/* though it will always be capable of being uniquely identified and used by the Kernel system. */
TgTYPE_STRUCT_ALIGN(STg2_File_Block,16,)
{
    /* File Block - This describes the file format definition */
    TgUINT64                                    m_uiFourCC; /*« Must be 'TGSF' */
    TgUINT64                                    m_uiSize; /*« Size of the Header */
    TgUINT16                                    m_uiVersion; /*« Version of the file format */
    TgUINT08                                    m_uiMachine; /*« Machine targeted by file */
    TgUINT08                                    m_uiFlags; /*« Used to describe file or machine traits */

    /* Tool Block - This describes the tool used to make the file. */
    TgUINT16                                    m_uiTool_Version; /*« Version of the tool used to make file */
    TgUINT16                                    m_uiTool_ID; /*« Generic Identifier for the tool used to make this file */

    /* Section Block - This describes the section listing after the header */
    TgUINT16                                    m_uiSection_Version; /*« Version of the file section entries */
    TgUINT16                                    m_uiSection_Count; /*« Count of the file section entries */
    TgUINT32                                    m_uiSection_Size; /*« Size of the file section entries */

    /* Contiguous list of data sections in this file block */
    STg2_File_Section                           m_asSection[1]; /*« Array is actually of size m_uiSection_Size */
};

/* Describes the subsequent (following) data section */
TgTYPE_STRUCT_ALIGN(STg2_File_Data,16,)
{
    TgUINT32                                    m_uiFourCC; /*« Descriptor of the file section */
    TgUINT32                                    m_uiSize; /*« Size of the file section */
    TgUINT32                                    m_uiVersion; /*« Version of the file section */
    TgSINT32                                    m_iOffset; /*« Offset from this header, to the data.  (Allow for data alignment) */
};

/* Describe a data test section (used by the unit test) - 4CC = 'TEST' */
TgTYPE_STRUCT_ALIGN(STg2_File_Data__TEST,16,)
{
    TgUINT32                                    m_uiTest;
    TgUINT32                                    m_nuiData;
    TgUINT08                                    m_auiData[8]; /*« Array is actually of size m_nuiData */
};


/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Public Functions                                                                                                                                                      */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

/* ---- Path Functions ---------------------------------------------------------------------------------------------------------------------------------------------------- */

TgEXTN P_TgCHAR                             tgCM_Path_Add_Seperator( PC_TgCHAR, C_TgSIZE );
TgEXTN P_TgCHAR                             tgCM_Path_Add_Extension( PC_TgCHAR, C_TgSIZE, CPC_TgCHAR );
TgEXTN P_TgCHAR                             tgCM_Path_Copy( PC_TgCHAR, C_TgSIZE, CPC_TgCHAR );
TgEXTN P_TgCHAR                             tgCM_Path_Append( PC_TgCHAR, C_TgSIZE, CPC_TgCHAR );
TgEXTN TgUINT32                             tgCM_Path_Common_Prefix_Size( CPC_TgCHAR, CPC_TgCHAR );
TgEXTN P_TgCHAR                             tgCM_Path_Common_Prefix( PC_TgCHAR, C_TgSIZE, CPC_TgCHAR, CPC_TgCHAR );
TgEXTN P_TgCHAR                             tgCM_Path_Remove_Seperator( PC_TgCHAR );
TgEXTN P_TgCHAR                             tgCM_Path_Remove_Extension( PC_TgCHAR );
TgEXTN P_TgCHAR                             tgCM_Path_Remove_File_Name( PC_TgCHAR );
TgEXTN P_TgCHAR                             tgCM_Path_Rename_Extension( PC_TgCHAR, C_TgSIZE, CPC_TgCHAR );
TgEXTN P_TgCHAR                             tgCM_Path_Remove_Directory( PC_TgCHAR );
TgEXTN P_TgCHAR                             tgCM_Path_Init( PC_TgCHAR, C_TgSIZE, ... );

TgEXTN P_TgCHAR                             tgCM_Path_Find_Extension( PC_TgCHAR );
TgEXTN P_TgCHAR                             tgCM_Path_Find_File_Name( PC_TgCHAR );

                                            /* Platform specific functions */
TgEXTN TgBOOL                               tgCM_Path_IsAbsolute( PC_TgCHAR );
TgEXTN TgVOID                               tgCM_Path_Query_Application_Data_Directory( P_TgCHAR, C_TgSIZE );
TgEXTN TgVOID                               tgCM_Path_Query_Temporary_Directory( P_TgCHAR, C_TgSIZE );


/* ---- File Data Functions ----------------------------------------------------------------------------------------------------------------------------------------------- */

TgEXTN TgVOID                               tgCM_File_Output_Header( P_STg2_Output, CPC_STg2_File_Block );
TgEXTN TgVOID                               tgCM_File_Output_Data_Headers( P_STg2_Output, CPC_STg2_File_Block );

TgEXTN TgBOOL                               tgCM_File_Query_Data( TgVOID const **, CPC_STg2_File_Block, C_TgUINT32 );
TgEXTN TgBOOL                               tgCM_File_Query_Data_Size( P_TgSIZE, CPC_STg2_File_Block, C_TgUINT32 );
TgEXTN TgSIZE                               tgCM_File_Query_Data_Count( CPC_STg2_File_Block );

TgEXTN TgVOID                               tgCM_File_Check_Block_With_Assert( CPCU_STg2_File_Block );


/* ====================================================================================================================================================================== */
#endif