~ubuntu-branches/ubuntu/hardy/codeblocks/hardy-backports

« back to all changes in this revision

Viewing changes to src/build_tools/scrooge/scrooge.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michael Casadevall
  • Date: 2008-07-17 04:39:23 UTC
  • Revision ID: james.westby@ubuntu.com-20080717043923-gmsy5cwkdjswghkm
Tags: upstream-8.02
ImportĀ upstreamĀ versionĀ 8.02

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
 
3
 * http://www.gnu.org/licenses/gpl-3.0.html
 
4
 *
 
5
 * $Revision: 4909 $
 
6
 * $Id: scrooge.cpp 4909 2008-02-27 13:15:26Z mortenmacfly $
 
7
 * $HeadURL: svn://svn.berlios.de/codeblocks/tags/8.02/src/build_tools/scrooge/scrooge.cpp $
 
8
 */
 
9
 
 
10
#include <stdio.h>
 
11
#include <string.h>
 
12
#include <dirent.h>
 
13
#include <sys/types.h>
 
14
#include <sys/stat.h>
 
15
 
 
16
#include "../../sdk/tinyxml/tinystr.h"
 
17
#include "../../sdk/tinyxml/tinyxml.h"
 
18
 
 
19
 
 
20
void ProcessFile(const char* fileName);
 
21
int main(int argc, char** argv);
 
22
void ls(char *dirname);
 
23
 
 
24
 
 
25
void ls(char *dirname)
 
26
{
 
27
        struct dirent *entry;
 
28
        struct stat buf;
 
29
 
 
30
    chdir(dirname);
 
31
        DIR *d = opendir(".");
 
32
 
 
33
        if(d == 0)
 
34
        return;
 
35
 
 
36
 
 
37
        for(entry = readdir(d); entry != NULL; entry = readdir(d))
 
38
        {
 
39
                if (stat(entry->d_name, &buf) < 0 || entry->d_name[0] == '.' || entry->d_name[0] == '_')
 
40
                        continue;
 
41
 
 
42
                if (S_ISDIR(buf.st_mode))
 
43
                {
 
44
            ls(entry->d_name);
 
45
                }
 
46
                else
 
47
                {
 
48
            if(strstr(entry->d_name, ".xrc"))
 
49
                ProcessFile(entry->d_name);
 
50
                }
 
51
        }
 
52
        closedir(d);
 
53
    chdir("..");
 
54
}
 
55
 
 
56
 
 
57
 
 
58
int main(int argc, char** argv)
 
59
{
 
60
    puts("Humbug!");
 
61
 
 
62
        if(argc != 2)
 
63
                return 0;
 
64
 
 
65
    ls(argv[1]);
 
66
 
 
67
    return 0;
 
68
}
 
69
 
 
70
 
 
71
void ProcessFile(const char* fileName)
 
72
{
 
73
        TiXmlDocument doc;
 
74
        doc.LoadFile(fileName);
 
75
                if(doc.Error())
 
76
                {
 
77
            printf("error in file %s: %s\n", fileName, doc.ErrorDesc());
 
78
                        return;
 
79
        }
 
80
                TiXmlPrinter printer;
 
81
                printer.SetStreamPrinting();
 
82
                doc.Accept(&printer);
 
83
 
 
84
                FILE *f = fopen(fileName, "wb");
 
85
                if(!f)
 
86
                        return;
 
87
 
 
88
                fwrite(printer.CStr(), printer.Size(), 1, f);
 
89
                fclose(f);
 
90
}
 
91