Пример #1
0
main()
{
    FILE	*fptr, *FileListPtr, *PlistPtr;
    CHAR	mline[MAXSTRING], CdimageFileName[1024], dirname[MAXSTRING];
    CHAR	mline2[512], filename[MAXSTRING], newfile[2], *CharPtr;
    CHAR	CdimageName[MAXSTRING], BeginName[32], FilePath[1024];
    INT		i, j;
    LONG	numfiles = 0;
    BOOL	NotFirstTime = FALSE;
    CHAR	Version[64], Patch[8], CurrentTime[25], TmpBfr[512], *CharPtr2;
    CHAR	ReleaseDir[1024];
    DWORD	HeaderSum, CheckSum;
	CHAR	verrel[64];

    if (!getenv("IngVersion"))
    {
	printf("Error! IngVersion not defined!\n");
	exit(1);
    }

    if (!getenv("PATCHNO"))
    {
	printf("Error! PATCHNO not defined!\n");
	exit(1);
    }

    if (!getenv("II_PATCH_DIR"))
    {
	printf("Error! II_PATCH_DIR not defined!\n");
	exit(1);
    }

    strcpy(Version, getenv("IngVersion"));
    j = 0;
    for (i=0; i<strlen(Version); i++)
    {
	if (Version[i] == '"')
	    continue;
	mline2[j++] = Version[i];
    }
    mline2[j] = '\0';
    strcpy(Version, mline2);

	strcpy(verrel, Version);
    j = 0;
	/* miss out the first 3 chars e.g. 'OI ' */
    for (i=3; i<strlen(verrel); i++)
    {
	if (verrel[i] == '.' || verrel[i] == '(' || verrel[i] == ')' || verrel[i] == '/'
		|| verrel[i] == ' ')
	    continue;
	mline2[j++] = verrel[i];
    }
    mline2[j] = '\0';
    strcpy(verrel, mline2);

    strcpy(Patch, getenv("PATCHNO"));
    j = 0;
    for (i=0; i<strlen(Patch); i++)
    {
	if (Patch[i] == '"')
	    continue;
	mline2[j++] = Patch[i];
    }
    mline2[j] = '\0';
    strcpy(Patch, mline2);

    strcpy(ReleaseDir, getenv("II_PATCH_DIR"));
    j = 0;
    for (i=0; i<strlen(ReleaseDir); i++)
    {
	if (ReleaseDir[i] == '"')
	    continue;
	mline2[j++] = ReleaseDir[i];
    }
    mline2[j] = '\0';
    strcpy(ReleaseDir, mline2);

    if ((fptr = fopen("fsizes.roc", "w")) == NULL)
    {
	printf("Error! Unable to open fsizes.roc for write!\n");
	exit(1);
    }

    if ((FileListPtr = fopen("filelist", "r")) == NULL)
    {
	printf("Error! Unable to open filelist for read!\n");
	fclose(fptr);
	exit(1);
    }

    if ((PlistPtr = fopen("plist", "w")) == NULL)
    {
	printf("Error! Unable to open filelist for read!\n");
	fclose(fptr);
	fclose(FileListPtr);
	exit(1);
    }

	/*
    ** Define some essentials first.
    */
    fprintf(fptr, "#define IngVersion \"%s\"\n", Version);
    fprintf(fptr, "#define PATCHNO \"%s\"\n", Patch);
    fprintf(fptr, "#define PatchVersion \"%s\"\n", verrel);
    if (getenv("INGRESII"))
	fprintf(fptr, "#define IngresII\n");

    /*
    ** Set up the plist headers.
    */
    fprintf(PlistPtr, "## Version:	%s\n", Version);
    fprintf(PlistPtr, "## Patch:	%s\n", Patch);
    fprintf(PlistPtr, "## Task:	build_plist\n");
    GetTimeOfDay(CurrentTime);
    fprintf(PlistPtr, "## Performed:	%s\n", CurrentTime);
    fprintf(PlistPtr, "##\n##\n## Contents:\n");
    fprintf(PlistPtr, "##	Packing list for patch ID recorded above.\n");
    fprintf(PlistPtr, "##\n##\n");
    fprintf(PlistPtr, "##                  file                        size     checksum\n##\n");

    fprintf(fptr, "\nstruct FILEINF filesizes[] = {\n");

    /*
    ** Now, set up the filesizes array. As we do this, if we find a file
    ** which is not in 8.3 (cdimage) format, rename it as such. Also,
    ** if we are dealing with files which are located in dictfiles or
    ** collation, the directories on the cdimage will be dictfile
    ** or collatio.
    */
    while (fgets(mline, MAXSTRING -1, FileListPtr) != NULL)
    {
	numfiles++;

	if (NotFirstTime)
	    fprintf(fptr, ",\n");

	if (!NotFirstTime)
	    NotFirstTime = TRUE;

	mline[strlen(mline)-1] = '\0';
	CharPtr = mline;
	strcpy(dirname, mline);
	CharPtr2 = dirname;
	while (*CharPtr2 != ' ')
	{
	    CharPtr++;
	    CharPtr2++;
	}
	*CharPtr2 = '\0';
	strcpy(TmpBfr, dirname);
	if (dirname[strlen(dirname)-1] == '\\')
	    dirname[strlen(dirname)-1] = '\0';
	else 
	{
		TmpBfr[strlen(TmpBfr)+1] = '\0';
		TmpBfr[strlen(TmpBfr)] = '\\';
	}

	/*
	** Convert single slashes to double slashes.
	*/
	j = 0;
	for (i=0; i<strlen(dirname); i++)
	{
	    mline2[j] = dirname[i];
	    if (dirname[i] == '\\')
		mline2[++j] = '\\';

	    j++;
	}
	mline2[j] = '\0';
	strcpy(dirname, mline2);

	CharPtr++;
	strcpy(filename, CharPtr);
	CharPtr2 = filename;
	while (*CharPtr2 != ' ')
	{
	    CharPtr++;
	    CharPtr2++;
	}
	*CharPtr2 = '\0';
	strcat(TmpBfr, filename);

	CharPtr++;
	strcpy(newfile, CharPtr);
	newfile[1] = '\0';

	sprintf(CdimageFileName, "%s%s\\%s", ReleaseDir, dirname, filename);

	if (!FileExists(CdimageFileName))
	{
	    printf("Error! %s does not exist!\n", CdimageFileName);
	    fclose(PlistPtr);
	    fclose(FileListPtr);
	    fclose(fptr);
	}

	strcpy(CdimageName, filename);
/*	strcpy(mline2, filename);
	if ((CharPtr2 = strchr(mline2, '.')) != NULL)
	    *CharPtr2 = '\0';

	if (strlen(mline2) > 8)
	{
	    j = 1;
	    strncpy(BeginName, filename, 7);
	    BeginName[7] = '\0';
	    CharPtr2 = strchr(filename, '.');
	    if (CharPtr2)
		sprintf(CdimageName, "%s%i%s", BeginName, j, CharPtr2);
	    else
		sprintf(CdimageName, "%s%i", BeginName, j);
	    sprintf(mline2, "%s%s\\%s", ReleaseDir, dirname, CdimageName);
	    while (FileExists(mline2))
	    {
		j++;
	   	if (CharPtr2)
		    sprintf(CdimageName, "%s%i%s", BeginName, j, CharPtr2);
		else
		    sprintf(CdimageName, "%s%i", BeginName, j);
		sprintf(mline2, "%s%s\\%s", ReleaseDir, dirname, CdimageName);
	    }

	    CopyFile(CdimageFileName, mline2, FALSE);
	    DeleteFile(CdimageFileName);
	    strcpy(CdimageFileName, mline2);
	} */
	
	fprintf(fptr, "\"  \",	\"%s\",	\"%s\",	\"%s\",	%d,	%i,	0",
		filename, CdimageName, dirname,
		GetCurrentFileSize(CdimageFileName), atoi(newfile));

	CheckSum = GetCurrentFileChecksum(CdimageFileName);
	fprintf(PlistPtr, "%-58s  %9d  %10u\n", TmpBfr,
		GetCurrentFileSize(CdimageFileName), CheckSum);
    }

    fprintf(fptr, "\n};\n\n#define NUMFILES %d\n", numfiles);

    fprintf(PlistPtr, "##\n##\n## File format version:	1\n");
    fprintf(PlistPtr, "##\n##\n## State:	completed\n");

    fclose(PlistPtr);
    fclose(FileListPtr);
    fclose(fptr);
}
Пример #2
0
int hb_CmpTdSpan( const char * szFile, PHB_ITEM pArray, int iCompLevel, PHB_ITEM pBlock, BOOL bOverWrite, const char * szPassWord, int iSpanSize, BOOL bPath, BOOL bDrive, PHB_ITEM pProgress )
{
   ULONG                ulCount     = 0;
   const char *         szDummy;
   DWORD                dwSize;
   BOOL                 bAdded      = FALSE;
   BOOL                 bReturn     = TRUE;
   BOOL                 bFileExist  = hb_fsFile( szFile );

   CZipArchive          szZip;
   SpanCallbackc        span;
   SpanActionCallbackc  spanac;

   szZip.SetSpanCallback( &span );


   if( iSpanSize == 0 )
   {
      iSpanSize = 1457664;
   }

   try
   {
      if( ( bFileExist && bOverWrite ) || ! bFileExist )
      {
         szZip.Open( szFile, CZipArchive::zipCreateSpan, iSpanSize );
      }
      else
      {
         bReturn = FALSE;
         return ( int ) bReturn;
      }
   }

   catch( CZipException )
   {
      bReturn = FALSE;
   }

   catch( ... )
   {
   }

   //if (! bReturn )
   //{

   if( szPassWord != NULL )
   {
      szZip.SetPassword( szPassWord );
   }

   if( pZipI.szComment != NULL )
   {
      szZip.SetGlobalComment( pZipI.szComment );
      hb_xfree( pZipI.szComment );
   }

   if( HB_IS_BLOCK( pProgress ) )
   {
      pProgressInfo = pProgress;
      szZip.SetCallback( &spanac );
   }

   for( ulCount = 1; ( ulCount <= hb_arrayLen( pArray ) ); ulCount++ )
   {
      szDummy  = ( char * ) hb_arrayGetCPtr( pArray, ulCount );
      dwSize   = GetCurrentFileSize( szDummy );

      bAdded   = FALSE;

      if( dwSize != ( DWORD ) -1 )
      {
         if( pBlock != NULL )
         {
            PHB_ITEM FileName = hb_itemPutC( NULL, hb_arrayGetCPtr( pArray, ulCount ) ), FilePos = hb_itemPutNI( NULL, ulCount );

            hb_vmEvalBlockV( pBlock, 2, FileName, FilePos );

            hb_itemRelease( FileName );
            hb_itemRelease( FilePos );
         }

         try
         {

            if( bPath && ! bAdded )
            {
               szZip.AddNewFile( szDummy, iCompLevel, true, CZipArchive::zipsmSafeSmart, 65536 );
               bAdded = TRUE;
            }
            else if( ! bDrive && ! bPath && ! bAdded )
            {
               szZip.AddNewFile( szDummy, iCompLevel, false, CZipArchive::zipsmSafeSmart, 65536 );
            }

         }
         catch( ... )
         {
         }
      }
   }
   //}

   try
   {
      szZip.Close();
   }

   catch( CZipException )
   {
      bReturn = FALSE;
   }

   catch( ... )
   {
   }


   return ( int ) bReturn;
}
Пример #3
0
int hb_CmpTdSpanStd( char * szFile, char * szFiletoCompress, int iCompLevel, PHB_ITEM pBlock, BOOL bOverWrite, char * szPassWord, int iSpanSize, BOOL bPath, BOOL bDrive, PHB_ITEM pProgress )
{
   DWORD                dwSize;
   BOOL                 bAdded      = FALSE;
   BOOL                 bReturn     = TRUE;
   BOOL                 bFileExist  = hb_fsFile( szFile );

   CZipArchive          szZip;
   SpanCallbackc        span;
   SpanActionCallbackc  spanac;

   szZip.SetSpanCallback( &span );


   if( iSpanSize == 0 )
   {
      iSpanSize = 1457664;
   }

   try
   {
      if( ( bFileExist && bOverWrite ) || ! bFileExist )
      {
         szZip.Open( szFile, CZipArchive::zipCreateSpan, iSpanSize );
      }
      else
      {
         return ( int ) false;
      }
   }

   catch( CZipException )
   {
      bReturn = FALSE;
   }

   catch( ... )
   {
   }

   if( szPassWord != NULL )
   {
      szZip.SetPassword( szPassWord );
   }

   if( pZipI.szComment != NULL )
   {
      szZip.SetGlobalComment( pZipI.szComment );
      hb_xfree( pZipI.szComment );
   }

   if( HB_IS_BLOCK( pProgress ) )
   {
      pProgressInfo = pProgress;
      szZip.SetCallback( &spanac );
   }
   if( bReturn )
   {
      try
      {
         if( szPassWord != NULL )
         {
            szZip.SetPassword( szPassWord );
         }

         dwSize = GetCurrentFileSize( szFiletoCompress );

         if( pBlock != NULL )
         {
            PHB_ITEM FileName = hb_itemPutC( NULL, szFiletoCompress  );

            hb_vmEvalBlockV(  pBlock, 1, FileName );

            hb_itemRelease( FileName );

         }

         #if defined( __WIN32__ ) || defined( __MINGW32__ )
         if( bDrive && ! bAdded )
         {
            if( ! szZip.AddNewFileDrv( szFiletoCompress, iCompLevel, true, CZipArchive::zipsmSafeSmart, 65536 ) )
            {
               bReturn = FALSE;
            }
            else
            {
               bAdded = TRUE;
            }
         }
         #endif

         if( bPath && ! bAdded )
         {
            if( ! szZip.AddNewFile( szFiletoCompress, iCompLevel, true, CZipArchive::zipsmSafeSmart, 65536 ) )
            {
               bReturn = FALSE;
            }
            else
            {
               bAdded = TRUE;
            }
         }
         else if( ! bDrive && ! bPath && ! bAdded )
         {
            if( ! szZip.AddNewFile( szFiletoCompress, iCompLevel, false, CZipArchive::zipsmSafeSmart, 65536 ) )
            {
               bReturn = FALSE;
            }
         }

      }
      catch( ... )
      {
      }
   }

   try
   {
      szZip.Close();
   }

   catch( CZipException )
   {
      bReturn = FALSE;
   }

   catch( ... )
   {
   }
   if( pProgressInfo )
   {
      hb_itemRelease( pProgressInfo );
   }

   return ( int ) bReturn;
}
Пример #4
0
int hb_CompressFile( const char * szFile, PHB_ITEM pArray, int iCompLevel, PHB_ITEM pBlock, BOOL bOverWrite, const char * szPassWord, BOOL bPath, BOOL bDrive, PHB_ITEM pProgress )
{
   ULONG                ulCount        = 0;
   const char *         szDummy;
   char *               szDummyLower   = NULL;
   char *               szFileLower    = hb_strdup( ( char * ) szFile );
   BOOL                 bFileExist     = hb_fsFile( szFile );
   BOOL                 bAdded         = FALSE;
   BOOL                 bReturn        = TRUE;
   DWORD                dwSize;

   CZipArchive          szZip;
   SpanCallbackc        span;
   SpanActionCallbackc  spanac;

   szZip.SetSpanCallback( &span );

   #ifdef HB_OS_WIN_32
   hb_strLower( szFileLower, strlen( szFileLower ) );
   #endif

   try
   {
      if( ( bFileExist && bOverWrite ) || ! bFileExist )
      {
         szZip.Open( szFile, CZipArchive::zipCreate, 0 );
      }
      else
      {
         szZip.Open( szFile, CZipArchive::zipOpen, 0 );
      }
   }

   catch( CZipException )
   {
      bReturn = FALSE;
   }

   catch( ... )
   {
   }

   if( bReturn )
   {

      if( szPassWord != NULL )
      {
         szZip.SetPassword( szPassWord );
      }

      if( pZipI.szComment != NULL )
      {
         szZip.SetGlobalComment( pZipI.szComment );
         hb_xfree( pZipI.szComment );
      }

      if( HB_IS_BLOCK( pProgress ) )
      {
         pProgressInfo = pProgress;
         szZip.SetCallback( &spanac );
      }

      for( ulCount = 1; ( ulCount <= hb_arrayLen( pArray ) ); ulCount++ )
      {
         szDummy        = ( char * ) hb_arrayGetCPtr( pArray, ulCount );
         dwSize         = GetCurrentFileSize( szDummy );
         bAdded         = FALSE;

         szDummyLower   = hb_strdup( ( char * ) szDummy );

         #ifdef HB_OS_WIN_32
         hb_strLower( szDummyLower, strlen( szDummyLower ) );
         #endif

// Prevent adding current archive file !
         if( strstr( szFileLower, szDummyLower ) == NULL && strstr( szDummyLower, szFileLower ) == NULL )
         {
            if( dwSize != ( DWORD ) -1 )
            {
               if( pBlock != NULL )
               {
                  PHB_ITEM FileName = hb_itemPutC( NULL, hb_arrayGetCPtr( pArray, ulCount ) ), FilePos = hb_itemPutNI( NULL, ulCount );


                  hb_vmEvalBlockV( pBlock, 2, FileName, FilePos );

                  hb_itemRelease( FileName );
                  hb_itemRelease( FilePos );
               }

               try
               {
                  if( bPath && ! bAdded )
                  {
                     szZip.AddNewFile( szDummy, iCompLevel, true, CZipArchive::zipsmSafeSmart, 65536 );
                     bAdded = TRUE;
                  }
                  else if( ! bDrive && ! bPath && ! bAdded )
                  {
                     szZip.AddNewFile( szDummy, iCompLevel, false, CZipArchive::zipsmSafeSmart, 65536 );
                  }

               }
               catch( ... )
               {
               }
            }
         }
         hb_xfree( szDummyLower );
      }
   }
   hb_xfree( szFileLower );
   try
   {
      szZip.Close();
   }

   catch( CZipException )
   {
      bReturn = FALSE;
   }

   catch( ... )
   {
   }

   return ( int ) bReturn;


}