Why does the command 'touch -t' via QProcess only works for Android 7+?
-
For my Android App I need to edit my photos and keep the original date and time for Android 5.1 - 9. But the timestamp is only changed for Android 7+.
QString fileDate = reader.text("date"); QDate date = QDate::fromString(fileDate, "yyyy-MM-dd"); QString fileTime = reader.text("time"); QTime time = QTime::fromString(fileTime, "HH:mm:ss"); QString dateTimeStrg; if(date.isValid() && time.isValid()) { QDateTime dateTime(date, time); dateTimeStrg = dateTime.toString("yyMMddhhmm.ss"); QProcess process; process.start("touch", QStringList() << "-t" << dateTimeStrg << filePath); process.waitForFinished(); qInfo() << "error" << process.error(); // QProcess::UnknownError }
Does anyone know what I'm doing wrong?
-
For my Android App I need to edit my photos and keep the original date and time for Android 5.1 - 9. But the timestamp is only changed for Android 7+.
QString fileDate = reader.text("date"); QDate date = QDate::fromString(fileDate, "yyyy-MM-dd"); QString fileTime = reader.text("time"); QTime time = QTime::fromString(fileTime, "HH:mm:ss"); QString dateTimeStrg; if(date.isValid() && time.isValid()) { QDateTime dateTime(date, time); dateTimeStrg = dateTime.toString("yyMMddhhmm.ss"); QProcess process; process.start("touch", QStringList() << "-t" << dateTimeStrg << filePath); process.waitForFinished(); qInfo() << "error" << process.error(); // QProcess::UnknownError }
Does anyone know what I'm doing wrong?
@PowerNow
This will not be an error from usingQProcess
nor with your code. You should look at thetouch -t
command you are using and the Android version. Maybe the option changed or the format of the argument?If
touch
is perhaps reporting an error you are not checking for it. You should check for error codes, and read stdout/err fromQProcess
to see if a message is being sent there. -
@JonB Thks! I forgot to mention that I check the error via process.error(), it's for all versions QProcess::UnknownError, the default value. Yes if it depends from the Android Version, where can I find this?
-
@JonB Thks! I forgot to mention that I check the error via process.error(), it's for all versions QProcess::UnknownError, the default value. Yes if it depends from the Android Version, where can I find this?
@PowerNow
I meant you need to look at something like https://doc.qt.io/qt-5/qprocess.html#readAllStandardError (andreadAllStandardOutput()
too just in case).For the Android version differences, I don't use Android, so I'd have to Google, which is what you would need to do. Or find an Android forum to ask.
-
I just checked it with readAllStandardError() and get for Android 5x,6x:
"touch: invalid timestamp specified\n"I tried the following:
[[CC]YY]MMDDhhmm[.ss]
"201912051120.11"
[YY]MMDDhhmm[.ss]
"1912051120.11"
MMDDhhmm[.ss]
"12051120.11"
MMDDhhmm
"12051120"But always the same error...
-
I just checked it with readAllStandardError() and get for Android 5x,6x:
"touch: invalid timestamp specified\n"I tried the following:
[[CC]YY]MMDDhhmm[.ss]
"201912051120.11"
[YY]MMDDhhmm[.ss]
"1912051120.11"
MMDDhhmm[.ss]
"12051120.11"
MMDDhhmm
"12051120"But always the same error...
-
I just checked it with readAllStandardError() and get for Android 5x,6x:
"touch: invalid timestamp specified\n"I tried the following:
[[CC]YY]MMDDhhmm[.ss]
"201912051120.11"
[YY]MMDDhhmm[.ss]
"1912051120.11"
MMDDhhmm[.ss]
"12051120.11"
MMDDhhmm
"12051120"But always the same error...