Ejemplo n.º 1
0
/* TODO */
int BfastAlignValidateInputs(struct arguments *args) {

	char *FnName="BfastAlignValidateInputs";

	/* Check if we are piping */
	if(NULL == args->readsFileName) {
		VERBOSE = -1;
	}

	if(0<=VERBOSE) {
		fprintf(stderr, BREAK_LINE);
		fprintf(stderr, "Checking input parameters supplied by the user ...\n");
	}

	if(args->fastaFileName!=0) {
		if(0<=VERBOSE) {
			fprintf(stderr, "Validating fastaFileName %s. \n",
					args->fastaFileName);
		}
		if(ValidateFileName(args->fastaFileName)==0)
			PrintError(FnName, "fastaFileName", "Command line argument", Exit, IllegalFileName);	
	}	
	else {		
		PrintError(FnName, "fastaFileName", "Required command line argument", Exit, IllegalFileName);	
	}

	if(args->readsFileName!=0) {
		if(0<=VERBOSE) {
			fprintf(stderr, "Validating readsFileName %s. \n",
					args->readsFileName);
		}
		if(ValidateFileName(args->readsFileName)==0)
			PrintError(FnName, "readsFileName", "Command line argument", Exit, IllegalFileName);	
	}	

	if(args->space != NTSpace && args->space != ColorSpace) {
		PrintError(FnName, "space", "Command line argument", Exit, OutOfRange);	
	}	
	
	if(args->numThreads<=0) {		
		PrintError(FnName, "numThreads", "Command line argument", Exit, OutOfRange);
	} 

	if(args->tmpDir!=0) {		
		if(0 <= VERBOSE) {
			fprintf(stderr, "Validating tmpDir path %s. \n", 
					args->tmpDir);
		}
		if(ValidatePath(args->tmpDir)==0)
			PrintError(FnName, "tmpDir", "Command line argument", Exit, IllegalPath);	
	}	
	/* If this does not hold, we have done something wrong internally */	
	assert(args->timing == 0 || args->timing == 1);

	return 1;
}
Ejemplo n.º 2
0
bool Feed::Download(int index) {
  if (category != FEED_CATEGORY_LINK)
    return false;
  
  DWORD dwMode = HTTP_Feed_Download;
  if (index == -1) {
    for (size_t i = 0; i < items.size(); i++) {
      if (items[i].state == FEEDITEM_SELECTED) {
        dwMode = HTTP_Feed_DownloadAll;
        index = i;
        break;
      }
    }
  }
  if (index < 0 || index > static_cast<int>(items.size())) return false;
  download_index = index;

  MainDialog.ChangeStatus(L"Downloading \"" + items[index].title + L"\"...");
  TorrentDialog.EnableInput(false);
  
  wstring file = items[index].title + L".torrent";
  ValidateFileName(file);
  file = GetDataPath() + file;

  return client.Get(win32::Url(items[index].link), file, dwMode, 
                    reinterpret_cast<LPARAM>(this));
}
Ejemplo n.º 3
0
bool ValidateDirectory (std::wstring& aName, const bool aMustExist)
	{
	if (! ValidateFileName (aName, aMustExist)) 
		{
		return false;
		}
	if (aName.at (aName.size () - 1) != L'/') 
		{
		aName += L'/';
		}
	return true;
	}
Ejemplo n.º 4
0
bool ValidateFileName (std::wstring& aName, const bool aMustExist, const std::wstring& aDefaultExtension)
	{
	assert (! aName.empty ());
	assert (! aDefaultExtension.empty ());
	std::wstring filename (aName);
	EnsureExtended (filename, aDefaultExtension);
	if (! ValidateFileName (filename, aMustExist)) 
		{
		return false;
		}
	aName = filename;
	return true;
	}
