summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/util.h
blob: f831ead1486a01b058bad3c9ad73e712752bf932 (plain)
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
#ifndef __UTIL_H
#define __UTIL_H

#include <qstring.h>
#include <qdir.h>
#include <stdlib.h>

QString filesize(unsigned long l);
QString percent(unsigned long pos, unsigned long len);
QString fmt(unsigned long pos, unsigned long len);

/**
 * class with utility inline function(s)
 * (in contrast to global functions they become available by just
 * including util.h)
 */
class QTReaderUtil
{
  public:

   /**
	 * searches for a specific direcory inside OpieReader installation
	 *
	 * @param subdir    name of sub directory inside installation directory which is needed
	 * @return full path name including that sub directory
	 *
	 * search order is (on all platforms):
	 * - OPIEDIR
	 * - QTDIR
	 * - READERDIR
	 */
	static QString getPluginPath( const char *subdir = "codecs/" )
	{
		QString dirname;
		dirname = getenv("OPIEDIR");
		dirname += "/plugins/reader/";
		dirname += subdir;
		if (QDir(dirname).exists())
			return dirname;

		dirname = getenv("QTDIR");
		dirname += "/plugins/reader/";
		dirname += subdir;
		if (QDir(dirname).exists())
			return dirname;

		dirname = getenv("READERDIR");
		dirname += "/";
		dirname += subdir;
		if (QDir(dirname).exists())
			return dirname;

		return "";	 
	}
}; 

#endif