• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDE Support
  • Sitemap
  • Contact Us
 

strigi/src/streams

filestreamopener.cpp

Go to the documentation of this file.
00001 /* This file is part of Strigi Desktop Search
00002  *
00003  * Copyright (C) 2006 Ben van Klinken <bvklinken@gmail.com>
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Library General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Library General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Library General Public License
00016  * along with this library; see the file COPYING.LIB.  If not, write to
00017  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019  */
00020 #ifdef HAVE_CONFIG_H
00021 # include "config.h"
00022 #endif
00023 
00024 #include <strigi/strigiconfig.h>
00025 #include "archivereader.h"
00026 #include "fileinputstream.h"
00027 #include <sys/types.h>
00028 #include <sys/stat.h>
00029 
00030 using namespace std;
00031 using namespace Strigi;
00032 
00033 InputStream*
00034 FileStreamOpener::openStream(const string& url) {
00035     InputStream* stream = new FileInputStream(url.c_str());
00036     if (stream->status() != Ok) {
00037         delete stream;
00038         stream = 0;
00039     }
00040     return stream;
00041 }
00042 int
00043 FileStreamOpener::stat(const string& url, EntryInfo& e) {
00044     struct stat s;
00045     if (::stat(url.c_str(), &s) == -1) {
00046         return -1;
00047     }
00048     if (S_ISREG(s.st_mode)) {
00049         e.type = EntryInfo::File;
00050     } else if (S_ISDIR(s.st_mode)) {
00051         e.type = EntryInfo::Dir;
00052     } else {
00053         e.type = EntryInfo::Unknown;
00054     }
00055     e.size = s.st_size;
00056     e.mtime = s.st_mtime;
00057     size_t p = url.rfind('/');
00058     if (p == string::npos) {
00059         e.filename = url;
00060     } else {
00061         e.filename = url.substr(p+1);
00062     }
00063 
00064     return 0;
00065 }

strigi/src/streams

Skip menu "strigi/src/streams"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

KDE Support

Skip menu "KDE Support"
  • akonadi
  • Decibel
  • grantlee
  • kdewin
  • phonon
  •     Backend
  • polkit-qt
  • qca
  • qimageblitz
  • soprano
  • strigi
  •     searchclient
  •     streamanalyzer
  •     streams
Generated for KDE Support by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal