Exemplo n.º 1
0
Path FileMessageHandler::FindFilePath(const list<Path>& lps, const Path& f)
{
	// check the current working dir (or full path if supplied) first
	// note that if the file doesn't have a path and it is found in the
	// CWD, the CWD is not returned as part of the path.
	if(CheckIfFileExists(f) == true)
		return f;

	// if the path is absolute there's no point in checking the include paths;
	// given it wasn't found above we can just return an empty path
	if(f.HasVolume() == true)
		return Path();

	Path path(f);

	for(list<Path>::const_iterator i(lps.begin()); i != lps.end(); i++)
	{
		Path path (*i, f);

		if(CheckIfFileExists(path) == true)
			return path;
	}

	// not found so return empty path
	return Path();
}
Exemplo n.º 2
0
void FontTests::TestLongFontNameScenario()
{
    wistd::unique_ptr<wchar_t[]> expandedLongFontPath;
    VERIFY_SUCCEEDED(ExpandPathToMutable(pwszLongFontPath, expandedLongFontPath));
    if (!CheckIfFileExists(expandedLongFontPath.get()))
    {
        Log::Comment(L"Lucida Sans Typewriter doesn't exist; skipping long font test.");
        Log::Result(WEX::Logging::TestResults::Result::Skipped);
        return;
    }

    const HANDLE hConsoleOutput = GetStdOutputHandle();

    CONSOLE_FONT_INFOEX cfieSetLong = { 0 };
    cfieSetLong.cbSize = sizeof(cfieSetLong);
    cfieSetLong.FontFamily = 54;
    cfieSetLong.dwFontSize.Y = 12;
    VERIFY_SUCCEEDED(StringCchCopy(cfieSetLong.FaceName, ARRAYSIZE(cfieSetLong.FaceName), L"Lucida Sans Typewriter"));

    VERIFY_WIN32_BOOL_SUCCEEDED(OneCoreDelay::SetCurrentConsoleFontEx(hConsoleOutput, FALSE, &cfieSetLong));

    CONSOLE_FONT_INFOEX cfiePostLong = { 0 };
    cfiePostLong.cbSize = sizeof(cfiePostLong);
    VERIFY_WIN32_BOOL_SUCCEEDED(OneCoreDelay::GetCurrentConsoleFontEx(hConsoleOutput, FALSE, &cfiePostLong));

    Log::Comment(NoThrowString().Format(L"%ls %ls", cfieSetLong.FaceName, cfiePostLong.FaceName));

    VERIFY_ARE_EQUAL(0, NoThrowString(cfieSetLong.FaceName).CompareNoCase(cfiePostLong.FaceName));
}
Exemplo n.º 3
0
int main( int argc, char* argv[] )
{
  // pull out the JSON file and JavaScript file from the command line arguments
  std::string javaScriptFileName;
  std::string jSONFileName;

  for( int i = 1 ; i < argc ; ++i )
  {
    std::string arg( argv[i] );

    size_t idx = std::string::npos;

    idx = arg.find( ".json" );
    if( idx != std::string::npos )
    {
      jSONFileName = arg;
    }
    else
    {
      idx = arg.find( ".js" );
      if( idx != std::string::npos )
      {
        javaScriptFileName = arg;
      }
    }
  }

  if( !jSONFileName.empty() )
  {
    bool exists = CheckIfFileExists( jSONFileName );
    if( !exists )
    {
      DALI_ASSERT_ALWAYS( 0 && "JSON file not found ")
    }
  }
Exemplo n.º 4
0
static BOOL
Install(const char *driverpath)
{
	char path[300];
	WORD pathlen;
	BOOL rc;
	DWORD usagecount;

	/* first, retrieve the path the driver should be installed to
	 * in path */
	if (!SQLInstallDriverManager(path, sizeof(path), &pathlen) &&
	    ProcessSQLErrorMessages("SQLInstallDriverManager"))
		return FALSE;

	if (!CheckIfFileExists(path, "odbc32.dll")) {
		MessageBox(NULL,
			   "You must install MDAC before you can use the ODBC driver",
			   "Install",
			   MB_ICONSTOP | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND);
		SQLRemoveDriverManager(&usagecount);
		return FALSE;
	}

	rc = InstallMyDriver(driverpath);

	if (rc) {
		/* after the driver is installed create the new DSN */
		rc = AddMyDSN();
	}

	if (!rc)
		SQLRemoveDriverManager(&usagecount);

	return rc;
}
Exemplo n.º 5
0
std::string mitk::LoggingBackend::IncrementLogFileNames(const std::string &prefixPath, int numLogFiles)
{
  // delete last one
  {
    std::stringstream s;
    s << prefixPath.c_str() << "-" << numLogFiles - 1 << ".log";
    // check if the file exists
    if (CheckIfFileExists(s.str())) // if yes: delete it
    {
      int retVal = ::remove(s.str().c_str());
      if (retVal != 0)
      {
        mitkThrow()
          << "Problem while deleting the oldest log file. Maybe the access to this files is blocked. Aborting!";
      }
    }
  }

  // rename the others
  for (int r = numLogFiles - 1; r >= 1; r--)
  {
    std::stringstream dst;
    dst << prefixPath.c_str() << "-" << r << ".log";

    std::stringstream src;
    src << prefixPath.c_str() << "-" << r - 1 << ".log";

    // check if the source exists
    if (CheckIfFileExists(src.str())) // if yes: rename it
    {
      int retVal = ::rename(src.str().c_str(), dst.str().c_str());
      if (retVal != 0)
      {
        mitkThrow() << "Problem while renaming the log files. Maybe the access to this files is blocked. Aborting!";
      }
    }
  }

  // create new empty name and return it
  {
    std::stringstream s;
    s << prefixPath.c_str() << "-0.log";
    return s.str();
  }
}