Source

libtaginfo / tests / write_xm / main.cc

Full commit
#include "taginfo.h"
#include <stdio.h>
#include <iostream>
#include <fstream>

#define TESTNAME "xyz ü1 23"

using namespace TagInfo;

int main( void ) {
    Info * info;
    std::string val = TESTDIR "samples/sample.xm";
    //std::cout << std::endl << "val: " << val << std::endl;
    
    std::string target("/tmp/out_01.xm");
    
    std::ifstream  src(val.c_str());
    std::ofstream  dst(target.c_str());
    dst << src.rdbuf();
    
    StringList labels = StringList();
    labels.append("user label1 äöüé");
    labels.append("user label1 äiiüé");
    
    info = Info::create_tag_info(target);
    if( info ) {
        info->set_artist("artißt");
        info->set_genre("gen re");
        info->set_composer("cömpozér");
        info->set_year(1982);
        info->set_rating(0);
        info->set_title("titlöe");
        info->set_original_artist ("ürgar t");
        info->set_homepage("ööö");
        info->set_encoder("encödr");
        info->set_track_number(2);
        info->set_track_count(5);
        info->set_volume_number(1);
        info->set_volume_count(3);
        info->set_copyright("Cöpppyright");
        info->set_album_artist("äöé");
        info->set_is_compilation(true);
//        info->set_comments("Cömmméé\nèntß"); // COMMENT NOT WORKING!
        info->set_album_labels_list(labels);
        info->set_artist_labels_list(labels);
        info->set_track_labels_list(labels);
        info->save();
    }
    else {
        return EXIT_FAILURE;
    }
    delete info;
    info = NULL;
    
    info = Info::create_tag_info(target);
    if( info ) {
        if( info->load() ) {
//            std::cout << "info->get_comments(): " << info->get_comments() << std::endl;
            if(info->get_title() == "titlöe") {
                delete info;
                if(remove(target.c_str()) != 0 )
                    return EXIT_FAILURE;
                return EXIT_SUCCESS;
            }
        }
        delete info;
        if(remove(target.c_str()) != 0 )
            return EXIT_FAILURE;
        return EXIT_FAILURE;
    }
    else {
        delete info;
        if(remove(target.c_str()) != 0 )
            return EXIT_FAILURE;
        return EXIT_FAILURE;
    }
}