Ejemplo n.º 5
0
/* TODO */
int BfastFasta2BRGValidateInputs(struct arguments *args) {

	char *FnName="BfastFasta2BRGValidateInputs";

	fprintf(stderr, BREAK_LINE);
	fprintf(stderr, "Checking input parameters supplied by the user ...\n");

	if(args->fastaFileName!=0) {
		fprintf(stderr, "Validating fastaFileName %s. \n",
				args->fastaFileName);
		if(ValidateFileName(args->fastaFileName)==0)
			PrintError(FnName, "fastaFileName", "Command line argument", Exit, IllegalFileName);	
	}	
	else {		
		PrintError(FnName, "fastaFileName", "Required command line argument", Exit, IllegalFileName);	
	}

	if(args->space != NTSpace && args->space != ColorSpace) {
		PrintError(FnName, "space", "Command line argument", Exit, OutOfRange);	
	}	
	assert(args->timing == 0 || args->timing == 1);
	return 1;
}
Ejemplo n.º 6
0
string GetInputFileName(string prompt)
{
	string temp = "";
	bool validFileName = true;
	do{
		cin.clear();

		//Prompt the user to enter a value.
		cout << prompt;
		//place the value in string temp
		getline(cin, temp);

		//check to see if CTRL-Z has been pressed
		if (cin.eof()){
			throw IOException(ERROR_EOF, EXIT);
			cin.clear();
			return 0;
		}

		validFileName = ValidateFileName(temp);

	} while (!validFileName);//end while loop
	return temp;
}
Ejemplo n.º 7
0
BOOL CALLBACK
FileNamesDialogProc(
    HWND    hdlg,
    UINT    uMessage,
    WPARAM  wParam,
    LPARAM  lParam
    )
{
    static BOOL IgnoreChange = FALSE;

    switch (uMessage) {
        case WM_INITDIALOG:
            CenterWindow( GetParent( hdlg ), hwndFrame );
            break;

        case WM_COMMAND:
            if (HIWORD(wParam) == EN_CHANGE && (!IgnoreChange)) {
                SendMessage( GetParent(hdlg), PSM_CHANGED, (LPARAM)hdlg, 0 );
            }
            break;

        case WM_NOTIFY:
            switch (((LPNMHDR)lParam)->code) {
                case PSN_SETACTIVE:
                    IgnoreChange = TRUE;
                    SetDlgItemText( hdlg, IDC_LOG_FILE_NAME,   ApiMonOptions.LogFileName   );
                    SetDlgItemText( hdlg, IDC_TRACE_FILE_NAME, ApiMonOptions.TraceFileName );
                    SetDlgItemText( hdlg, IDC_SYMBOL_PATH,     ApiMonOptions.SymbolPath    );
                    IgnoreChange = FALSE;
                    break;

                case PSN_KILLACTIVE:
                    {
                        DWORD rslt = 0;
                        if (!ValidateFileName( hdlg, IDC_LOG_FILE_NAME )) {
                            PopUpMsg( "Invalid log file name" );
                            rslt = 1;
                        }
                        if (!ValidateFileName( hdlg, IDC_TRACE_FILE_NAME )) {
                            PopUpMsg( "Invalid trace file name" );
                            rslt = 1;
                        }
                        if (!ValidatePathName( hdlg, IDC_SYMBOL_PATH )) {
                            PopUpMsg( "Invalid symbol path" );
                            rslt = 1;
                        }
                        SetWindowLong( hdlg, DWL_MSGRESULT, rslt );
                    }
                    break;

                case PSN_APPLY:
                    GetDlgItemText( hdlg, IDC_LOG_FILE_NAME,   ApiMonOptions.LogFileName,   sizeof(ApiMonOptions.LogFileName)   );
                    GetDlgItemText( hdlg, IDC_TRACE_FILE_NAME, ApiMonOptions.TraceFileName, sizeof(ApiMonOptions.TraceFileName) );
                    GetDlgItemText( hdlg, IDC_SYMBOL_PATH,     ApiMonOptions.SymbolPath,    sizeof(ApiMonOptions.SymbolPath)    );
                    SaveOptions();
                    SendMessage( GetParent(hdlg), PSM_UNCHANGED, (LPARAM)hdlg, 0 );
                    SetWindowLong( hdlg, DWL_MSGRESULT, 0 );
                    break;
            }
            break;

        case WM_HELP:
            {
                LPHELPINFO hi = (LPHELPINFO)lParam;
                ProcessHelpRequest( hdlg, hi->iCtrlId );
            }
            break;
    }
    return FALSE;
}
Ejemplo n.º 8
0
HRESULT CreateCaptureGraph()
{
    char  szFilename[264];
    WCHAR wszFilename[264];
    HRESULT hr=NOERROR;
    IBaseFilter *pFileWriter=NULL;
    IBaseFilter *pTee=NULL;
    IFileSinkFilter *pFileSink=NULL;

    if (gCaptureAudioOnly)
        {
        hr=RebuildGraph();
        if (FAILED(hr))
            return(hr);

        hr=CreateAudioOnlyPreviewGraph();
        if (FAILED(hr))
            return(hr);
        hr=CreateAudioOnlyCaptureGraph();
        return(hr);
        }

    if (!gRecNoPreview)
        {
        hr=CreatePreviewGraph();
        if (FAILED(hr))
            return(hr);
        }
    else
        {
        hr=RebuildGraph();
        if (FAILED(hr))
            return(hr);
        }

    ZeroMemory(wszFilename,sizeof(wszFilename));

    if (lstrlen(gszDestinationFile)==0)
        lstrcpy(gszDestinationFile, "DBOXIICapture");
    
    ValidateFileName(gszDestinationFile);

    _makepath(szFilename, NULL, gszDestinationFolder, gszDestinationFile, "mpg" );

    MakeUniqueFileName(szFilename);

    MultiByteToWideChar(CP_ACP, 
                        0, 
                        szFilename, 
                        lstrlen(szFilename),
                        wszFilename,  
                        264);

    hr=LoadFilterByCLSID(gpIGraphBuilder, CLSID_RAWWriter, &pFileWriter, L"FileWriter");
    if (SUCCEEDED(hr))
        hr=pFileWriter->QueryInterface(IID_IFileSinkFilter, (void **)&pFileSink);
    if (SUCCEEDED(hr))
        hr=pFileSink->SetFileName(wszFilename,NULL);

    if (!gRecNoPreview)
        {
        if (SUCCEEDED(hr))
            hr=gpIGraphBuilder->FindFilterByName(L"InfTee", &pTee);
        if (SUCCEEDED(hr))
            hr=TryConnectingFilters(gpIGraphBuilder, pTee, 1, pFileWriter, 0, TRUE);
        }
    else
        {
        hr=TryConnectingFilters(gpIGraphBuilder, gpVCap, 2, pFileWriter, 0, TRUE);
        }

	RELEASE(pFileSink);
    RELEASE(pTee);
    RELEASE(pFileWriter);

    return(hr);
}
Ejemplo n.º 9
0
HRESULT CreateAudioOnlyCaptureGraph()
{
    HRESULT hr=NOERROR;
    char  szFilename[264];
    IBaseFilter *pFileWriter=NULL;
    IBaseFilter *pTee=NULL;
    IFileSinkFilter *pFileSink=NULL;
    IWaveToMPA *pIWaveToMPA=NULL;
    IWaveToMP3 *pIWaveToMP3=NULL;
    IBaseFilter *pMPEGAudioEncoder=NULL;
    WCHAR wszFilename[264];

    ZeroMemory(wszFilename,sizeof(wszFilename));

    if (lstrlen(gszDestinationFile)==0)
        lstrcpy(gszDestinationFile, "DBOXIICapture");
    
    ValidateFileName(gszDestinationFile);

    if (!gTranscodeAudio)
        _makepath(szFilename, NULL, gszDestinationFolder, gszDestinationFile, "mpa" );
    else
        {
        if (gTranscodeAudioFormat==AUDIO_PCM)
            _makepath(szFilename, NULL, gszDestinationFolder, gszDestinationFile, "wav" );
        else
            _makepath(szFilename, NULL, gszDestinationFolder, gszDestinationFile, "mpa" );
        }

    MakeUniqueFileName(szFilename);

    MultiByteToWideChar(CP_ACP, 
                        0, 
                        szFilename, 
                        lstrlen(szFilename),
                        wszFilename,  
                        264);

    if (!gTranscodeAudio)
        {
        hr=LoadFilterByCLSID(gpIGraphBuilder, CLSID_RAWWriter, &pFileWriter, L"FileWriter");
        if (SUCCEEDED(hr))
            hr=pFileWriter->QueryInterface(IID_IFileSinkFilter, (void **)&pFileSink);
        if (SUCCEEDED(hr))
            hr=pFileSink->SetFileName(wszFilename,NULL);

        if (SUCCEEDED(hr))
            hr=gpIGraphBuilder->FindFilterByName(L"InfTee", &pTee);

        if (gRecNoPreview)
            {
            if (SUCCEEDED(hr))
                hr=TryConnectingFilters(gpIGraphBuilder, pTee, 0, pFileWriter, 0, TRUE);
            }
        else
            {
            if (SUCCEEDED(hr))
                hr=TryConnectingFilters(gpIGraphBuilder, pTee, 1, pFileWriter, 0, TRUE);
            }
        }
    else
        {
        if (gTranscodeAudioFormat==AUDIO_PCM)
            {
            hr=LoadFilterByCLSID(gpIGraphBuilder, CLSID_WaveOut, &pFileWriter, L"FileWriter");
            if (SUCCEEDED(hr))
                hr=pFileWriter->QueryInterface(IID_IFileSinkFilter, (void **)&pFileSink);
            if (SUCCEEDED(hr))
                hr=pFileSink->SetFileName(wszFilename,NULL);

            if (SUCCEEDED(hr))
                hr=gpIGraphBuilder->FindFilterByName(L"InfTee", &pTee);
            if (SUCCEEDED(hr))
                hr=TryConnectingFilters(gpIGraphBuilder, pTee, 1, pFileWriter, 0, TRUE);
            }
        else
        if (gTranscodeAudioFormat==AUDIO_MPEG1L2)
            {
            hr=LoadFilterByCLSID(gpIGraphBuilder, CLSID_WaveToMPA, &pMPEGAudioEncoder, L"MPEGAudioEncoder");
            if (SUCCEEDED(hr))
                hr=pMPEGAudioEncoder->QueryInterface(IID_WaveToMPA, (void **)&pIWaveToMPA);
            if (SUCCEEDED(hr))
                hr=pIWaveToMPA->setParameter(CMD_BITRATE, gTranscodeAudioBitRate);

            if (SUCCEEDED(hr))
                hr=gpIGraphBuilder->FindFilterByName(L"InfTee", &pTee);
            if (SUCCEEDED(hr))
                hr=TryConnectingFilters(gpIGraphBuilder, pTee, 1, pMPEGAudioEncoder, 0, TRUE);

            if (SUCCEEDED(hr))
                hr=LoadFilterByCLSID(gpIGraphBuilder, CLSID_RAWWriter, &pFileWriter, L"FileWriter");
            if (SUCCEEDED(hr))
                hr=pFileWriter->QueryInterface(IID_IFileSinkFilter, (void **)&pFileSink);
            if (SUCCEEDED(hr))
                hr=pFileSink->SetFileName(wszFilename,NULL);
            if (SUCCEEDED(hr))
                hr=TryConnectingFilters(gpIGraphBuilder, pMPEGAudioEncoder, 0, pFileWriter, 0, TRUE);
            }
        else
        if (gTranscodeAudioFormat==AUDIO_MPEG1L3)
            {
            hr=LoadFilterByCLSID(gpIGraphBuilder, CLSID_WaveToMP3, &pMPEGAudioEncoder, L"MPEGAudioEncoder");
            if (SUCCEEDED(hr))
                hr=pMPEGAudioEncoder->QueryInterface(IID_WaveToMP3, (void **)&pIWaveToMP3);
            if (SUCCEEDED(hr))
                hr=pIWaveToMP3->setParameter(CMD_BITRATE, gTranscodeAudioBitRate);

            if (SUCCEEDED(hr))
                hr=gpIGraphBuilder->FindFilterByName(L"InfTee", &pTee);
            if (SUCCEEDED(hr))
                hr=TryConnectingFilters(gpIGraphBuilder, pTee, 1, pMPEGAudioEncoder, 0, TRUE);

            if (SUCCEEDED(hr))
                hr=LoadFilterByCLSID(gpIGraphBuilder, CLSID_RAWWriter, &pFileWriter, L"FileWriter");
            if (SUCCEEDED(hr))
                hr=pFileWriter->QueryInterface(IID_IFileSinkFilter, (void **)&pFileSink);
            if (SUCCEEDED(hr))
                hr=pFileSink->SetFileName(wszFilename,NULL);
            if (SUCCEEDED(hr))
                hr=TryConnectingFilters(gpIGraphBuilder, pMPEGAudioEncoder, 0, pFileWriter, 0, TRUE);
            }
        }


    RELEASE(pIWaveToMPA);
    RELEASE(pIWaveToMP3);
    RELEASE(pMPEGAudioEncoder);

    RELEASE(pFileSink);
    RELEASE(pTee);
    RELEASE(pFileWriter);

    return(hr);
}