1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
/***************************************************************************
* Copyright (C) 2003-2005 by The Amarok Developers *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* 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., *
* 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef COLLECTIONSCANNER_H
#define COLLECTIONSCANNER_H
#include "metabundle.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <tqmap.h>
#include <tqstringlist.h>
#include <tdeapplication.h>
typedef TQMap<TQString, TQString> AttributeMap;
/**
* @class CollectionScanner
* @short Scans directories and builds the Collection
*/
class CollectionScanner : public TDEApplication
{
TQ_OBJECT
public:
CollectionScanner( const TQStringList& folders,
bool recursive,
bool incremental,
bool importPlaylists,
bool restart );
~CollectionScanner();
int newInstance() { return 0; }
public slots:
void pause();
void resume();
private slots:
void doJob();
private:
void readDir( const TQString& dir, TQStringList& entries );
void scanFiles( const TQStringList& entries );
/**
* Read metadata tags of a given file.
* @mb MetaBundle for the file.
* @return TQMap containing tags, or empty TQMap on failure.
*/
AttributeMap readTags( const MetaBundle& mb );
/**
* Helper method for writing XML elements to stdout.
* @name Name of the element.
* @attributes Key/value map of attributes.
*/
void writeElement( const TQString& name, const AttributeMap& attributes );
/**
* @return the LOWERCASE file extension without the preceding '.', or "" if there is none
*/
inline TQString extension( const TQString &fileName )
{
return fileName.contains( '.' ) ? fileName.mid( fileName.findRev( '.' ) + 1 ).lower() : "";
}
/**
* @return the last directory in @param fileName
*/
inline TQString directory( const TQString &fileName )
{
return fileName.section( '/', 0, -2 );
}
const bool m_importPlaylists;
TQStringList m_folders;
const bool m_recursively;
const bool m_incremental;
const bool m_restart;
const TQString m_logfile;
bool m_pause;
struct direntry {
dev_t dev;
ino_t ino;
} KDE_PACKED;
TQMemArray<direntry> m_processedDirs;
};
#endif // COLLECTIONSCANNER_H
|