Created
September 8, 2017 08:49
-
-
Save 0xlitf/a983959341595cbcd608fd71de342efa to your computer and use it in GitHub Desktop.
qt file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
QString LoginWrapper::getToken() { | |
qDebug() << "m_tokenFilename: " << m_tokenFilename; | |
QFile file(m_tokenFilename); | |
if (!file.exists()) { | |
file.open( QIODevice::ReadWrite | QIODevice::Text ); | |
file.close(); | |
} | |
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { | |
return ""; | |
} | |
QTextStream in(&file); | |
auto all = in.readAll(); | |
qDebug() << "all: " << all; | |
return all; | |
} | |
void LoginWrapper::clearToken() { | |
QFile file(m_tokenFilename); | |
if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) { | |
return; | |
} | |
file.resize(0); | |
} | |
void LoginWrapper::saveToken(const QString& token) { | |
QFile file(m_tokenFilename); | |
if(!file.open(QIODevice::ReadWrite | QIODevice::Text)) { | |
return; | |
} | |
QTextStream in(&file); | |
in << token; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment