~mixxxdevelopers/mixxx/trunk

« back to all changes in this revision

Viewing changes to mixxx/src/parser.cpp

  • Committer: Raffitea
  • Date: 2011-01-07 00:44:11 UTC
  • mfrom: (2616.1.25 traktor_library)
  • Revision ID: raffitea-20110107004411-lz9m8mnny3sf86rq
Merging from lp:~mixxxdevelopers/mixxx/traktor_library
* support for n-level childmodels in sidebar
* M3U and PLS playlist import

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//
2
 
// C++ Implementation: parser
3
 
//
4
 
// Description: superclass for external formats parsers
5
 
//
6
 
//
7
 
// Author: Ingo Kossyk <kossyki@cs.tu-berlin.de>, (C) 2004
8
 
//
9
 
// Copyright: See COPYING file that comes with this distribution
10
 
//
11
 
//
12
 
 
13
 
#include <QtDebug>
14
 
#include "parser.h"
15
 
 
16
 
/**
17
 
   @author Ingo Kossyk (kossyki@cs.tu-berlin.de)
18
 
 **/
19
 
 
20
 
 
21
 
Parser::Parser() : QObject()
22
 
{
23
 
}
24
 
 
25
 
Parser::~Parser()
26
 
{
27
 
 
28
 
 
29
 
}
30
 
 
31
 
void Parser::clearLocations()
32
 
{
33
 
    while(!m_sLocations.isEmpty())
34
 
        m_sLocations.removeFirst();
35
 
}
36
 
 
37
 
long Parser::countParsed()
38
 
{
39
 
    return (long)m_sLocations.count();
40
 
}
41
 
 
42
 
bool Parser::isFilepath(QString sFilepath){
43
 
    QFile file(sFilepath);
44
 
    bool exists = file.exists();
45
 
    file.close();
46
 
    return exists;
47
 
}
48
 
 
49
 
bool Parser::isBinary(QString filename){
50
 
    QFile file(filename);
51
 
 
52
 
    if(file.open(QIODevice::ReadOnly)){
53
 
        char c;
54
 
        unsigned char uc;
55
 
        
56
 
        if(!file.getChar(&c))
57
 
        {
58
 
          qDebug() << "Parser: Error reading stream on " << filename;
59
 
          return true; //should this raise an exception?
60
 
        }
61
 
        
62
 
        uc = uchar(c);
63
 
        
64
 
        if(!(33<=uc && uc<=127))  //Starting byte is no character
65
 
        {
66
 
            file.close();
67
 
            return true;
68
 
        }
69
 
 
70
 
    } else{
71
 
        qDebug() << "Parser: Could not open file: " << filename;
72
 
    }
73
 
    //qDebug(QString("Parser: textstream starting character is: %1").arg(i));
74
 
    file.close();
75
 
    return false;
76
 
}