From bdbc0ea90c852057ba8656081f951b10cf6c29fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Tue, 3 Sep 2013 20:03:07 +0200 Subject: Additional k => tde renaming and fixes --- ark/CMakeLists.txt | 2 +- ark/Makefile.am | 8 +- ark/arch.cpp | 2 +- ark/arj.cpp | 2 +- ark/arkutils.cpp | 230 +++++++++++++++++++++++++++++++++++++++++++++++ ark/arkutils.h | 56 ++++++++++++ ark/arkwidget.cpp | 2 +- ark/artdeutils.cpp | 230 ----------------------------------------------- ark/artdeutils.h | 56 ------------ ark/extractiondialog.cpp | 4 +- ark/lha.cpp | 2 +- ark/rar.cpp | 2 +- ark/sevenzip.cpp | 2 +- ark/zoo.cpp | 2 +- 14 files changed, 300 insertions(+), 300 deletions(-) create mode 100644 ark/arkutils.cpp create mode 100644 ark/arkutils.h delete mode 100644 ark/artdeutils.cpp delete mode 100644 ark/artdeutils.h (limited to 'ark') diff --git a/ark/CMakeLists.txt b/ark/CMakeLists.txt index c0ea58a..329fb47 100644 --- a/ark/CMakeLists.txt +++ b/ark/CMakeLists.txt @@ -49,7 +49,7 @@ tde_add_kpart( libarkpart AUTOMOC SOURCES ark_part.cpp arkfactory.cpp zip.cpp tar.cpp filelistview.cpp arch.cpp lha.cpp compressedfile.cpp zoo.cpp rar.cpp ar.cpp - artdeutils.cpp archiveformatdlg.cpp + arkutils.cpp archiveformatdlg.cpp arkwidget.cpp searchbar.cpp addition.ui extraction.ui general.ui arkviewer.cpp sevenzip.cpp extractiondialog.cpp ace.cpp diff --git a/ark/Makefile.am b/ark/Makefile.am index bf14490..60f5fe8 100644 --- a/ark/Makefile.am +++ b/ark/Makefile.am @@ -10,24 +10,24 @@ lib_LTLIBRARIES = ark_la_SOURCES = main.cpp arkapp.cpp mainwindow.cpp ark_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(KDE_PLUGIN) -ark_la_LIBADD = $(LIB_KDED) -lDCOP $(LIB_TDEHTML) $(LIB_KIO) $(LIB_KDEUI) $(LIB_KDECORE) $(LIB_QT) libark_common.la $(LIB_KPARTS) +ark_la_LIBADD = $(LIB_KDED) -lDCOP $(LIB_TDEHTML) $(LIB_TDEIO) $(LIB_TDEUI) $(LIB_TDECORE) $(LIB_QT) libark_common.la $(LIB_TDEPARTS) ark_la_COMPILE_FIRST = settings.h noinst_LTLIBRARIES = libark_common.la libark_common_la_SOURCES = settings.kcfgc archiveformatinfo.cpp libark_common_la_LDFLAGS = $(all_libraries) -no-undefined -libark_common_la_LIBADD = $(LIB_KDED) -lDCOP $(LIB_TDEHTML) $(LIB_KIO) $(LIB_KDEUI) $(LIB_KDECORE) $(LIB_QT) $(LIB_TDEFILE) +libark_common_la_LIBADD = $(LIB_KDED) -lDCOP $(LIB_TDEHTML) $(LIB_TDEIO) $(LIB_TDEUI) $(LIB_TDECORE) $(LIB_QT) $(LIB_TDEFILE) kde_module_LTLIBRARIES = libarkpart.la libarkpart_la_LDFLAGS = $(KDE_PLUGIN) $(all_libraries) -libarkpart_la_LIBADD = $(LIB_KDED) -lDCOP $(LIB_TDEHTML) $(LIB_KIO) $(LIB_KDEUI) $(LIB_KDECORE) $(LIB_QT) libark_common.la $(LIB_KPARTS) +libarkpart_la_LIBADD = $(LIB_KDED) -lDCOP $(LIB_TDEHTML) $(LIB_TDEIO) $(LIB_TDEUI) $(LIB_TDECORE) $(LIB_QT) libark_common.la $(LIB_TDEPARTS) libarkpart_la_COMPILE_FIRST = settings.h libarkpart_la_SOURCES = ark_part.cpp arkfactory.cpp zip.cpp tar.cpp \ filelistview.cpp arch.cpp lha.cpp \ compressedfile.cpp zoo.cpp rar.cpp \ - ar.cpp artdeutils.cpp archiveformatdlg.cpp \ + ar.cpp arkutils.cpp archiveformatdlg.cpp \ arkwidget.cpp searchbar.cpp \ addition.ui extraction.ui general.ui \ arkviewer.cpp sevenzip.cpp extractiondialog.cpp \ diff --git a/ark/arch.cpp b/ark/arch.cpp index 2ca8ec5..eb5606b 100644 --- a/ark/arch.cpp +++ b/ark/arch.cpp @@ -47,7 +47,7 @@ // ark includes #include "arch.h" #include "arkwidget.h" -#include "artdeutils.h" +#include "arkutils.h" #include "filelistview.h" // the archive types diff --git a/ark/arj.cpp b/ark/arj.cpp index f081e17..4a9ab44 100644 --- a/ark/arj.cpp +++ b/ark/arj.cpp @@ -42,7 +42,7 @@ #include "arj.h" #include "arkwidget.h" #include "settings.h" -#include "artdeutils.h" +#include "arkutils.h" #include "filelistview.h" ArjArch::ArjArch( ArkWidget *_gui, const TQString & _fileName ) diff --git a/ark/arkutils.cpp b/ark/arkutils.cpp new file mode 100644 index 0000000..24411e8 --- /dev/null +++ b/ark/arkutils.cpp @@ -0,0 +1,230 @@ +/* + + $Id$ + + ark -- archiver for the KDE project + + Copyright (C) + + 2002: Helio Chissini de Castro + 2001: Corel Corporation (author: Michael Jarrett, michaelj@corel.com) + 1999-2000: Corel Corporation (author: Emily Ezust, emilye@corel.com) + 1999: Francois-Xavier Duranceau duranceau@kde.org + 1997-1999: Rob Palmbos palm9744@kettering.edu + 2003: Hans Petter Bieker + + 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 Street, Fifth Floor, Boston, MA 02110-1301, USA. + +*/ + +#include + +// C includes +#include +#include + +#include +#include +#include +#include + +#include +#include + +#ifdef _HPUX_SOURCE +#include +#endif + +// for statfs: +#ifdef BSD4_4 +#include +#elif defined(__linux__) +#include +#elif defined(__sun) +#include +#define STATFS statvfs +#elif defined(_AIX) +#include +#endif + +#ifndef STATFS +#define STATFS statfs +#endif + +// KDE includes +#include +#include +#include +#include + +// TQt includes +#include + +#include "arkutils.h" + +TQString ArkUtils::getTimeStamp(const TQString &_month, + const TQString &_day, + const TQString &_yearOrTime) +{ + // Make the date format sortable. + // Month is in _month, day is in _day. + // In _yearOrTime is either a year or a time. + // If it's March, we'll see the year for all dates up to October 1999. + // (five months' difference - e.g., if it's Apr, then get years up to Nov) + + char month[4]; + strncpy(month, _month.ascii(), 3); + month[3] = '\0'; + int nMonth = getMonth(month); + int nDay = _day.toInt(); + + kdDebug(1601) << "Month is " << nMonth << ", Day is " << nDay << endl; + + time_t t = time(0); + if (t == -1) + exit(1); + struct tm *now = localtime(&t); + int thisYear = now->tm_year + 1900; + int thisMonth = now->tm_mon + 1; + + TQString year, timestamp; + + if (_yearOrTime.contains(":")) + // it has a timestamp so we have to figure out the year + { + year.sprintf("%d", ArkUtils::getYear(nMonth, thisYear, thisMonth)); + timestamp = _yearOrTime; + } + else + { + year = _yearOrTime; + if (year.right(1) == " ") + year = year.left(4); + if (year.left(1) == " ") + year = year.right(4); + + timestamp = "??:??"; + } + + TQString retval; + retval.sprintf("%s-%.2d-%.2d %s", + year.utf8().data(), nMonth, nDay, + timestamp.utf8().data()); + return retval; +} + +int ArkUtils::getMonth(const char *strMonth) + // returns numeric value for three-char month string +{ + static char months[13][4] = { "", "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; + int nIndex; + for (nIndex = 1; nIndex < 13; ++nIndex) + { + if (0 == strcmp(strMonth, months[nIndex])) + return nIndex; + } + return 0; +} + +// This function gets the year from an LHA or ls -l timestamp. +// Note: LHA doesn't seem to display the year if the file is more +// than 6 months into the future, so this will fail to give the correct +// year (of course it is hoped that there are not too many files lying +// around from the future). + +int ArkUtils::getYear(int theMonth, int thisYear, int thisMonth) +{ + int monthDiff = TQABS(thisMonth - theMonth); + if (monthDiff > 6) + return (thisYear - 1); + else + return thisYear; +} + +TQString ArkUtils::fixYear(const TQString& strYear) +{ + // returns 4-digit year by guessing from two-char year string. + // Remember: this is used for file timestamps. There probably aren't any + // files that were created before 1970, so that's our cutoff. Of course, + // in 2070 we'll have some problems.... + + if ( strYear.length() != 2 ) return strYear; + + bool ok; + int y = strYear.toInt( &ok ); + + if ( ok ) + { + if ( y > 70 ) + y += 1900; + else + y += 2000; + + return TQString::number( y ); + } + else + return TQString(); +} + +bool +ArkUtils::haveDirPermissions( const TQString &strFile ) +{ + return ( access( TQFile::encodeName( strFile ), W_OK ) == 0 ); +} + +bool +ArkUtils::diskHasSpace(const TQString &dir, TDEIO::filesize_t size) + // check if disk has enough space to accommodate (a) new file(s) of + // the given size in the partition containing the given directory +{ + kdDebug( 1601 ) << "diskHasSpace() " << "dir: " << dir << " Size: " << size << endl; + + struct STATFS buf; + if (STATFS(TQFile::encodeName(dir), &buf) == 0) + { + double nAvailable = (double)buf.f_bavail * buf.f_bsize; + if ( nAvailable < (double)size ) + { + KMessageBox::error(0, i18n("You have run out of disk space.")); + return false; + } + } + else + { + // something bad happened + kdWarning( 1601 ) << "diskHasSpace() failed" << endl; + // Q_ASSERT(0); + } + return true; +} + +TDEIO::filesize_t +ArkUtils::getSizes(TQStringList *list) +{ + TDEIO::filesize_t sum = 0; + TQString str; + KDE_struct_stat st; + + for ( TQStringList::Iterator it = list->begin(); it != list->end(); ++it) + { + str = *it; + str = str.right(str.length()-5); + if (KDE_stat(TQFile::encodeName(str), &st ) < 0) + continue; + sum += st.st_size; + } + return sum; +} diff --git a/ark/arkutils.h b/ark/arkutils.h new file mode 100644 index 0000000..c53791f --- /dev/null +++ b/ark/arkutils.h @@ -0,0 +1,56 @@ +// -*-C++-*- emacs magic for .h files +/* + + $Id$ + + ark -- archiver for the KDE project + + Copyright (C) + + 1997-1999: Rob Palmbos palm9744@kettering.edu + 1999: Francois-Xavier Duranceau duranceau@kde.org + 1999-2000: Corel Corporation (author: Emily Ezust, emilye@corel.com) + 2001: Corel Corporation (author: Michael Jarrett, michaelj@corel.com) + 2003: Hans Petter Bieker + + 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 Street, Fifth Floor, Boston, MA 02110-1301, USA. + +*/ + +#ifndef ARKUTILS_H +#define ARKUTILS_H + +#include + +#include + +class TQStringList; + +// various functions for massaging timestamps +namespace ArkUtils +{ + int getYear(int theMonth, int thisYear, int thisMonth); + int getMonth(const char *strMonth); + TQString fixYear(const TQString& strYear); + + TQString getTimeStamp(const TQString &month, + const TQString &day, + const TQString &year); + bool haveDirPermissions(const TQString &strFile); + bool diskHasSpace(const TQString &dir, TDEIO::filesize_t size); + TDEIO::filesize_t getSizes(TQStringList *list); +} + +#endif diff --git a/ark/arkwidget.cpp b/ark/arkwidget.cpp index 5dacb77..9dfcf42 100644 --- a/ark/arkwidget.cpp +++ b/ark/arkwidget.cpp @@ -75,7 +75,7 @@ #include "extractiondialog.h" #include "arkwidget.h" #include "filelistview.h" -#include "artdeutils.h" +#include "arkutils.h" #include "archiveformatinfo.h" #include "compressedfile.h" #include "searchbar.h" diff --git a/ark/artdeutils.cpp b/ark/artdeutils.cpp deleted file mode 100644 index bdfec3f..0000000 --- a/ark/artdeutils.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/* - - $Id$ - - ark -- archiver for the KDE project - - Copyright (C) - - 2002: Helio Chissini de Castro - 2001: Corel Corporation (author: Michael Jarrett, michaelj@corel.com) - 1999-2000: Corel Corporation (author: Emily Ezust, emilye@corel.com) - 1999: Francois-Xavier Duranceau duranceau@kde.org - 1997-1999: Rob Palmbos palm9744@kettering.edu - 2003: Hans Petter Bieker - - 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 Street, Fifth Floor, Boston, MA 02110-1301, USA. - -*/ - -#include - -// C includes -#include -#include - -#include -#include -#include -#include - -#include -#include - -#ifdef _HPUX_SOURCE -#include -#endif - -// for statfs: -#ifdef BSD4_4 -#include -#elif defined(__linux__) -#include -#elif defined(__sun) -#include -#define STATFS statvfs -#elif defined(_AIX) -#include -#endif - -#ifndef STATFS -#define STATFS statfs -#endif - -// KDE includes -#include -#include -#include -#include - -// TQt includes -#include - -#include "artdeutils.h" - -TQString ArkUtils::getTimeStamp(const TQString &_month, - const TQString &_day, - const TQString &_yearOrTime) -{ - // Make the date format sortable. - // Month is in _month, day is in _day. - // In _yearOrTime is either a year or a time. - // If it's March, we'll see the year for all dates up to October 1999. - // (five months' difference - e.g., if it's Apr, then get years up to Nov) - - char month[4]; - strncpy(month, _month.ascii(), 3); - month[3] = '\0'; - int nMonth = getMonth(month); - int nDay = _day.toInt(); - - kdDebug(1601) << "Month is " << nMonth << ", Day is " << nDay << endl; - - time_t t = time(0); - if (t == -1) - exit(1); - struct tm *now = localtime(&t); - int thisYear = now->tm_year + 1900; - int thisMonth = now->tm_mon + 1; - - TQString year, timestamp; - - if (_yearOrTime.contains(":")) - // it has a timestamp so we have to figure out the year - { - year.sprintf("%d", ArkUtils::getYear(nMonth, thisYear, thisMonth)); - timestamp = _yearOrTime; - } - else - { - year = _yearOrTime; - if (year.right(1) == " ") - year = year.left(4); - if (year.left(1) == " ") - year = year.right(4); - - timestamp = "??:??"; - } - - TQString retval; - retval.sprintf("%s-%.2d-%.2d %s", - year.utf8().data(), nMonth, nDay, - timestamp.utf8().data()); - return retval; -} - -int ArkUtils::getMonth(const char *strMonth) - // returns numeric value for three-char month string -{ - static char months[13][4] = { "", "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; - int nIndex; - for (nIndex = 1; nIndex < 13; ++nIndex) - { - if (0 == strcmp(strMonth, months[nIndex])) - return nIndex; - } - return 0; -} - -// This function gets the year from an LHA or ls -l timestamp. -// Note: LHA doesn't seem to display the year if the file is more -// than 6 months into the future, so this will fail to give the correct -// year (of course it is hoped that there are not too many files lying -// around from the future). - -int ArkUtils::getYear(int theMonth, int thisYear, int thisMonth) -{ - int monthDiff = TQABS(thisMonth - theMonth); - if (monthDiff > 6) - return (thisYear - 1); - else - return thisYear; -} - -TQString ArkUtils::fixYear(const TQString& strYear) -{ - // returns 4-digit year by guessing from two-char year string. - // Remember: this is used for file timestamps. There probably aren't any - // files that were created before 1970, so that's our cutoff. Of course, - // in 2070 we'll have some problems.... - - if ( strYear.length() != 2 ) return strYear; - - bool ok; - int y = strYear.toInt( &ok ); - - if ( ok ) - { - if ( y > 70 ) - y += 1900; - else - y += 2000; - - return TQString::number( y ); - } - else - return TQString(); -} - -bool -ArkUtils::haveDirPermissions( const TQString &strFile ) -{ - return ( access( TQFile::encodeName( strFile ), W_OK ) == 0 ); -} - -bool -ArkUtils::diskHasSpace(const TQString &dir, TDEIO::filesize_t size) - // check if disk has enough space to accommodate (a) new file(s) of - // the given size in the partition containing the given directory -{ - kdDebug( 1601 ) << "diskHasSpace() " << "dir: " << dir << " Size: " << size << endl; - - struct STATFS buf; - if (STATFS(TQFile::encodeName(dir), &buf) == 0) - { - double nAvailable = (double)buf.f_bavail * buf.f_bsize; - if ( nAvailable < (double)size ) - { - KMessageBox::error(0, i18n("You have run out of disk space.")); - return false; - } - } - else - { - // something bad happened - kdWarning( 1601 ) << "diskHasSpace() failed" << endl; - // Q_ASSERT(0); - } - return true; -} - -TDEIO::filesize_t -ArkUtils::getSizes(TQStringList *list) -{ - TDEIO::filesize_t sum = 0; - TQString str; - KDE_struct_stat st; - - for ( TQStringList::Iterator it = list->begin(); it != list->end(); ++it) - { - str = *it; - str = str.right(str.length()-5); - if (KDE_stat(TQFile::encodeName(str), &st ) < 0) - continue; - sum += st.st_size; - } - return sum; -} diff --git a/ark/artdeutils.h b/ark/artdeutils.h deleted file mode 100644 index c53791f..0000000 --- a/ark/artdeutils.h +++ /dev/null @@ -1,56 +0,0 @@ -// -*-C++-*- emacs magic for .h files -/* - - $Id$ - - ark -- archiver for the KDE project - - Copyright (C) - - 1997-1999: Rob Palmbos palm9744@kettering.edu - 1999: Francois-Xavier Duranceau duranceau@kde.org - 1999-2000: Corel Corporation (author: Emily Ezust, emilye@corel.com) - 2001: Corel Corporation (author: Michael Jarrett, michaelj@corel.com) - 2003: Hans Petter Bieker - - 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 Street, Fifth Floor, Boston, MA 02110-1301, USA. - -*/ - -#ifndef ARKUTILS_H -#define ARKUTILS_H - -#include - -#include - -class TQStringList; - -// various functions for massaging timestamps -namespace ArkUtils -{ - int getYear(int theMonth, int thisYear, int thisMonth); - int getMonth(const char *strMonth); - TQString fixYear(const TQString& strYear); - - TQString getTimeStamp(const TQString &month, - const TQString &day, - const TQString &year); - bool haveDirPermissions(const TQString &strFile); - bool diskHasSpace(const TQString &dir, TDEIO::filesize_t size); - TDEIO::filesize_t getSizes(TQStringList *list); -} - -#endif diff --git a/ark/extractiondialog.cpp b/ark/extractiondialog.cpp index 0684ca1..f4b5196 100644 --- a/ark/extractiondialog.cpp +++ b/ark/extractiondialog.cpp @@ -48,7 +48,7 @@ #include #include -#include "artdeutils.h" +#include "arkutils.h" #include "settings.h" ExtractionDialog::ExtractionDialog( TQWidget *parent, const char *name, @@ -139,7 +139,7 @@ void ExtractionDialog::accept() uc.setReplaceHome( true ); KURL p( uc.replacedPath( m_urlRequester->comboBox()->currentText() ) ); - //if p isn't local KIO and friends will complain later on + //if p isn't local TDEIO and friends will complain later on if ( p.isLocalFile() ) { TQFileInfo fi( p.path() ); diff --git a/ark/lha.cpp b/ark/lha.cpp index 18a31db..101277d 100644 --- a/ark/lha.cpp +++ b/ark/lha.cpp @@ -49,7 +49,7 @@ #include "settings.h" #include "arch.h" #include "lha.h" -#include "artdeutils.h" +#include "arkutils.h" #include "filelistview.h" LhaArch::LhaArch( ArkWidget *_gui, const TQString & _fileName ) diff --git a/ark/rar.cpp b/ark/rar.cpp index 5878769..4d6a7ce 100644 --- a/ark/rar.cpp +++ b/ark/rar.cpp @@ -49,7 +49,7 @@ #include "arch.h" #include "settings.h" #include "rar.h" -#include "artdeutils.h" +#include "arkutils.h" #include "filelistview.h" RarArch::RarArch( ArkWidget *_gui, const TQString & _fileName ) diff --git a/ark/sevenzip.cpp b/ark/sevenzip.cpp index 3f5fff2..287ec3b 100644 --- a/ark/sevenzip.cpp +++ b/ark/sevenzip.cpp @@ -39,7 +39,7 @@ #include "sevenzip.h" #include "arkwidget.h" #include "settings.h" -#include "artdeutils.h" +#include "arkutils.h" #include "filelistview.h" SevenZipArch::SevenZipArch( ArkWidget *gui, const TQString &filename ) diff --git a/ark/zoo.cpp b/ark/zoo.cpp index e173415..aa96d47 100644 --- a/ark/zoo.cpp +++ b/ark/zoo.cpp @@ -46,7 +46,7 @@ #include "arkwidget.h" #include "arch.h" #include "zoo.h" -#include "artdeutils.h" +#include "arkutils.h" #include "filelistview.h" static TQString fixTime( const TQString &_strTime ); -- cgit v1.2.1