~openhommdev/openhomm/gui

« back to all changes in this revision

Viewing changes to src/core/hrFilesystem.cpp

  • Committer: Stanislav Ershov
  • Date: 2010-02-09 01:48:58 UTC
  • Revision ID: digital.stream.of.mind@gmail.com-20100209014858-j4hxtrebjdtblo9n
refactored and documented some code

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
const char * MOUNT_SUCCESSFULLY = "Successfully mounted: %s";
26
26
const char * MOUNT_FAILED       = "Failed to mount: %s";
27
27
 
28
 
hrFilesystem::hrFilesystem()
29
 
{
30
 
}
31
 
 
32
 
hrFilesystem::~hrFilesystem()
33
 
{
34
 
}
35
 
 
36
28
bool hrFilesystem::mount(const QString &path)
37
29
{
38
30
    QStringList pathElements = path.split('/');
73
65
    return true;
74
66
}
75
67
 
 
68
/*!
 
69
  not implemented yet
 
70
*/
76
71
bool hrFilesystem::umount(const QString &path)
77
72
{
78
73
    Q_UNUSED(path);
84
79
    _cache.insert(filename, archive);
85
80
}
86
81
 
87
 
bool hrFilesystem::findInCache(const QString &filename, QString &archive)
 
82
/*!
 
83
  Try to find archive where the file located.
 
84
  @param filename Filename to found.
 
85
  @return Archive name or null string on error.
 
86
*/
 
87
QString hrFilesystem::findInCache(const QString &filename)
88
88
{
89
89
    if ( _cache.find(filename) != _cache.end() )
90
90
    {
91
 
        archive = _cache[filename];
92
 
 
93
 
        return true;
 
91
        return _cache[filename];
94
92
    }
95
93
 
96
94
    qWarning() << "Not found " << filename << __FILE__ << __LINE__;
97
 
    return false;
 
95
    return QString();
 
96
}
 
97
 
 
98
/**
 
99
 *  Extract archive name from full path.
 
100
 *  @param path a case-sensitive path
 
101
 *  @param ext Must be ".lod" or ".snd" or something else
 
102
 *  @return Archive name or null string on error.
 
103
 */
 
104
QString hrFilesystem::extractArchnameFromPath(const QString& path, const char* ext)
 
105
{
 
106
    QString archive;
 
107
    int index = path.indexOf(ext);
 
108
 
 
109
    if ( index == -1 )
 
110
        return QString();
 
111
 
 
112
    archive = path.left(index + qstrlen(ext));
 
113
    archive.remove(0, qstrlen(ext) + 1);
 
114
 
 
115
    return archive;
 
116
}
 
117
 
 
118
/**
 
119
 *  Extract filename with path from full path.
 
120
 *  @param path a case-sensitive path
 
121
 *  @param ext Must be ".lod" or ".snd" or something else
 
122
 *  @return Archive name or null string on error.
 
123
 */
 
124
QString hrFilesystem::extractFilenameFromPath(const QString& path, const char* ext)
 
125
{
 
126
    int index = path.indexOf(ext);
 
127
 
 
128
    if ( index == -1 )
 
129
        return QString();
 
130
 
 
131
    return path.right(path.length() - index - qstrlen(ext) - 1 );
98
132
}