4c75f9e
/**************************************************************************
4c75f9e
**
4c75f9e
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
4c75f9e
** Contact: http://www.qt-project.org/legal
4c75f9e
**
4c75f9e
** This file is part of Qt Creator.
4c75f9e
**
4c75f9e
** Commercial License Usage
4c75f9e
** Licensees holding valid commercial Qt licenses may use this file in
4c75f9e
** accordance with the commercial license agreement provided with the
4c75f9e
** Software or, alternatively, in accordance with the terms contained in
4c75f9e
** a written agreement between you and Digia.  For licensing terms and
4c75f9e
** conditions see http://qt.digia.com/licensing.  For further information
4c75f9e
** use the contact form at http://qt.digia.com/contact-us.
4c75f9e
**
4c75f9e
** GNU Lesser General Public License Usage
4c75f9e
** Alternatively, this file may be used under the terms of the GNU Lesser
4c75f9e
** General Public License version 2.1 as published by the Free Software
4c75f9e
** Foundation and appearing in the file LICENSE.LGPL included in the
4c75f9e
** packaging of this file.  Please review the following information to
4c75f9e
** ensure the GNU Lesser General Public License version 2.1 requirements
4c75f9e
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
4c75f9e
**
4c75f9e
** In addition, as a special exception, Digia gives you certain additional
4c75f9e
** rights.  These rights are described in the Digia Qt LGPL Exception
4c75f9e
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
4c75f9e
**
4c75f9e
****************************************************************************/
4c75f9e
4c75f9e
#ifndef HOSTOSINFO_H
4c75f9e
#define HOSTOSINFO_H
4c75f9e
4c75f9e
#include "utils_global.h"
4c75f9e
4c75f9e
#include <QString>
4c75f9e
4c75f9e
#ifdef Q_OS_WIN
4c75f9e
#define QTC_HOST_EXE_SUFFIX ".exe"
4c75f9e
#else
4c75f9e
#define QTC_HOST_EXE_SUFFIX ""
4c75f9e
#endif // Q_OS_WIN
4c75f9e
4c75f9e
namespace Utils {
4c75f9e
4c75f9e
class QTCREATOR_UTILS_EXPORT HostOsInfo
4c75f9e
{
4c75f9e
public:
4c75f9e
    // Add more as needed.
4c75f9e
    enum HostOs { HostOsWindows, HostOsLinux, HostOsMac, HostOsOtherUnix, HostOsOther };
4c75f9e
    static inline HostOs hostOs();
4c75f9e
4c75f9e
    enum HostArchitecture { HostArchitectureX86, HostArchitectureAMD64, HostArchitectureItanium,
4c75f9e
                            HostArchitectureArm, HostArchitectureUnknown };
4c75f9e
    static HostArchitecture hostArchitecture();
4c75f9e
4c75f9e
    static bool isWindowsHost() { return hostOs() == HostOsWindows; }
4c75f9e
    static bool isLinuxHost() { return hostOs() == HostOsLinux; }
4c75f9e
    static bool isMacHost() { return hostOs() == HostOsMac; }
4c75f9e
    static inline bool isAnyUnixHost();
4c75f9e
4c75f9e
    static QString withExecutableSuffix(const QString &executable)
4c75f9e
    {
4c75f9e
        QString finalName = executable;
4c75f9e
        if (isWindowsHost())
4c75f9e
            finalName += QLatin1String(QTC_HOST_EXE_SUFFIX);
4c75f9e
        return finalName;
4c75f9e
    }
4c75f9e
4c75f9e
    static Qt::CaseSensitivity fileNameCaseSensitivity()
4c75f9e
    {
4c75f9e
        return isWindowsHost() ? Qt::CaseInsensitive: Qt::CaseSensitive;
4c75f9e
    }
4c75f9e
4c75f9e
    static QChar pathListSeparator()
4c75f9e
    {
4c75f9e
        return isWindowsHost() ? QLatin1Char(';') : QLatin1Char(':');
4c75f9e
    }
4c75f9e
4c75f9e
    static Qt::KeyboardModifier controlModifier()
4c75f9e
    {
4c75f9e
        return isMacHost() ? Qt::MetaModifier : Qt::ControlModifier;
4c75f9e
    }
4c75f9e
};
4c75f9e
4c75f9e
HostOsInfo::HostOs HostOsInfo::hostOs()
4c75f9e
{
4c75f9e
#if defined(Q_OS_WIN)
4c75f9e
    return HostOsWindows;
4c75f9e
#elif defined(Q_OS_LINUX)
4c75f9e
    return HostOsLinux;
4c75f9e
#elif defined(Q_OS_MAC)
4c75f9e
    return HostOsMac;
4c75f9e
#elif defined(Q_OS_UNIX)
4c75f9e
    return HostOsOtherUnix;
4c75f9e
#else
4c75f9e
    return HostOsOther;
4c75f9e
#endif
4c75f9e
}
4c75f9e
4c75f9e
bool HostOsInfo::isAnyUnixHost()
4c75f9e
{
4c75f9e
#ifdef Q_OS_UNIX
4c75f9e
    return true;
4c75f9e
#else
4c75f9e
    return false;
4c75f9e
#endif
4c75f9e
}
4c75f9e
4c75f9e
} // namespace Utils
4c75f9e
4c75f9e
#endif // HOSTOSINFO_H