[PATCH] [GraphWriter] Attempt to open .dot files with xdg-open/open first

Daniel Berlin dberlin at dberlin.org
Mon Apr 6 16:36:14 PDT 2015


Just to note:
If you have word/libreoffice installed on a mac, this will now open
the .dot files in that instead of say, preview (which supports it) or
graphviz :(

(Yeah, i know, i can reset the defaults for .dot files, but it
arbitrarily worked before)


On Fri, Apr 3, 2015 at 10:25 AM, Phabricator <reviews at reviews.llvm.org> wrote:
> REPOSITORY
>   rL LLVM
>
> http://reviews.llvm.org/D6534
>
> Files:
>   llvm/trunk/lib/Support/GraphWriter.cpp
>
> Index: llvm/trunk/lib/Support/GraphWriter.cpp
> ===================================================================
> --- llvm/trunk/lib/Support/GraphWriter.cpp
> +++ llvm/trunk/lib/Support/GraphWriter.cpp
> @@ -140,6 +140,29 @@
>    std::string ViewerPath;
>    GraphSession S;
>
> +#ifdef __APPLE__
> +  if (S.TryFindProgram("open", ViewerPath)) {
> +    std::vector<const char *> args;
> +    args.push_back(ViewerPath.c_str());
> +    if (wait)
> +      args.push_back("-W");
> +    args.push_back(Filename.c_str());
> +    args.push_back(nullptr);
> +    errs() << "Trying 'open' program... ";
> +    if (!ExecGraphViewer(ViewerPath, args, Filename, wait, ErrMsg))
> +      return false;
> +  }
> +#endif
> +  if (S.TryFindProgram("xdg-open", ViewerPath)) {
> +    std::vector<const char *> args;
> +    args.push_back(ViewerPath.c_str());
> +    args.push_back(Filename.c_str());
> +    args.push_back(nullptr);
> +    errs() << "Trying 'xdg-open' program... ";
> +    if (!ExecGraphViewer(ViewerPath, args, Filename, wait, ErrMsg))
> +      return false;
> +  }
> +
>    // Graphviz
>    if (S.TryFindProgram("Graphviz", ViewerPath)) {
>      std::vector<const char *> args;
>
> EMAIL PREFERENCES
>   http://reviews.llvm.org/settings/panel/emailpreferences/
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>



More information about the llvm-commits mailing list