Exemple #1
0
STATICFUNC(int) MyPathNameCompare(const PathName& path1, const PathName& path2)
{
  int ret = PathName::Compare(path1, path2);

  if (ret == 0)
  {
    return 0;
  }

  string extension1 = path1.GetExtension();
  string extension2 = path2.GetExtension();

  if (extension1.empty() == extension2.empty())
  {
    // both have no extenion or both have an extension
    return ret;
  }

  PathName path11(path1);
  PathName path22(path2);

  if (extension1.empty())
  {
    path11.AppendExtension(extension2);
  }
  else
  {
    MIKTEX_ASSERT(!path22.HasExtension());
    path22.AppendExtension(extension1);
  }

  return PathName::Compare(path11, path22);
}
Exemple #2
0
MyPathNameCompare (/*[in]*/ const PathName & path1,
		   /*[in]*/ const PathName & path2)
{
  int ret = PathName::Compare(path1, path2);

  if (ret == 0)
    {
      return (0);
    }

  const char * lpszExtension1 = path1.GetExtension();
  const char * lpszExtension2 = path2.GetExtension();

  if ((lpszExtension1 == 0 && lpszExtension2 == 0)
      || (lpszExtension1 != 0 && lpszExtension2 != 0))
    {
      return (ret);
    }

  PathName path11 (path1);
  PathName path22 (path2);

  if (lpszExtension1 == 0)
    {
      path11.AppendExtension (lpszExtension2);
    }
  else
    {
      path22.AppendExtension (lpszExtension1);
    }

  return (PathName::Compare(path11, path22));
}
Exemple #3
0
bool SessionImpl::ConvertToBitmapFile(const PathName& sourceFileName, PathName& destFileName, IRunProcessCallback* callback)
{
  string ext = sourceFileName.GetExtension();

  if (ext.empty())
  {
    MIKTEX_FATAL_ERROR_2(T_("No file name extension in graphics rule."), "path", ext);
  }

  string rule;

  if (!FindGraphicsRule(ext, ".bmp", rule))
  {
    MIKTEX_FATAL_ERROR_2(T_("No conversion rule found."), "path", sourceFileName.ToString());
  }

  destFileName.SetToTempFile();
#if defined(MIKTEX_WINDOWS)
  Utils::RemoveBlanksFromPathName(destFileName);
#endif

  string commandLine;

  for (const char* lpsz = rule.c_str(); *lpsz != 0; ++lpsz)
  {
    if (*lpsz == '%')
    {
      ++lpsz;
      switch (*lpsz)
      {
      case 'i':
        commandLine += sourceFileName.GetData();
	break;
      case 'o':
        commandLine += destFileName.GetData();
	break;
      }
    }
    else
    {
      commandLine += *lpsz;
    }
  }

  bool done = Process::ExecuteSystemCommand(commandLine, nullptr, callback, nullptr);

  if (!done)
  {
    File::Delete(destFileName, { FileDeleteOption::TryHard });
  }

  return done;
}