Merge branch '2123_crash_while_copy'
[midnight-commander.git] / src / clipboard.c
blob7de7a60f19c677c4e8b85f60c32290b03abd16bf
1 /*
2 Util for external clipboard.
4 Copyright (C) 2009 The Free Software Foundation, Inc.
6 Written by:
7 Ilia Maslakon <il.smind@gmail.com>, 2010.
9 This file is part of the Midnight Commander.
11 The Midnight Commander is free software; you can redistribute it
12 and/or modify it under the terms of the GNU General Public License as
13 published by the Free Software Foundation; either version 2 of the
14 License, or (at your option) any later version.
16 The Midnight Commander is distributed in the hope that it will be
17 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
18 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
24 MA 02110-1301, USA.
27 #include <config.h>
29 #include <stdio.h>
30 #include <stdlib.h>
32 #include "lib/global.h"
33 #include "lib/fileloc.h"
35 #include "main.h"
36 #include "src/execute.h"
38 #include "clipboard.h"
40 gboolean
41 copy_file_to_ext_clip (void)
43 char *tmp, *cmd;
44 int res = 0;
45 const char *d = getenv ("DISPLAY");
47 if (d == NULL || clipbord_store_path == NULL || clipbord_store_path[0] =='\0')
48 return FALSE;
50 tmp = concat_dir_and_file (home_dir, EDIT_CLIP_FILE);
51 cmd = g_strconcat (clipbord_store_path, " ", tmp, " 2>/dev/null", (char *) NULL);
53 if (cmd != NULL)
54 res = my_system (EXECUTE_AS_SHELL, shell, cmd);
56 g_free (cmd);
57 g_free (tmp);
58 return TRUE;
61 gboolean
62 paste_to_file_from_ext_clip (void)
64 char *tmp, *cmd;
65 int res = 0;
66 const char *d = getenv ("DISPLAY");
68 if (d == NULL || clipbord_paste_path == NULL || clipbord_paste_path[0] == '\0')
69 return FALSE;
71 tmp = concat_dir_and_file (home_dir, EDIT_CLIP_FILE);
72 cmd = g_strconcat (clipbord_paste_path, " > ", tmp, " 2>/dev/null", (char *) NULL);
74 if (cmd != NULL)
75 res = my_system (EXECUTE_AS_SHELL, shell, cmd);
77 g_free (cmd);
78 g_free (tmp);
79 return TRUE;