create .config/autostart if necessary

This commit is contained in:
Jean-Francois Dockes 2012-03-19 16:15:26 +01:00
parent f245b21cfa
commit 8ff5d624df

View File

@ -104,6 +104,13 @@ void RTIToolW::accept()
if (text.empty())
text = desktopfiletext;
// Try to create .config and autostart anyway. If they exists this will
// do nothing. An error will be detected when we try to create the file
string dir = path_cat(path_home(), ".config");
mkdir(dir.c_str(), 0700);
dir = path_cat(dir, "autostart");
mkdir(dir.c_str(), 0700);
int fd = ::open(autostartfile.c_str(), O_WRONLY|O_CREAT, 0644);
if (fd < 0 || ::write(fd, text.c_str(), size_t(text.size()))
!= ssize_t(text.size()) || ::close(fd) != 0) {