mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-07-02 14:04:22 +00:00
Add guess_content_type() function.
WiP.
This commit is contained in:
parent
8a97afd6bf
commit
64b5affa4f
6 changed files with 279 additions and 5 deletions
39
include/dindexer-machinery/guess_content_type.hpp
Normal file
39
include/dindexer-machinery/guess_content_type.hpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
/* Copyright 2015, 2016, Michele Santullo
|
||||
* This file is part of "dindexer".
|
||||
*
|
||||
* "dindexer" 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "dindexer" 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 "dindexer". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef id17F1582F16C8478E8D9795BECBF275A3
|
||||
#define id17F1582F16C8478E8D9795BECBF275A3
|
||||
|
||||
#include "dindexer-common/mediatypes.hpp"
|
||||
#include "dindexer-machinery/recorddata.hpp"
|
||||
#include <vector>
|
||||
|
||||
namespace mchlib {
|
||||
enum ContentTypes {
|
||||
ContentType_Generic,
|
||||
ContentType_Backup,
|
||||
ContentType_VideoDVD,
|
||||
ContentType_VideoBD,
|
||||
ContentType_Unknown
|
||||
};
|
||||
|
||||
template <bool> class SetListingView;
|
||||
|
||||
ContentTypes guess_content_type ( dinlib::MediaTypes parMediaType, const SetListingView<true>& parContent );
|
||||
} //namespace mchlib
|
||||
|
||||
#endif
|
|
@ -45,9 +45,7 @@ namespace mchlib {
|
|||
friend class mchlib::SetListingView<Const>;
|
||||
friend class boost::iterator_core_access;
|
||||
template <bool> friend class DirIterator;
|
||||
typedef boost::iterator_facade<DirIterator<Const>, FileRecordData, boost::random_access_traversal_tag> base_class;
|
||||
typedef typename base_class::difference_type difference_type;
|
||||
typedef typename base_class::reference reference;
|
||||
typedef boost::iterator_facade<DirIterator<Const>, FileRecordData, boost::forward_traversal_tag> base_class;
|
||||
struct enabler {};
|
||||
public:
|
||||
typedef typename std::conditional<
|
||||
|
@ -55,8 +53,14 @@ namespace mchlib {
|
|||
std::vector<mchlib::FileRecordData>::const_iterator,
|
||||
std::vector<mchlib::FileRecordData>::iterator
|
||||
>::type VecIterator;
|
||||
typedef typename base_class::difference_type difference_type;
|
||||
typedef typename base_class::value_type value_type;
|
||||
typedef typename base_class::pointer pointer;
|
||||
typedef typename base_class::reference reference;
|
||||
typedef typename base_class::iterator_category iterator_category;
|
||||
|
||||
DirIterator ( DirIterator<Const>&& parOther );
|
||||
DirIterator ( DirIterator&& parOther );
|
||||
DirIterator ( const DirIterator& parOther );
|
||||
template <bool OtherConst>
|
||||
DirIterator ( DirIterator<OtherConst>&& parOther, typename std::enable_if<std::is_convertible<typename DirIterator<OtherConst>::VecIterator, VecIterator>::value, enabler>::type = enabler() );
|
||||
DirIterator ( VecIterator parBegin, VecIterator parEnd, const PathName* parBasePath, std::size_t parLevelOffset );
|
||||
|
@ -131,6 +135,11 @@ namespace mchlib {
|
|||
SetListingView<true> make_view ( void ) const;
|
||||
SetListingView<true> make_cview ( void ) const;
|
||||
|
||||
bool empty ( void ) const;
|
||||
std::size_t size ( void ) const;
|
||||
std::size_t files_count ( void ) const;
|
||||
std::size_t dir_count ( void ) const;
|
||||
|
||||
private:
|
||||
ListType m_list;
|
||||
std::shared_ptr<PathName> m_base_path;
|
||||
|
|
77
include/dindexer-machinery/set_listing_helpers.hpp
Normal file
77
include/dindexer-machinery/set_listing_helpers.hpp
Normal file
|
@ -0,0 +1,77 @@
|
|||
/* Copyright 2015, 2016, Michele Santullo
|
||||
* This file is part of "dindexer".
|
||||
*
|
||||
* "dindexer" 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "dindexer" 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 "dindexer". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef id036D985665EC437096DF7EBC5607DB0A
|
||||
#define id036D985665EC437096DF7EBC5607DB0A
|
||||
|
||||
#include "set_listing.hpp"
|
||||
#include <cstddef>
|
||||
#include <algorithm>
|
||||
|
||||
namespace mchlib {
|
||||
template <bool Const>
|
||||
std::size_t count_listing_dirs ( const SetListingView<Const>& parList );
|
||||
|
||||
template <bool Const>
|
||||
std::size_t count_listing_files ( const SetListingView<Const>& parList );
|
||||
|
||||
template <bool Const>
|
||||
std::size_t count_listing_items ( const SetListingView<Const>& parList );
|
||||
|
||||
template <bool Const>
|
||||
std::size_t count_listing_items_recursive ( const SetListingView<Const>& parList );
|
||||
|
||||
template <bool Const>
|
||||
inline
|
||||
std::size_t count_listing_dirs (const SetListingView<Const>& parList) {
|
||||
return std::count_if(
|
||||
parList.cbegin(),
|
||||
parList.cend(),
|
||||
[] (const FileRecordData& parItm) {
|
||||
return parItm.is_directory;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
template <bool Const>
|
||||
inline
|
||||
std::size_t count_listing_files (const SetListingView<Const>& parList) {
|
||||
return std::count_if(
|
||||
parList.cbegin(),
|
||||
parList.cend(),
|
||||
[] (const FileRecordData& parItm) {
|
||||
return not parItm.is_directory;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
template <bool Const>
|
||||
inline
|
||||
std::size_t count_listing_items (const SetListingView<Const>& /*parList*/) {
|
||||
assert(false);
|
||||
return 0;
|
||||
//return std::count_if(
|
||||
// parList.cbegin(),
|
||||
// parList.cend(),
|
||||
// [] (const FileRecordData&) {
|
||||
// return true;
|
||||
// }
|
||||
//);
|
||||
}
|
||||
} //namespace mchlib
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue