コード例 #1
0
//----------------
//
void WriteDatFile( TYPE_File *writeFile )
{
    char* currentDir;
     
    appendToLogfile("WriteDatFile: Started.", INFO);
    appendToLogfile("WriteDatFile: GetCurrentDir called.", WARNING);
    currentDir = GetCurrentDir();  // Store the current  directory.

    appendStringToLogfile("WriteDatFile: GetCurrentDir returned=%s.",currentDir, WARNING);
    appendStringToLogfile("WriteDatFile: Moving to=%s.",TAPIniDir, WARNING);
    GotoPath(TAPIniDir);           // Go to the Project Directory.
    
	if ( TAP_Hdd_Exist( PLAYDATA_FILENAME ) ) TAP_Hdd_Delete( PLAYDATA_FILENAME );	// Just delete any old copies

    appendToLogfile("WriteDatFile: Creating DATA file.", ERR);
	TAP_Hdd_Create( PLAYDATA_FILENAME, ATTR_PROGRAM );						// Create the file

    appendToLogfile("WriteDatFile: Opening DATA file.", ERR);
	writeFile = TAP_Hdd_Fopen( PLAYDATA_FILENAME );
	if ( writeFile == NULL ) return; 										// Check we can open it

    appendToLogfile("WriteDatFile: Writing to DATA file.", ERR);
	TAP_Hdd_Fwrite( playDataBuffer_ini, PLAYBACKDATA_BUFFER_SIZE_ini, 1, writeFile );	// dump the whole buffer in one hit

    appendToLogfile("WriteDatFile: Closing DATA file.", ERR);
	TAP_Hdd_Fclose( writeFile );

    appendStringToLogfile("WriteDatFile: Returning to=%s.",currentDir, WARNING);
	GotoPath(currentDir);            // Return to the original directory.

    TAP_MemFree( currentDir );   // Free allocated memory.
    
    appendToLogfile("WriteDatFile: Finished.", INFO);
}
コード例 #2
0
ファイル: IniFile.c プロジェクト: BackupTheBerlios/tap-svn
bool ReadConfigurationFile( void )
{
	TYPE_File *readFile = NULL;
	int	i = 0;
	dword	fileLength = 0;
	bool	schSaveIniFile = FALSE;

	GotoPath( SETTINGS_FOLDER );
	if ( ! TAP_Hdd_Exist( OPTIONS_FILENAME ) )
	{
		GotoTapDir();
		TAP_Hdd_ChangeDir( PROJECT_DIRECTORY );
		if ( ! TAP_Hdd_Exist( OPTIONS_FILENAME ) ) return FALSE;

		schSaveIniFile = TRUE;
	}
	
	readFile = TAP_Hdd_Fopen( OPTIONS_FILENAME );
	if ( readFile == NULL ) return FALSE;						// and we can open it ok

	dataBuffer_ini = TAP_MemAlloc( DATA_BUFFER_SIZE_ini );				// Read the data in one hit (quicker), then process from RAM
	memset( dataBuffer_ini, '\0', DATA_BUFFER_SIZE_ini );				// set the whole buffer to the string termination character (null)
	dataBufferPtr_ini = 0;

	fileLength = TAP_Hdd_Flen( readFile );						// how big is the file
	if ( fileLength > DATA_BUFFER_SIZE_ini  ) fileLength = DATA_BUFFER_SIZE_ini;	// ensure we don't overflow the buffer
	
	TAP_Hdd_Fread( dataBuffer_ini, fileLength, 1, readFile );			// grab all the data from the file

	TAP_Hdd_Fclose( readFile );

	if(SetConfigurationVariables() == FALSE)
	{
		TAP_MemFree( dataBuffer_ini );						// must return the memory back to the heap

		SaveConfigurationToFile();
	}
	else
	{
		TAP_MemFree( dataBuffer_ini );						// must return the memory back to the heap
	}

	if(schSaveIniFile == TRUE)
	{
		SaveConfigurationToFile();

		GotoTapDir();
		TAP_Hdd_ChangeDir( PROJECT_DIRECTORY );

		if ( TAP_Hdd_Exist( OPTIONS_FILENAME ) ) TAP_Hdd_Delete( OPTIONS_FILENAME );
	}

	return TRUE;
}
コード例 #3
0
ファイル: IniFile.c プロジェクト: BackupTheBerlios/tap-svn
//----------------
//
void WriteIniFile( TYPE_File *writeFile )
{
	GotoPath(SETTINGS_FOLDER);
	if ( TAP_Hdd_Exist( OPTIONS_FILENAME ) ) TAP_Hdd_Delete( OPTIONS_FILENAME );	// Just delete any old copies

	TAP_Hdd_Create( OPTIONS_FILENAME, ATTR_PROGRAM );				// Create the file

	writeFile = TAP_Hdd_Fopen( OPTIONS_FILENAME );
	if ( writeFile == NULL ) return; 										// Check we can open it

	TAP_Hdd_Fwrite( dataBuffer_ini, DATA_BUFFER_SIZE_ini, 1, writeFile );		// dump the whole buffer in one hit

	TAP_Hdd_Fclose( writeFile );
}
コード例 #4
0
//------------
//
void DeleteFileFolder(void)
{
     char str[TS_FILE_NAME_SIZE];
     
     if (myfiles[CurrentDirNumber][chosenLine]->isPlaying)
        TAP_Hdd_StopTs();  // Stop the current playback to allow us to delete the file.
     TAP_Hdd_Delete(myfiles[CurrentDirNumber][chosenLine]->name);
     
     // Check if the delete was successful.
#ifdef WIN32
     if (FALSE)
#else  
     if (TAP_Hdd_Exist(myfiles[CurrentDirNumber][chosenLine]->name))  // Delete didn't work
#endif
     {
         TAP_SPrint(str,myfiles[CurrentDirNumber][chosenLine]->name);
         ShowMessageWin( rgn, "File Deletion Failed.", "Failed to delete file:", str, 400 );
         fileDeleted = FALSE;
     }
     else
         fileDeleted = TRUE;
     
}
コード例 #5
0
void DeletePlayData( void )
{   // Will delete the playback progress file, and then recreate a new one.
    char* currentDir;
    int i;
     
    appendToLogfile("DeletePlayData: Started.", INFO);

    appendToLogfile("DeletePlayData: GetCurrentDir called.", WARNING);
    currentDir = GetCurrentDir();  // Store the current  directory.
    appendStringToLogfile("DeletePlayData: GetCurrentDir returned=%s.",currentDir, WARNING);
    appendStringToLogfile("DeletePlayData: Moving to=%s.",TAPIniDir, WARNING);
    GotoPath(TAPIniDir);           // Go to the Project Directory.

    appendToLogfile("DeletePlayData: Deleting DATA file.", ERR);
	if ( TAP_Hdd_Exist( PLAYDATA_FILENAME ) ) TAP_Hdd_Delete( PLAYDATA_FILENAME );	// Just delete any old copies

    appendToLogfile("DeletePlayData: Calling LoadPlayData.", ERR);
    LoadPlayData();  // Recreate and reload the new information.

    appendStringToLogfile("DeletePlayData: Returning to=%s.",currentDir, WARNING);
	GotoPath(currentDir);            // Return to the original directory.

    // Got through all of our current files and remove any progress information.
    for (i=1; i <= numberOfFiles; i += 1)
    {
        myfiles[CurrentDirNumber][i]->hasPlayed = FALSE;  // Reset indicator to show that file has not been played.
        myfiles[CurrentDirNumber][i]->currentBlock = 0;
        myfiles[CurrentDirNumber][i]->totalBlock   = 1;   // Set to 1 to ensure no division by 0 errors.
    }   

    ShowMessageWin( rgn, "All Progress Info Cleared.", "Removed playback information", "for all recorded files.", 400 );

    TAP_MemFree( currentDir );   // Free allocated memory.

    appendToLogfile("DeletePlayData: Finished.", INFO);
}
コード例 #6
0
void AutoStartPage::Save()
{
	if ( m_taps.size() == 0 )
	{
		MessageBox::Show( messageBoxTitle, "No TAPs are installed in Auto Start", "OK" );
		return;
	}

	// Set current directory to ProgramFiles
	if ( !TAP_Hdd_ChangeDir( programFilesPath ) )
	{
		MessageBox::Show( messageBoxTitle, "ProgramFiles directory could not be found", "OK" );
		return;
	}

	// display a progress box
	ProgressBox progress( "Please wait", "Reordering Auto Start TAPs" );
	progress.OnOpen();

	string errors;
	string warnings;

	bool reorder = false;
	// Get the current filenames of each of the TAPs
	if ( !TAP_Hdd_ChangeDir( autoStartPath ) )
	{
		progress.OnClose();
		MessageBox::Show("Reorder TAPs", "Failed to find Auto Start folder", "OK");
		return;
	}
	for ( unsigned int i = 0; i < m_taps.size(); ++i )
	{
		if ( m_taps[i].index != i )
			reorder = true;
		if ( !TAP_Hdd_Exist( (char*)m_taps[i].filename.c_str() ) )
		{
			int extOffset = m_taps[i].filename.size()-3;
			if ( extOffset > 0)
			{
				m_taps[i].filename[extOffset] = m_taps[i].filename[extOffset] == 't' ? 'n' : 't';
			}
		}
	}

	if (reorder)
	{
		TAP_Hdd_ChangeDir("..");
		// Create a temporary Auto Start and move all TAPs there
		TAP_Hdd_Create( tempAutoStartName, ATTR_FOLDER );
		if ( !TAP_Hdd_ChangeDir( tempAutoStartName ) )
		{
			progress.OnClose();
			MessageBox::Show( messageBoxTitle, "Failed to create Temp Auto Start folder", "OK");
			return;
		}
		// Move the TAPs to the Temporary Auto Start directory
		short int stepSize = 50/m_taps.size();
		for ( unsigned int i = 0; i < m_taps.size(); ++i )
		{
			TRACE1("Moving %s\n",(char*)m_taps[i].filename.c_str());
			progress.StepProgress( stepSize, "Preparing " + m_taps[i].name );
			HDD_Move( (char*)m_taps[i].filename.c_str(), "/ProgramFiles/Auto Start", "/ProgramFiles/Temp Auto Start" );
			if ( !TAP_Hdd_Exist( (char*)m_taps[i].filename.c_str() ) )
			{
				// TAP wasn't moved, flag the failure and
				if ( warnings.size() > 0 )
					warnings += ", ";
				warnings += m_taps[i].name;
				m_taps[i].spare = false;
				progress.StepProgress( stepSize );
			}
			else
				m_taps[i].spare = true;
		}
		TRACE("Done moving\n");

		// Now move them back into Auto Start in the order the user has requested
		if ( !TAP_Hdd_ChangeDir( "/ProgramFiles/Auto Start" ) )
		{
			progress.OnClose();
			MessageBox::Show("Reorder TAPs", "Failed to find Auto Start folder", "OK");
			return;
		}
		int count = 0;
		for ( unsigned int i = 0; i < m_taps.size(); ++i )
		{
			if ( m_taps[i].spare )
			{
				TRACE1("Moving TAP %s\n",(char*)m_taps[i].filename.c_str());
				progress.StepProgress( stepSize, "Reordering " + m_taps[i].name );
				HDD_Move((char*)m_taps[i].filename.c_str(), "/ProgramFiles/Temp Auto Start", "/ProgramFiles/Auto Start");
				if ( !TAP_Hdd_Exist( (char*)m_taps[i].filename.c_str() ) )
				{
					if ( errors.size() > 0 )
						errors += ", ";
					errors += m_taps[i].name;
				}
				++count;
			}
		}
	}

	// Finally, deal with enabled and disabled
	for ( unsigned int i = 0; i < m_taps.size(); ++i )
	{
		int extOffset = m_taps[i].filename.size()-3;
		string tapName = m_taps[i].filename;
		tapName[extOffset] = 't';
		string napName = m_taps[i].filename;
		napName[extOffset] = 'n';
		if ( m_taps[i].enabled )
		{
			// ensure TAP is enabled
			if ( TAP_Hdd_Exist( (char*)tapName.c_str() ) )
				TAP_Hdd_Delete( (char*)napName.c_str() );
			else
				TAP_Hdd_Rename( (char*)napName.c_str(), (char*)tapName.c_str() );
		}
		else
		{
			// ensure TAP is disabled
			if ( TAP_Hdd_Exist( (char*)tapName.c_str() ) )
			{
				TAP_Hdd_Delete( (char*)napName.c_str() );
				TAP_Hdd_Rename( (char*)tapName.c_str(), (char*)napName.c_str() );
			}
		}
	}

	// Delete Temp Auto Start if the directory is empty
	if ( TAP_Hdd_ChangeDir( "/ProgramFiles/Temp Auto Start" ) )
	{
		TYPE_File file;
		dword totalEntry = TAP_Hdd_FindFirst( &file );
		while ( totalEntry-- )
		{
			// ignore ., .. and deleted files
			if ( file.attr != ATTR_PARENTFOLDER && file.attr != ATTR_THISFOLDER && file.attr != ATTR_DELETEDFILE )
				break;
			if ( totalEntry==0 || TAP_Hdd_FindNext( &file ) == 0 )
			{
				TAP_Hdd_ChangeDir("..");
				TAP_Hdd_Delete( tempAutoStartName );
				break;
			}
		}
	}

	progress.OnClose();

	// report any errors
	if ( errors.size() || warnings.size() )
	{
		if ( errors.size() > 0 )
			MessageBox::Show("Reorder TAPs", "The following TAPs could not be reordered:\n" + errors + "Check the Temp Auto Start folder", "OK");
		else if ( warnings.size() > 0 )
			MessageBox::Show("Reorder TAPs", "The following TAPs could not be reordered:\n" + warnings, "OK");
	}
	else
	{
		if ( MessageBox::Show("Reorder TAPs", "Finished", HDD_isAnyRecording() ? "OK" : "OK\nReboot" ) == 2 )
			Reboot(false);
	}
}
コード例 #7
0
void LogoManager_LogoCacheRebuild(void)
{
  TRACEENTER();

  char                  ID[4];
  dword                 Version;
  TYPE_File            *f, *fLogo;
  int                   i, j, k, NrFiles;
  TYPE_FolderEntry      FolderEntry;
  dword                 LogoIndex;
  byte                 *PixelData, *TempBuffer;
  dword                 BufferSize, CompressedSize;
  TYPE_GrData          *grData;
  int                   LogosConverted;
  char                  LogoPath[FBLIB_DIR_SIZE];

  if(LogoManager_CB) LogoManager_CB(2, -1);

  //Step 1: Kill the current cache
  HDD_TAP_PushDir();
  HDD_ChangeDir(LOGOROOT);
  TAP_Hdd_Delete(LOGOCACHE);

  //Step 2: iterate through all directories and count the number of logos
  LogoManager_NrLogos = 0;
  for(i = LGST_3pgstyle; i < LGST_NRITEMS; i++)
  {
    for(j = LGAR_43; j < LGAR_NRITEMS; j++)
    {
      if(HDD_ChangeDir(LogoManager_GetDirectory(i, j, LogoPath)))
      {
        NrFiles = TAP_Hdd_FindFirst(&FolderEntry, "qtl|qsl|ibl");
        for(k = 0; k < NrFiles; k++)
        {
          if(FolderEntry.attr == ATTR_NORMAL)
          {
            FixInvalidFileName(FolderEntry.name);
            LogoManager_NrLogos++;
          }
          TAP_Hdd_FindNext(&FolderEntry);
        }
      }
    }
  }
  if(LogoManager_CB) LogoManager_CB(3, LogoManager_NrLogos);


  //Step 3: build the basic cache file
  LogosConverted = 0;
  if(LogoManager_LogoData) TAP_MemFree(LogoManager_LogoData);
  LogoManager_LogoData = TAP_MemAlloc(LogoManager_NrLogos * sizeof(tLogoData));
  if(LogoManager_LogoData)
  {
    memset(LogoManager_LogoData, 0, LogoManager_NrLogos * sizeof(tLogoData));
    HDD_ChangeDir(LOGOROOT);
    if(!TAP_Hdd_Exist(LOGOCACHE)) TAP_Hdd_Create(LOGOCACHE, ATTR_NORMAL);
    f = TAP_Hdd_Fopen(LOGOCACHE);
    if(f)
    {
      strcpy(ID, LOGOCACHEID);
      Version = LOGOCACHEVERSION;

      TAP_Hdd_Fwrite(ID, 4, 1, f);
      TAP_Hdd_Fwrite(&Version, sizeof(dword), 1, f);
      TAP_Hdd_Fwrite(&LogoManager_NrLogos, sizeof(dword), 1, f);
      TAP_Hdd_Fwrite(LogoManager_LogoData, sizeof(tLogoData), LogoManager_NrLogos, f);

      //Step 4: iterate through all directories again, compress the data and save it to the cache
      LogoIndex = 0;
      for(i = LGST_3pgstyle; i < LGST_NRITEMS; i++)
      {
        for(j = LGAR_43; j < LGAR_NRITEMS; j++)
        {
          if(HDD_ChangeDir(LogoManager_GetDirectory(i, j, LogoPath)))
          {
            NrFiles = TAP_Hdd_FindFirst(&FolderEntry, "qtl|qsl|ibl");
            for(k = 0; k < NrFiles; k++)
            {
              if(LogoManager_CB) LogoManager_CB(2, LogosConverted * 100 / LogoManager_NrLogos);

              if(FolderEntry.attr == ATTR_NORMAL)
              {
                LogoManager_LogoData[LogoIndex].ChannelID = 0;
                strncpy(LogoManager_LogoData[LogoIndex].LogoName, FolderEntry.name, MAXLOGONAME);
                LogoManager_LogoData[LogoIndex].LogoName[MAXLOGONAME] = '\0';
                LogoManager_LogoData[LogoIndex].LogoName[strlen(LogoManager_LogoData[LogoIndex].LogoName) - 4] = '\0';
                LogoManager_LogoData[LogoIndex].Style  = i;

                if(StringEndsWith(FolderEntry.name, ".qtl")) LogoManager_LogoData[LogoIndex].Size = LGSZ_qtl;
                if(StringEndsWith(FolderEntry.name, ".qsl")) LogoManager_LogoData[LogoIndex].Size = LGSZ_qsl;
                if(StringEndsWith(FolderEntry.name, ".ibl")) LogoManager_LogoData[LogoIndex].Size = LGSZ_ibl;

                LogoManager_LogoData[LogoIndex].Aspect = j;
                LogoManager_LogoData[LogoIndex].grData = NULL;

                fLogo = TAP_Hdd_Fopen(FolderEntry.name);
                if(fLogo)
                {
                  BufferSize = TAP_Hdd_Flen(fLogo) - 8;
                  PixelData = TAP_MemAlloc(BufferSize + 8);
                  TempBuffer = TAP_MemAlloc(sizeof(TYPE_GrData) + BufferSize);
                  if(PixelData && TempBuffer)
                  {
                    TAP_Hdd_Fread(PixelData, BufferSize + 8, 1, fLogo);
                    CompressedSize = CompressTFD(&PixelData[8], BufferSize, &TempBuffer[sizeof(TYPE_GrData)], 0x0001, 0xffff, NULL);
                    TAP_Put16bit(&TempBuffer[sizeof(TYPE_GrData) + 0x0e], 0xffff);

                    grData = (TYPE_GrData*)TempBuffer;
                    grData->version        = 1;
                    grData->reserved       = 0;
                    grData->dataFormat     = OSD_1555;
                    grData->compessMethod  = COMPRESS_Tfp;
                    grData->data           = NULL;
                    grData->dataSize       = BufferSize;
                    grData->width          = TAP_Get32bit(&PixelData[0]);
                    grData->height         = TAP_Get32bit(&PixelData[4]);

                    LogoManager_LogoData[LogoIndex].CachePosition = TAP_Hdd_Ftell(f);
                    LogoManager_LogoData[LogoIndex].grDataSize    = sizeof(TYPE_GrData) + CompressedSize;
                    TAP_Hdd_Fwrite(grData, LogoManager_LogoData[LogoIndex].grDataSize, 1, f);
                    LogoIndex++;
                  }
                  if(PixelData) TAP_MemFree(PixelData);
                  if(TempBuffer) TAP_MemFree(TempBuffer);
                  TAP_Hdd_Fclose(fLogo);
                }
                else
                {
                  if(LogoManager_CB) LogoManager_CB(-1, 2);
                }
                LogosConverted++;
              }
              TAP_Hdd_FindNext(&FolderEntry);
            }
          }
        }
      }

      //Step 5: if the LIL exists, read and update the ChannelID of all Logos

      //Step 6: rewrite the cache structure to update all pointers
      TAP_Hdd_Fseek(f, sizeof(ID) + sizeof(dword) + sizeof(dword), SEEK_SET);
      TAP_Hdd_Fwrite(LogoManager_LogoData, sizeof(tLogoData), LogoManager_NrLogos, f);
      TAP_Hdd_Fclose(f);
    }
  }
  HDD_TAP_PopDir();
  if(LogoManager_CB) LogoManager_CB(4, 0);

  TRACEEXIT();
}
コード例 #8
0
ファイル: file.c プロジェクト: BackupTheBerlios/tap-svn
int remove(char *name)
{
	TAP_Hdd_Delete(name);
	return 0;
}