예제 #1
0
int main(int argc, char **argv)
{
    char textName[MAXPATH];
    char symbName[MAXPATH];
    fpstream* helpStrm;

    // Banner messages
    char initialText[] = "Help Compiler  Version 1.0  Copyright (c) 1991"
                         " Borland International.\n";
    char helpText[] =
       "\n  Syntax  TVHC <Help text>[.TXT] [<Help file>[.HLP] [<Symbol file>[.H]]\n"
       "\n"
       "     Help text   = Help file source\n"
       "     Help file   = Compiled help file\n"
       "     Symbol file = An include file containing all the screen names as const's\n";

    char bufStr[MAXSTRSIZE];

    cout << initialText;
    if (argc < 2)
        {
        cout << helpText;
        exit(1); 
        }

    //  Calculate file names
    strcpy(textName,replaceExt(argv[1], ".TXT", False));
    if (!fExists(textName))
        {
        strcpy(bufStr,"File ");
        strcat(bufStr,textName);
        strcat(bufStr," not found.");
        error(bufStr);
        }

    if (argc >= 3)
        strcpy(helpName, replaceExt(argv[2], ".HLP", False));
    else
        strcpy(helpName, replaceExt(textName, ".HLP",  True));

    checkOverwrite( helpName );

    if (argc >= 4)
        strcpy(symbName, replaceExt(argv[3], ".H", False));
    else
        strcpy(symbName, replaceExt(helpName, ".H", True));

    checkOverwrite( symbName );

    TProtectedStream textStrm(textName, ios::in);
    TProtectedStream symbStrm(symbName, ios::out);

    helpStrm =  new fpstream(helpName, ios::out|ios::binary);
    processText(textStrm, *helpStrm, symbStrm);
    return 0;
}
예제 #2
0
bool MainWindow::saveCurrentFileAs()
{
  QString location = ":gpteditor";
  KURL url = KFileDialog::getSaveURL(location, QString::null, this);

  if(!url.isEmpty() && checkOverwrite(url))
  {
    if(m_tabEditor->saveCurrentFileAs(url))
    {
      return true;
    }
  }
  return false;
}
예제 #3
0
/** copy file \p sourceFile to \p destFile. If \p force is false, the user
 *  will be asked before existing files are overwritten. If \p only_tmp
 *  is true, then only copy files that are in our tmp dir (to avoid other files
 *  overwriting themselves).
 *  \return
 *  - SUCCESS if this file got copied
 *  - FORCE   if subsequent calls should not ask for confirmation before
 *            overwriting files anymore.
 *  - CANCEL  if the export should be cancelled
 */
CopyStatus copyFile(string const & format,
		    FileName const & sourceFile, FileName const & destFile,
		    string const & latexFile, bool force, bool only_tmp)
{
	CopyStatus ret = force ? FORCE : SUCCESS;

	// This check could be changed to
	// boost::filesystem::equivalent(sourceFile, destFile) if export to
	// other directories than the document directory is desired.
	// Also don't overwrite files that already exist and are identical
	// to the source files.
	if ((only_tmp && !prefixIs(onlyPath(sourceFile.absFileName()), package().temp_dir().absFileName()))
	    || sourceFile.checksum() == destFile.checksum())
		return ret;

	if (!force) {
		switch(checkOverwrite(destFile)) {
		case 0:
			return SUCCESS;
		case 1:
			ret = SUCCESS;
			break;
		case 2:
			ret = FORCE;
			break;
		default:
			return CANCEL;
		}
	}

	Mover const & mover = getMover(format);
	if (!mover.copy(sourceFile, destFile, latexFile))
		Alert::error(_("Couldn't copy file"),
			     bformat(_("Copying %1$s to %2$s failed."),
				     makeDisplayPath(sourceFile.absFileName()),
				     makeDisplayPath(destFile.absFileName())));

	return ret;
}