mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 10:22:52 +00:00
filelight: avoid stat()-ing if dirent::d_type is available
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
ec0dce85df
commit
812b922836
3 changed files with 27 additions and 1 deletions
|
@ -29,7 +29,19 @@ endif()
|
||||||
|
|
||||||
add_definitions(-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII)
|
add_definitions(-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII)
|
||||||
|
|
||||||
include_directories(src)
|
include(CheckStructHasMember)
|
||||||
|
|
||||||
|
check_struct_has_member("struct dirent" d_type dirent.h HAVE_DIRENT_D_TYPE)
|
||||||
|
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/config-filelight.h.cmake
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/config-filelight.h
|
||||||
|
)
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||||
|
)
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
add_subdirectory(misc)
|
add_subdirectory(misc)
|
||||||
|
|
4
filelight/config-filelight.h.cmake
Normal file
4
filelight/config-filelight.h.cmake
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
/* config.h. Generated by cmake from config.h.cmake */
|
||||||
|
|
||||||
|
/* Defined to 1 if you have a d_type member in struct dirent */
|
||||||
|
#cmakedefine HAVE_DIRENT_D_TYPE 1
|
|
@ -19,6 +19,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
#include "config-filelight.h"
|
||||||
|
|
||||||
#include "localLister.h"
|
#include "localLister.h"
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
@ -148,12 +150,19 @@ LocalLister::scan(const QByteArray &path, const QByteArray &dirname)
|
||||||
QByteArray new_path = path;
|
QByteArray new_path = path;
|
||||||
new_path += ent->d_name;
|
new_path += ent->d_name;
|
||||||
|
|
||||||
|
#ifdef HAVE_DIRENT_D_TYPE
|
||||||
|
if (ent->d_type != DT_DIR && ent->d_type != DT_REG) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//get file information
|
//get file information
|
||||||
if (KDE_lstat(new_path, &statbuf) == -1) {
|
if (KDE_lstat(new_path, &statbuf) == -1) {
|
||||||
outputError(new_path);
|
outputError(new_path);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef HAVE_DIRENT_D_TYPE // anything that is not file/directory is filtered above
|
||||||
if (S_ISLNK(statbuf.st_mode) ||
|
if (S_ISLNK(statbuf.st_mode) ||
|
||||||
S_ISCHR(statbuf.st_mode) ||
|
S_ISCHR(statbuf.st_mode) ||
|
||||||
S_ISBLK(statbuf.st_mode) ||
|
S_ISBLK(statbuf.st_mode) ||
|
||||||
|
@ -162,6 +171,7 @@ LocalLister::scan(const QByteArray &path, const QByteArray &dirname)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (S_ISREG(statbuf.st_mode)) //file
|
if (S_ISREG(statbuf.st_mode)) //file
|
||||||
cwd->append(ent->d_name, (statbuf.st_blocks * S_BLKSIZE));
|
cwd->append(ent->d_name, (statbuf.st_blocks * S_BLKSIZE));
|
||||||
|
|
Loading…
Add table
Reference in a new issue