myxlib/src/myx/filesystem/current_executable.cpp

43 lines
861 B
C++

#include <myx/base/config.hpp>
#include <myx/filesystem/current_executable.hpp>
#include <paths.h>
#include <QString>
#include <QCoreApplication>
namespace myx {
namespace filesystem {
CurrentExecutable::CurrentExecutable() :
m_procFilePath( QStringLiteral( "/proc/self/exe" ) )
{
auto canonicalFilePath = m_procFilePath.canonicalFilePath();
auto canonicalPath = m_procFilePath.canonicalPath();
m_fileName = canonicalFilePath.remove( canonicalPath ).remove( '/' );
m_canonicalFilePath = canonicalFilePath;
m_canonicalPath = canonicalPath;
}
QFileInfo CurrentExecutable::canonicalFilePath() const
{
return( m_canonicalFilePath );
}
QDir CurrentExecutable::canonicalPath() const
{
return( m_canonicalPath );
}
QString CurrentExecutable::fileName() const
{
return( m_fileName );
}
} // namespace filesystem
} // namespace myx