Exemplo n.º 1
0
JBoolean
SyGExec
	(
	const JCharacter*	cmd,
	const JBoolean		report
	)
{
	JString errOutput;
	const JError err = JRunProgram(cmd, &errOutput);
	if (!err.OK() && report)
		{
		(JGetUserNotification())->ReportError(err.GetMessage());
		}
	return err.OK();
}
Exemplo n.º 2
0
JError
JUncompressFile
	(
	const JCharacter*	origFileName,
	JString*			newFileName,
	const JCharacter*	dirName,
	JProcess**			process
	)
{
	// generate a file name if one is not provided

	if (newFileName->IsEmpty())
		{
		const JError err = JCreateTempFile(dirName, NULL, newFileName);
		if (!err.OK())
			{
			return err;
			}
		}
	else if (!JStringEmpty(dirName))
		{
		*newFileName = JCombinePathAndName(dirName, *newFileName);
		}

	// construct the command

	JString cmd = "gunzip --to-stdout ";
	cmd += JPrepArgForExec(origFileName);
	cmd += " >| ";
	cmd += JPrepArgForExec(*newFileName);

	cmd = "/bin/sh -c " + JPrepArgForExec(cmd);

	// run the command

	if (process != NULL)
		{
		return JProcess::Create(process, cmd);
		}
	else
		{
		JString errText;
		return JRunProgram(cmd, &errText);
		}
}