Why does the command 'touch -t' via QProcess only works for Android 7+?
-
wrote on 5 Dec 2019, 16:58 last edited by PowerNow 12 Jun 2019, 07:05
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?
wrote on 5 Dec 2019, 22:18 last edited by@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. -
wrote on 6 Dec 2019, 07:04 last edited by PowerNow 12 Jun 2019, 07:13
@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?
-
@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?
wrote on 6 Dec 2019, 07:44 last edited by@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.
-
wrote on 6 Dec 2019, 08:49 last edited by
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...
@PowerNow Then you need to check what formats that version of touch supports.
-
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...
1/8