summaryrefslogtreecommitdiff
path: root/library/global.cpp
Unidiff
Diffstat (limited to 'library/global.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/global.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/library/global.cpp b/library/global.cpp
index ec87555..f7a0767 100644
--- a/library/global.cpp
+++ b/library/global.cpp
@@ -763,50 +763,99 @@ void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter)
763 } 763 }
764 for (unsigned c = 0; c < subDirs.count();++c) { 764 for (unsigned c = 0; c < subDirs.count();++c) {
765 DocLnkSet ide( path+"/"+subDirs[c], mimefilter ); 765 DocLnkSet ide( path+"/"+subDirs[c], mimefilter );
766 folder->appendFrom(ide); 766 folder->appendFrom(ide);
767 } 767 }
768 } 768 }
769 } else if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) { 769 } else if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) {
770 QString path = (*it)->path() + "/Documents"; 770 QString path = (*it)->path() + "/Documents";
771 DocLnkSet ide( path, mimefilter ); 771 DocLnkSet ide( path, mimefilter );
772 folder->appendFrom(ide); 772 folder->appendFrom(ide);
773 } 773 }
774 } 774 }
775} 775}
776 776
777QStringList Global::languageList() 777QStringList Global::languageList()
778{ 778{
779 QString lang = getenv("LANG"); 779 QString lang = getenv("LANG");
780 QStringList langs; 780 QStringList langs;
781 langs.append(lang); 781 langs.append(lang);
782 int i = lang.find("."); 782 int i = lang.find(".");
783 if ( i > 0 ) 783 if ( i > 0 )
784 lang = lang.left( i ); 784 lang = lang.left( i );
785 i = lang.find( "_" ); 785 i = lang.find( "_" );
786 if ( i > 0 ) 786 if ( i > 0 )
787 langs.append(lang.left(i)); 787 langs.append(lang.left(i));
788 return langs; 788 return langs;
789} 789}
790 790
791QStringList Global::helpPath() 791QStringList Global::helpPath()
792{ 792{
793 QString qpeDir = QPEApplication::qpeDir(); 793 QString qpeDir = QPEApplication::qpeDir();
794 QStringList path; 794 QStringList path;
795 QStringList langs = Global::languageList(); 795 QStringList langs = Global::languageList();
796 for (QStringList::ConstIterator it = langs.fromLast(); it!=langs.end(); --it) { 796 for (QStringList::ConstIterator it = langs.fromLast(); it!=langs.end(); --it) {
797 QString lang = *it; 797 QString lang = *it;
798 if ( !lang.isEmpty() ) 798 if ( !lang.isEmpty() )
799 path += qpeDir + "/help/" + lang + "/html"; 799 path += qpeDir + "/help/" + lang + "/html";
800 } 800 }
801 path += qpeDir + "/pics"; 801 path += qpeDir + "/pics";
802 path += qpeDir + "/help/html"; 802 path += qpeDir + "/help/html";
803 /* we even put english into the en dir so try it as fallback as well for opie */ 803 /* we even put english into the en dir so try it as fallback as well for opie */
804 path += qpeDir + "/help/en/html"; 804 path += qpeDir + "/help/en/html";
805 path += qpeDir + "/docs"; 805 path += qpeDir + "/docs";
806 806
807 807
808 return path; 808 return path;
809} 809}
810 810
811/*!
812 \internal
813 Truncate file to size specified
814 \a f must be an open file
815 \a size must be a positive value
816 */
817bool Global::truncateFile(QFile &f, int size){
818 if (!f.isOpen())
819 return FALSE;
820
821 return ::ftruncate(f.handle(), size) != -1;
822}
823
824
825
826
827// #if defined(Q_OS_UNIX) && defined(Q_WS_QWS)
828// extern int qws_display_id;
829// #endif
830
831/*!
832 /internal
833 Returns the default system path for storing temporary files.
834 Note: This does not it ensure that the provided directory exists
835*/
836QString Global::tempDir()
837{
838 QString result;
839#ifdef Q_OS_UNIX
840#ifdef Q_WS_QWS
841 result = QString("/tmp/qtopia-%1/").arg(QString::number(qws_display_id));
842#else
843 result="/tmp/";
844#endif
845#else
846 if (getenv("TEMP"))
847 result = getenv("TEMP");
848 else
849 result = getenv("TMP");
850
851 if (result[(int)result.length() - 1] != QDir::separator())
852 result.append(QDir::separator());
853#endif
854
855 return result;
856}
857
858//#endif
859
811 860
812#include "global.moc" 861#include "global.moc"