mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2024-11-25 00:53:43 +00:00
Move mediatypes.hpp/cpp to machinery.
This was needed so that machinery wouldn't depend on common. Also moved compatibility.h to helpers include dir. Ideally mediatypes.hpp will be merged into mediatype.hpp, or there will be some kind of renaming because the two names are getting really confusing.
This commit is contained in:
parent
6ddf79fad9
commit
1956594c01
19 changed files with 48 additions and 53 deletions
|
@ -19,7 +19,6 @@
|
|||
#define id1B7A42F6E46547A6AB0F914E2A91399F
|
||||
|
||||
#include "dindexer-common/validationerror.hpp"
|
||||
#include "dindexer-common/mediatypes.hpp"
|
||||
#include <boost/program_options/variables_map.hpp>
|
||||
|
||||
namespace din {
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
#ifndef id17F1582F16C8478E8D9795BECBF275A3
|
||||
#define id17F1582F16C8478E8D9795BECBF275A3
|
||||
|
||||
#include "dindexer-common/mediatypes.hpp"
|
||||
#include "dindexer-machinery/mediatypes.hpp"
|
||||
#include "dindexer-machinery/recorddata.hpp"
|
||||
#include "dindexer-common/compatibility.h"
|
||||
#include "helpers/compatibility.h"
|
||||
#include <vector>
|
||||
|
||||
namespace mchlib {
|
||||
|
@ -36,8 +36,8 @@ namespace mchlib {
|
|||
|
||||
template <bool> class SetListingView;
|
||||
|
||||
ContentTypes guess_content_type ( dinlib::MediaTypes parMediaType, const SetListingView<true>& parContent, std::size_t parEntriesCount=0 );
|
||||
ContentTypes guess_content_type ( dinlib::MediaTypes parMediaType, const std::vector<FileRecordData>& parContent );
|
||||
ContentTypes guess_content_type ( MediaTypes parMediaType, const SetListingView<true>& parContent, std::size_t parEntriesCount=0 );
|
||||
ContentTypes guess_content_type ( MediaTypes parMediaType, const std::vector<FileRecordData>& parContent );
|
||||
|
||||
char content_type_to_char ( ContentTypes parCType ) a_pure;
|
||||
ContentTypes char_to_content_type ( char parCType ) a_pure;
|
||||
|
|
|
@ -20,11 +20,11 @@
|
|||
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include "dindexer-common/mediatypes.hpp"
|
||||
#include "dindexer-machinery/mediatypes.hpp"
|
||||
|
||||
namespace mchlib {
|
||||
#if defined(WITH_MEDIA_AUTODETECT)
|
||||
dinlib::MediaTypes guess_media_type ( std::string&& parPath );
|
||||
MediaTypes guess_media_type ( std::string&& parPath );
|
||||
|
||||
class UnknownMediaTypeException : std::runtime_error {
|
||||
public:
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
#ifndef id700AFD0F33634ACC88079BB8853A9E13
|
||||
#define id700AFD0F33634ACC88079BB8853A9E13
|
||||
|
||||
#include "dindexer-common/compatibility.h"
|
||||
#include "helpers/compatibility.h"
|
||||
#include <string>
|
||||
|
||||
namespace dinlib {
|
||||
namespace mchlib {
|
||||
enum MediaTypes {
|
||||
MediaType_CDRom = 'C',
|
||||
MediaType_Directory = 'D',
|
||||
|
@ -35,6 +35,6 @@ namespace dinlib {
|
|||
|
||||
const std::string& media_type_to_str ( MediaTypes parType );
|
||||
MediaTypes char_to_media_type ( char parMType ) a_pure;
|
||||
} //namespace dinlib
|
||||
} //namespace mchlib
|
||||
|
||||
#endif
|
|
@ -19,21 +19,21 @@
|
|||
#define id25B0BCA6D9464754920E1BC7C5D9DB57
|
||||
|
||||
#include "dindexer-machinery/scantask/base.hpp"
|
||||
#include "dindexer-common/mediatypes.hpp"
|
||||
#include "dindexer-machinery/mediatypes.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace mchlib {
|
||||
namespace scantask {
|
||||
class MediaType : Base<dinlib::MediaTypes> {
|
||||
class MediaType : Base<MediaTypes> {
|
||||
public:
|
||||
MediaType ( char parDefault, bool parForce, std::string parSearchPath );
|
||||
virtual ~MediaType ( void ) noexcept = default;
|
||||
|
||||
private:
|
||||
virtual void on_data_destroy ( dinlib::MediaTypes& parData );
|
||||
virtual void on_data_create ( dinlib::MediaTypes& parData );
|
||||
virtual void on_data_destroy ( MediaTypes& parData );
|
||||
virtual void on_data_create ( MediaTypes& parData );
|
||||
|
||||
dinlib::MediaTypes m_default;
|
||||
MediaTypes m_default;
|
||||
#if defined(WITH_MEDIA_AUTODETECT)
|
||||
std::string m_search_path;
|
||||
bool m_force;
|
||||
|
|
|
@ -2,7 +2,6 @@ project(${bare_name}-common CXX C)
|
|||
|
||||
add_library(${PROJECT_NAME}
|
||||
commandline.cpp
|
||||
mediatypes.cpp
|
||||
settings.cpp
|
||||
validationerror.cpp
|
||||
common_info.cpp
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#define idB6191389C4AD4EE5862CCF1591BE6CE5
|
||||
|
||||
#include "dindexer-common/validationerror.hpp"
|
||||
#include "dindexer-common/mediatypes.hpp"
|
||||
#include <boost/program_options/variables_map.hpp>
|
||||
|
||||
namespace din {
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#define id1B7A42F6E46547A6AB0F914E2A91399F
|
||||
|
||||
#include "dindexer-common/validationerror.hpp"
|
||||
#include "dindexer-common/mediatypes.hpp"
|
||||
#include <boost/program_options/variables_map.hpp>
|
||||
|
||||
namespace din {
|
||||
|
|
|
@ -11,6 +11,7 @@ add_library(${PROJECT_NAME} SHARED
|
|||
filesearcher.cpp
|
||||
discinfo.cpp
|
||||
mediatype.cpp
|
||||
mediatypes.cpp
|
||||
machinery_info.cpp
|
||||
guess_content_type.cpp
|
||||
set_listing.cpp
|
||||
|
@ -28,7 +29,6 @@ target_include_directories(${PROJECT_NAME}
|
|||
target_link_libraries(${PROJECT_NAME}
|
||||
PRIVATE ${bare_name}-if
|
||||
PRIVATE ${MAGIC_LIBRARIES}
|
||||
PUBLIC ${bare_name}-common
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace mchlib {
|
|||
};
|
||||
|
||||
struct EntryChecking {
|
||||
typedef bool(*CheckerFunction)(dinlib::MediaTypes, const ConstSetListingView&, const std::vector<const FileRecordData*>&);
|
||||
typedef bool(*CheckerFunction)(MediaTypes, const ConstSetListingView&, const std::vector<const FileRecordData*>&);
|
||||
|
||||
std::size_t max_total_entries;
|
||||
CheckerFunction checker_func;
|
||||
|
@ -87,8 +87,8 @@ namespace mchlib {
|
|||
return std::move(retval);
|
||||
}
|
||||
|
||||
bool identify_video_dvd (dinlib::MediaTypes parMediaType, const ConstSetListingView& parContent, const std::vector<const FileRecordData*>& parFlatContent ) {
|
||||
if (parMediaType != dinlib::MediaType_DVD and parMediaType != dinlib::MediaType_Directory)
|
||||
bool identify_video_dvd (MediaTypes parMediaType, const ConstSetListingView& parContent, const std::vector<const FileRecordData*>& parFlatContent ) {
|
||||
if (parMediaType != MediaType_DVD and parMediaType != MediaType_Directory)
|
||||
return false;
|
||||
|
||||
const auto items_count = count_listing_items(parContent);
|
||||
|
@ -103,8 +103,8 @@ namespace mchlib {
|
|||
return check_missing_content(parFlatContent, should_have).empty();
|
||||
}
|
||||
|
||||
bool identify_video_cd (dinlib::MediaTypes parMediaType, const ConstSetListingView& parContent, const std::vector<const FileRecordData*>& parFlatContent) {
|
||||
if (parMediaType != dinlib::MediaType_CDRom and parMediaType != dinlib::MediaType_Directory)
|
||||
bool identify_video_cd (MediaTypes parMediaType, const ConstSetListingView& parContent, const std::vector<const FileRecordData*>& parFlatContent) {
|
||||
if (parMediaType != MediaType_CDRom and parMediaType != MediaType_Directory)
|
||||
return false;
|
||||
|
||||
const auto items_count = count_listing_items(parContent);
|
||||
|
@ -121,7 +121,7 @@ namespace mchlib {
|
|||
}
|
||||
} //unnamed namespace
|
||||
|
||||
ContentTypes guess_content_type (dinlib::MediaTypes parMediaType, const ConstSetListingView& parContent, std::size_t parEntriesCount) {
|
||||
ContentTypes guess_content_type (MediaTypes parMediaType, const ConstSetListingView& parContent, std::size_t parEntriesCount) {
|
||||
if (boost::empty(parContent))
|
||||
return ContentType_Empty;
|
||||
|
||||
|
@ -145,7 +145,7 @@ namespace mchlib {
|
|||
return ContentType_Generic;
|
||||
}
|
||||
|
||||
ContentTypes guess_content_type (dinlib::MediaTypes parMediaType, const std::vector<FileRecordData>& parContent) {
|
||||
ContentTypes guess_content_type (MediaTypes parMediaType, const std::vector<FileRecordData>& parContent) {
|
||||
if (parContent.empty())
|
||||
return ContentType_Empty;
|
||||
|
||||
|
|
|
@ -40,23 +40,23 @@ namespace mchlib {
|
|||
{
|
||||
}
|
||||
|
||||
dinlib::MediaTypes guess_media_type (std::string&& parPath) {
|
||||
MediaTypes guess_media_type (std::string&& parPath) {
|
||||
DiscInfo info(std::move(parPath));
|
||||
const DriveTypes drive_type = info.drive_type();
|
||||
if (DriveType_HardDisk == drive_type) {
|
||||
if (info.mountpoint() == PathName(info.original_path()).path())
|
||||
return dinlib::MediaType_HardDisk;
|
||||
return MediaType_HardDisk;
|
||||
else
|
||||
return dinlib::MediaType_Directory;
|
||||
return MediaType_Directory;
|
||||
}
|
||||
else if (DriveType_Optical == drive_type) {
|
||||
switch (info.optical_type()) {
|
||||
case OpticalType_DVD:
|
||||
return dinlib::MediaType_DVD;
|
||||
return MediaType_DVD;
|
||||
case OpticalType_CDRom:
|
||||
return dinlib::MediaType_CDRom;
|
||||
return MediaType_CDRom;
|
||||
case OpticalType_BluRay:
|
||||
return dinlib::MediaType_BluRay;
|
||||
return MediaType_BluRay;
|
||||
default:
|
||||
throw UnknownMediaTypeException("Set autodetect failed because this media type is unknown, please specify the set type manually");
|
||||
}
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
* along with "dindexer". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "dindexer-common/mediatypes.hpp"
|
||||
#include "dindexer-machinery/mediatypes.hpp"
|
||||
#include <map>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace dinlib {
|
||||
namespace mchlib {
|
||||
const std::string& media_type_to_str (MediaTypes parType) {
|
||||
static const std::map<MediaTypes, const std::string> types {
|
||||
{MediaType_CDRom, "CD-Rom"},
|
||||
|
@ -43,4 +43,4 @@ namespace dinlib {
|
|||
MediaTypes char_to_media_type (char parMType) {
|
||||
return static_cast<MediaTypes>(parMType);
|
||||
}
|
||||
} //namespace dinlib
|
||||
} //namespace mchlib
|
|
@ -25,7 +25,7 @@
|
|||
namespace mchlib {
|
||||
namespace scantask {
|
||||
MediaType::MediaType (char parDefault, bool parForce, std::string parSearchPath) :
|
||||
m_default(dinlib::char_to_media_type(parDefault))
|
||||
m_default(char_to_media_type(parDefault))
|
||||
#if defined(WITH_MEDIA_AUTODETECT)
|
||||
, m_search_path(std::move(parSearchPath))
|
||||
, m_force(parForce)
|
||||
|
@ -37,11 +37,11 @@ namespace mchlib {
|
|||
#endif
|
||||
}
|
||||
|
||||
void MediaType::on_data_destroy (dinlib::MediaTypes& parData) {
|
||||
parData = dinlib::MediaType_Other;
|
||||
void MediaType::on_data_destroy (MediaTypes& parData) {
|
||||
parData = MediaType_Other;
|
||||
}
|
||||
|
||||
void MediaType::on_data_create (dinlib::MediaTypes& parData) {
|
||||
void MediaType::on_data_create (MediaTypes& parData) {
|
||||
#if defined(WITH_MEDIA_AUTODETECT)
|
||||
if (m_force) {
|
||||
parData = m_default;
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#define id1B7A42F6E46547A6AB0F914E2A91399F
|
||||
|
||||
#include "dindexer-common/validationerror.hpp"
|
||||
#include "dindexer-common/mediatypes.hpp"
|
||||
#include <boost/program_options/variables_map.hpp>
|
||||
|
||||
namespace din {
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#define id259FD7C96B5049ECB50386F25455FBB2
|
||||
|
||||
#include "dindexer-common/validationerror.hpp"
|
||||
#include "dindexer-common/mediatypes.hpp"
|
||||
#include <boost/program_options/variables_map.hpp>
|
||||
|
||||
namespace din {
|
||||
|
|
|
@ -27,14 +27,14 @@ namespace po = boost::program_options;
|
|||
namespace din {
|
||||
namespace {
|
||||
const char g_allowed_types[] = {
|
||||
static_cast<char>(dinlib::MediaType_CDRom),
|
||||
static_cast<char>(dinlib::MediaType_Directory),
|
||||
static_cast<char>(dinlib::MediaType_DVD),
|
||||
static_cast<char>(dinlib::MediaType_BluRay),
|
||||
static_cast<char>(dinlib::MediaType_FloppyDisk),
|
||||
static_cast<char>(dinlib::MediaType_HardDisk),
|
||||
static_cast<char>(dinlib::MediaType_IomegaZip),
|
||||
static_cast<char>(dinlib::MediaType_Other)
|
||||
static_cast<char>(mchlib::MediaType_CDRom),
|
||||
static_cast<char>(mchlib::MediaType_Directory),
|
||||
static_cast<char>(mchlib::MediaType_DVD),
|
||||
static_cast<char>(mchlib::MediaType_BluRay),
|
||||
static_cast<char>(mchlib::MediaType_FloppyDisk),
|
||||
static_cast<char>(mchlib::MediaType_HardDisk),
|
||||
static_cast<char>(mchlib::MediaType_IomegaZip),
|
||||
static_cast<char>(mchlib::MediaType_Other)
|
||||
};
|
||||
} //unnamed namespace
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#define id1B7A42F6E46547A6AB0F914E2A91399F
|
||||
|
||||
#include <boost/program_options/variables_map.hpp>
|
||||
#include "dindexer-machinery/mediatypes.hpp"
|
||||
#include "dindexer-machinery/mediatype.hpp"
|
||||
|
||||
namespace din {
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
namespace {
|
||||
template <std::size_t N>
|
||||
void detect_type (mchlib::FileRecordData (&parTestData)[N], mchlib::ContentTypes parExpected, dinlib::MediaTypes parMediaType) {
|
||||
void detect_type (mchlib::FileRecordData (&parTestData)[N], mchlib::ContentTypes parExpected, mchlib::MediaTypes parMediaType) {
|
||||
using mchlib::SetListing;
|
||||
using mchlib::FileRecordData;
|
||||
|
||||
|
@ -52,7 +52,7 @@ TEST(machinery, guess_content_type) {
|
|||
FileRecordData("VIDEO_TS/VTS_01_0.VOB",0,0,2,false,false),
|
||||
FileRecordData("VIDEO_TS/VIDEO_TS.VOB",0,0,2,false,false)
|
||||
};
|
||||
detect_type(test_data, mchlib::ContentType_VideoDVD, dinlib::MediaType_DVD);
|
||||
detect_type(test_data, mchlib::ContentType_VideoDVD, mchlib::MediaType_DVD);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -63,7 +63,7 @@ TEST(machinery, guess_content_type) {
|
|||
FileRecordData("some_file.bin",0,0,1,false,false),
|
||||
FileRecordData("another_dir/VTS_01_0.BUP",0,0,2,false,false)
|
||||
};
|
||||
detect_type(test_data, mchlib::ContentType_Generic, dinlib::MediaType_Directory);
|
||||
detect_type(test_data, mchlib::ContentType_Generic, mchlib::MediaType_Directory);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -81,6 +81,6 @@ TEST(machinery, guess_content_type) {
|
|||
FileRecordData("CDI",0,0,1,true,false),
|
||||
FileRecordData("KARAOKE",0,0,1,true,false)
|
||||
};
|
||||
detect_type(test_data, mchlib::ContentType_VideoCD, dinlib::MediaType_CDRom);
|
||||
detect_type(test_data, mchlib::ContentType_VideoCD, mchlib::MediaType_CDRom);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue