Esempio n. 1
0
void TrackInfoObject::parse() {
    // Log parsing of header information in developer mode. This is useful for
    // tracking down corrupt files.
    const QString& canonicalLocation = m_fileInfo.canonicalFilePath();
    if (CmdlineArgs::Instance().getDeveloper()) {
        qDebug() << "TrackInfoObject::parse()" << canonicalLocation;
    }

    // Parse the information stored in the sound file.
    SoundSourceProxy proxy(canonicalLocation, m_pSecurityToken);
    Mixxx::SoundSource* pProxiedSoundSource = proxy.getProxiedSoundSource();
    if (pProxiedSoundSource != NULL && proxy.parseHeader() == OK) {

        // Dump the metadata extracted from the file into the track.

        // TODO(XXX): This involves locking the mutex for every setXXX
        // method. We should figure out an optimization where there are private
        // setters that don't lock the mutex.

        // If Artist, Title and Type fields are not blank, modify them.
        // Otherwise, keep their current values.
        // TODO(rryan): Should we re-visit this decision?
        if (!(pProxiedSoundSource->getArtist().isEmpty())) {
            setArtist(pProxiedSoundSource->getArtist());
        }

        if (!(pProxiedSoundSource->getTitle().isEmpty())) {
            setTitle(pProxiedSoundSource->getTitle());
        }

        if (!(pProxiedSoundSource->getType().isEmpty())) {
            setType(pProxiedSoundSource->getType());
        }

        setAlbum(pProxiedSoundSource->getAlbum());
        setAlbumArtist(pProxiedSoundSource->getAlbumArtist());
        setYear(pProxiedSoundSource->getYear());
        setGenre(pProxiedSoundSource->getGenre());
        setComposer(pProxiedSoundSource->getComposer());
        setGrouping(pProxiedSoundSource->getGrouping());
        setComment(pProxiedSoundSource->getComment());
        setTrackNumber(pProxiedSoundSource->getTrackNumber());
        setReplayGain(pProxiedSoundSource->getReplayGain());
        setBpm(pProxiedSoundSource->getBPM());
        setDuration(pProxiedSoundSource->getDuration());
        setBitrate(pProxiedSoundSource->getBitrate());
        setSampleRate(pProxiedSoundSource->getSampleRate());
        setChannels(pProxiedSoundSource->getChannels());
        setKeyText(pProxiedSoundSource->getKey(),
                   mixxx::track::io::key::FILE_METADATA);
        setHeaderParsed(true);
    } else {
        qDebug() << "TrackInfoObject::parse() error at file"
                 << canonicalLocation;
        setHeaderParsed(false);

        // Add basic information derived from the filename:
        parseFilename();
    }
}
Esempio n. 2
0
Log::Log(const String& filename) {
    this->filename = filename;

    logFile = FileSystem::fopen(filename.c_str(), "w");

    if (logFile == NULL) {
        String drive, base, ext;
        Array<String> path;
        parseFilename(filename, drive, path, base, ext);
        String logName = base + ((ext != "") ? ("." + ext) : ""); 

        // Write time is greater than 1ms.  This may be a network drive.... try another file.
        #ifdef G3D_WINDOWS
            logName = String(std::getenv("TEMP")) + logName;
        #else
            logName = String("/tmp/") + logName;
        #endif

        logFile = FileSystem::fopen(logName.c_str(), "w");
    }

    // Use a large buffer (although we flush in logPrintf)
    setvbuf(logFile, NULL, _IOFBF, 2048);

    fprintf(logFile, "Application Log\n");
    time_t t;
    time(&t);
    fprintf(logFile, "Start: %s\n", ctime(&t));
    fflush(logFile);

    if (commonLog == NULL) {
        commonLog = this;
    }
}
Esempio n. 3
0
MilkdropPreset::MilkdropPreset(const std::string & absoluteFilePath, const std::string & presetName, PresetOutputs & presetOutputs):
	Preset(presetName),
    builtinParams(_presetInputs, presetOutputs),
    _absoluteFilePath(absoluteFilePath),
    _presetOutputs(presetOutputs),
    _filename(parseFilename(absoluteFilePath))
{

  initialize(absoluteFilePath);

}
Esempio n. 4
0
void pageTab::setText(string path)
{
	textPath = path;
	parseFilename();
	QFile* file = new QFile((QString)textPath.c_str());
	file->open(QIODevice::ReadOnly);
	QByteArray* temp = new QByteArray;
	*temp = file->readAll();
	QString* text_to_set = new QString(*temp);
	textEdit->setText(*text_to_set);
	delete text_to_set;
	delete temp;
	delete file;
}
Esempio n. 5
0
void BinaryOutput::commit(bool flush) {
    debugAssertM(! m_committed, "Cannot commit twice");
    m_committed = true;
    debugAssertM(m_beginEndBits == 0, "Missing endBits before commit");

    if (m_filename == "<memory>") {
        return;
    }

    // Make sure the directory exists.
    std::string root, base, ext, path;
    Array<std::string> pathArray;
    parseFilename(m_filename, root, pathArray, base, ext); 

    path = root + stringJoin(pathArray, '/');
    if (! FileSystem::exists(path, false)) {
        FileSystem::createDirectory(path);
    }

    const char* mode = (m_alreadyWritten > 0) ? "ab" : "wb";

    alwaysAssertM(m_filename != "<memory>", "Writing to memory file");
    FILE* file = FileSystem::fopen(m_filename.c_str(), mode);

    if (! file) {
        logPrintf("Error %d while trying to open \"%s\"\n", errno, m_filename.c_str());
    }
    m_ok = (file != NULL) && m_ok;

    if (m_ok) {
        debugAssertM(file, std::string("Could not open '") + m_filename + "'");

        if (m_buffer != NULL) {
            m_alreadyWritten += m_bufferLen;

            size_t success = fwrite(m_buffer, m_bufferLen, 1, file);
            (void)success;
            debugAssertM(success == 1, std::string("Could not write to '") + m_filename + "'");
        }
        if (flush) {
            fflush(file);
        }
        FileSystem::fclose(file);
        file = NULL;
    }
}
Esempio n. 6
0
void ChecksumValidator::load(std::istream &stream) {
    m_sums.clear();

    std::string line;
    std::size_t lineNum = 1;
    while (std::getline(stream, line, PathConfig::StoragePath::recordSeparator)) {
        try {
            std::size_t beginToken = 0;
            std::string filename = parseFilename(line, beginToken);
            std::string checksum = parseChecksum(line, beginToken);

            m_sums.insert({ filename, checksum });
            ++lineNum;
        } catch (const ChecksumRecordCorruptedException &ex) {
            throw ex.withLineNumber(lineNum);
        }
    }
};
Esempio n. 7
0
void BinaryOutput::commit(bool flush) {
    debugAssertM(! m_committed, "Cannot commit twice");
    m_committed = true;
    debugAssertM(m_beginEndBits == 0, "Missing endBits before commit");

    // Make sure the directory exists.
    std::string root, base, ext, path;
    Array<std::string> pathArray;
    parseFilename(m_filename, root, pathArray, base, ext); 

    path = root + stringJoin(pathArray, '/');
    if (! fileExists(path, false)) {
        createDirectory(path);
    }

    const char* mode = (m_alreadyWritten > 0) ? "ab" : "wb";

    FILE* file = fopen(m_filename.c_str(), mode);

    m_ok = (file != NULL) && m_ok;

    if (m_ok) {
        debugAssertM(file, std::string("Could not open '") + m_filename + "'");

        if (m_buffer != NULL) {
            m_alreadyWritten += m_bufferLen;

            int success = fwrite(m_buffer, m_bufferLen, 1, file);
            (void)success;
            debugAssertM(success == 1, std::string("Could not write to '") + m_filename + "'");
        }
        if (flush) {
            fflush(file);
        }
        fclose(file);
        file = NULL;
    }
}
Esempio n. 8
0
void pageTab::setImage(string path)
{
	imagePath = path;
	parseFilename();
	scanImage->load(tr(imagePath.c_str()));

	int* before = new int; // holds the width before scaling
	int* after = new int; // holds the width after scaling

	QImage resizeImg = scanImage->toImage();
	*before = resizeImg.width();
		
	resizeImg = resizeImg.scaledToWidth(scaled_width);
	*after = resizeImg.width();
		
	resizeFactor = ((float)(*after)) / ((float)(*before));
	qDebug() << "Resize factor: " << resizeFactor;

	*scanImage = QPixmap::fromImage(resizeImg);
	delete [] before;
	delete [] after; 

	imgView->setPixmap(*scanImage);
}