本文整理汇总了C++中ChildProcess::waitForProcessToFinish方法的典型用法代码示例。如果您正苦于以下问题:C++ ChildProcess::waitForProcessToFinish方法的具体用法?C++ ChildProcess::waitForProcessToFinish怎么用?C++ ChildProcess::waitForProcessToFinish使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ChildProcess
的用法示例。
在下文中一共展示了ChildProcess::waitForProcessToFinish方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: finish
void finish (bool shouldKill)
{
String result;
Array<URL> selection;
if (shouldKill)
child.kill();
else
result = child.readAllProcessOutput().trim();
if (result.isNotEmpty())
{
StringArray tokens;
if (selectMultipleFiles)
tokens.addTokens (result, separator, "\"");
else
tokens.add (result);
for (auto& token : tokens)
selection.add (URL (File::getCurrentWorkingDirectory().getChildFile (token)));
}
if (! shouldKill)
{
child.waitForProcessToFinish (60 * 1000);
owner.finished (selection);
}
}
示例2: startOrFocusApp
void AppsPageComponent::startOrFocusApp(AppIconButton* appButton) {
if (debounce) return;
bool shouldStart = true;
int appIdx = runningAppsByButton[appButton];
bool hasLaunched = runningApps[appIdx] != nullptr;
String windowId;
if(hasLaunched) {
const auto shellWords = split(appButton->shell, " ");
const auto& cmdName = shellWords[0];
StringArray findCmd{"xdotool", "search", "--all", "--limit", "1", "--class", cmdName.toRawUTF8()};
ChildProcess findWindow;
findWindow.start(findCmd);
findWindow.waitForProcessToFinish(1000);
windowId = findWindow.readAllProcessOutput().trimEnd();
// does xdotool find a window id? if so, we shouldn't start a new one
shouldStart = (windowId.length() > 0) ? false : true;
}
if (shouldStart) {
startApp(appButton);
}
else {
focusApp(appButton, windowId);
}
};
示例3: exeIsAvailable
static bool exeIsAvailable (const char* const executable)
{
ChildProcess child;
const bool ok = child.start ("which " + String (executable))
&& child.readAllProcessOutput().trim().isNotEmpty();
child.waitForProcessToFinish (60 * 1000);
return ok;
}
示例4: isPlatformDialogAvailable
bool FileChooser::isPlatformDialogAvailable()
{
ChildProcess child;
const bool ok = child.start ("which zenity")
&& child.readAllProcessOutput().trim().isNotEmpty();
child.waitForProcessToFinish (60 * 1000);
return ok;
}
示例5: runLameChildProcess
bool runLameChildProcess (const TemporaryFile& tempMP3, const StringArray& processArgs) const
{
ChildProcess cp;
if (cp.start (processArgs))
{
const String childOutput (cp.readAllProcessOutput());
DBG (childOutput); ignoreUnused (childOutput);
cp.waitForProcessToFinish (10000);
return tempMP3.getFile().getSize() > 0;
}
return false;
}
示例6: showPlatformDialog
void FileChooser::showPlatformDialog (Array<File>& results,
const String& title,
const File& file,
const String& filters,
bool isDirectory,
bool selectsFiles,
bool isSave,
bool warnAboutOverwritingExistingFiles,
bool selectMultipleFiles,
FilePreviewComponent* previewComponent)
{
const String separator (":");
String command ("zenity --file-selection");
if (title.isNotEmpty()) command << " --title=\"" << title << "\"";
if (file != File::nonexistent) command << " --filename=\"" << file.getFullPathName () << "\"";
if (isDirectory) command << " --directory";
if (isSave) command << " --save";
if (selectMultipleFiles) command << " --multiple --separator=" << separator;
command << " 2>&1";
ChildProcess child;
if (child.start (command))
{
const String result (child.readAllProcessOutput().trim());
if (result.isNotEmpty())
{
StringArray tokens;
if (selectMultipleFiles)
tokens.addTokens (result, separator, "\"");
else
tokens.add (result);
for (int i = 0; i < tokens.size(); i++)
results.add (File (tokens[i]));
}
child.waitForProcessToFinish (60 * 1000);
}
}
示例7: showPlatformDialog
void FileChooser::showPlatformDialog (Array<File>& results,
const String& title, const File& file, const String& filters,
bool isDirectory, bool /* selectsFiles */,
bool isSave, bool /* warnAboutOverwritingExistingFiles */,
bool selectMultipleFiles, FilePreviewComponent*)
{
const File previousWorkingDirectory (File::getCurrentWorkingDirectory());
StringArray args;
String separator;
// use kdialog for KDE sessions or if zenity is missing
if (exeIsAvailable ("kdialog") && (isKdeFullSession() || ! exeIsAvailable ("zenity")))
addKDialogArgs (args, separator, title, file, filters, isDirectory, isSave, selectMultipleFiles);
else
addZenityArgs (args, separator, title, file, filters, isDirectory, isSave, selectMultipleFiles);
args.add ("2>/dev/null"); // (to avoid logging info ending up in the results)
ChildProcess child;
if (child.start (args, ChildProcess::wantStdOut))
{
const String result (child.readAllProcessOutput().trim());
if (result.isNotEmpty())
{
StringArray tokens;
if (selectMultipleFiles)
tokens.addTokens (result, separator, "\"");
else
tokens.add (result);
for (int i = 0; i < tokens.size(); ++i)
results.add (File::getCurrentWorkingDirectory().getChildFile (tokens[i]));
}
child.waitForProcessToFinish (60 * 1000);
}
previousWorkingDirectory.setAsCurrentWorkingDirectory();
}
示例8: showPlatformDialog
//.........这里部分代码省略.........
String separator;
StringArray args;
const File previousWorkingDirectory (File::getCurrentWorkingDirectory());
const bool isKdeFullSession = SystemStats::getEnvironmentVariable ("KDE_FULL_SESSION", String::empty)
.equalsIgnoreCase ("true");
if (exeIsAvailable ("kdialog") && (isKdeFullSession || ! exeIsAvailable ("zenity")))
{
// use kdialog for KDE sessions or if zenity is missing
args.add ("kdialog");
if (title.isNotEmpty())
args.add ("--title=" + title);
if (selectMultipleFiles)
{
separator = "\n";
args.add ("--multiple");
args.add ("--separate-output");
args.add ("--getopenfilename");
}
else
{
if (isSave) args.add ("--getsavefilename");
else if (isDirectory) args.add ("--getexistingdirectory");
else args.add ("--getopenfilename");
}
String startPath;
if (file.exists() || file.getParentDirectory().exists())
{
startPath = file.getFullPathName();
}
else
{
startPath = File::getSpecialLocation (File::userHomeDirectory).getFullPathName();
if (isSave)
startPath += "/" + file.getFileName();
}
args.add (startPath);
}
else
{
// zenity
args.add ("zenity");
args.add ("--file-selection");
if (title.isNotEmpty())
args.add ("--title=" + title);
if (selectMultipleFiles)
{
separator = ":";
args.add ("--multiple");
args.add ("--separator=" + separator);
}
else
{
if (isDirectory) args.add ("--directory");
if (isSave) args.add ("--save");
}
if (file.isDirectory())
file.setAsCurrentWorkingDirectory();
else if (file.getParentDirectory().exists())
file.getParentDirectory().setAsCurrentWorkingDirectory();
else
File::getSpecialLocation (File::userHomeDirectory).setAsCurrentWorkingDirectory();
if (! file.getFileName().isEmpty())
args.add ("--filename=" + file.getFileName());
}
ChildProcess child;
if (child.start (args))
{
const String result (child.readAllProcessOutput().trim());
if (result.isNotEmpty())
{
StringArray tokens;
if (selectMultipleFiles)
tokens.addTokens (result, separator, "\"");
else
tokens.add (result);
for (int i = 0; i < tokens.size(); i++)
results.add (File (tokens[i]));
}
child.waitForProcessToFinish (60 * 1000);
}
previousWorkingDirectory.setAsCurrentWorkingDirectory();
}