~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to arts/builder/dirmanager.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
    /*
 
2
 
 
3
    Copyright (C) 1999 Stefan Westerfeld
 
4
                       stefan@space.twc.de
 
5
 
 
6
    This program is free software; you can redistribute it and/or modify
 
7
    it under the terms of the GNU General Public License as published by
 
8
    the Free Software Foundation; either version 2 of the License, or
 
9
    (at your option) any later version.
 
10
 
 
11
    This program is distributed in the hope that it will be useful,
 
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
    GNU General Public License for more details.
 
15
 
 
16
    You should have received a copy of the GNU General Public License
 
17
    along with this program; if not, write to the Free Software
 
18
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
19
 
 
20
    */
 
21
 
 
22
#include <sys/stat.h>
 
23
#include <string>
 
24
#include <kmessagebox.h>
 
25
#include <kapp.h>
 
26
#include <stdio.h>
 
27
 
 
28
#include "portablekde.h"
 
29
#include "dirmanager.h"
 
30
 
 
31
using namespace std;
 
32
 
 
33
const char *DirManager::mapDir()
 
34
{
 
35
        static char *d = 0;
 
36
 
 
37
        if(!d) d = directory("/maps",i18n("instrument map files"));
 
38
        return d;
 
39
}
 
40
 
 
41
const char *DirManager::sessionDir()
 
42
{
 
43
        static char *d = 0;
 
44
 
 
45
        if(!d) d = directory("/sessions",
 
46
                i18n("sessions (save files of the positions of all sliders/buttons)"));
 
47
 
 
48
        return d;
 
49
}
 
50
 
 
51
const char *DirManager::structureDir()
 
52
{
 
53
        static char *d = 0;
 
54
 
 
55
        if(!d) d = directory("/structures",i18n("structures (signal flow graphs)"));
 
56
        return d;
 
57
}
 
58
 
 
59
const char *DirManager::baseDir()
 
60
{
 
61
        static char *d = 0;
 
62
 
 
63
        if(!d) d = directory("",i18n("all aRts files/directories"));
 
64
        return d;
 
65
}
 
66
 
 
67
char *DirManager::directory(const char *subdir, const char *desc)
 
68
{
 
69
        const char *home = getenv("HOME");
 
70
 
 
71
        if(home == 0) return strdup("");
 
72
        string dirname = string(home) + string("/arts") + string(subdir);
 
73
 
 
74
        struct stat buf;
 
75
        if(stat(dirname.c_str(), &buf) == -1)
 
76
        {
 
77
                QString message;
 
78
                message = i18n("You need the directory %1.\n"
 
79
                        "It will be used to store %2.\nShould I create it now?")
 
80
                        .arg(dirname.c_str()).arg(desc);
 
81
 
 
82
                if(KMessageBox::questionYesNo(0,message,i18n("aRts directory missing"))
 
83
                        == KMessageBox::Yes)
 
84
                {
 
85
                        char command[1024];
 
86
                        sprintf(command,"mkdir -p %s",dirname.c_str());
 
87
                        system(command);
 
88
                }
 
89
        }
 
90
 
 
91
        return strdup(dirname.c_str());
 
92
}