Rivendellaudio/lib/rdtextfile.cpp
Deltec Enterprises 4a3106c8dc
Master (#6)
* Fixed bug where wrong ID was used for local maintenance

* Updated ChangeLog

* Added ability to run macros from cart list with "Run Macro" button

* Updated ChangeLog

* Updated translations

* 2018-10-18 Fred Gleason <fredg@paravelsystems.com>
	* Tweaked the position of buttons on the bottom row of the main
	screen of rdlibrary(1).
	* Changed the minimum size of the main screen of rdlibrary to
	850x600.

* 2018-10-18 Fred Gleason <fredg@paravelsystems.com>
	* Fixed a regression in rdmaint(8) that broke cut rehashing.

* 2018-10-19 Fred Gleason <fredg@paravelsystems.com>
	* Added code in the %post and %preun rules in 'rivendell.spec.in'
	to enable and disable the 'rivendell' service.

* 2018-10-19 Fred Gleason <fredg@paravelsystems.com>
	* Modified rdservice(8) to log errors to syslog.
	* Added an rdservice(8) man page.
	* Modified 'systemd/rivendell.service.in' to enable automatic
	start retries.

* 2018-10-19 Fred Gleason <fredg@paravelsystems.com>
	* Fixed a typo that broke generation of the rmlsend(1) man page.

* 2018-10-19 Fred Gleason <fredg@paravelsystems.com>
	* Removed 'build_win32.bat'.
	* Removed all conditional compilation based on 'WIN32'.

* 2018-10-19 Fred Gleason <fredg@paravelsystems.com>
	* Removed check for Win32 installer from 'configure.ac'.
	* Removed win32 clauses from '.pro' files.
2018-10-19 16:52:56 -07:00

61 lines
1.5 KiB
C++

// rdtextfile.cpp
//
// Spawn an external text file viewer.
//
// (C) Copyright 2002-2006,2016-2017 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <qfile.h>
#include <qmessagebox.h>
#include <q3process.h>
#include "rdconf.h"
#include "rd.h"
#include "rdtempdirectory.h"
#include <rdtextfile.h>
bool RDTextFile(const QString &data)
{
char tmpfile[256];
QString editor;
if(getenv("VISUAL")==NULL) {
editor=RD_LINUX_EDITOR;
}
else {
editor=getenv("VISUAL");
}
strcpy(tmpfile,RDTempDirectory::basePath()+"/rdreportXXXXXX");
int fd=mkstemp(tmpfile);
if(fd<0) {
QMessageBox::warning(NULL,"File Error","Unable to create temporary file");
return false;
}
write(fd,data.utf8(),data.utf8().length());
::close(fd);
if(fork()==0) {
system(editor+" "+QString(tmpfile));
unlink(tmpfile);
exit(0);
}
return true;
}