문제

Here's the code I have right now

/* Rename existing project files to .old */
if (FileIOUtil::fileExists(dest, outFileName))
{
  QFile oldFile(outFileName);
  QFileInfo fileInfo; fileInfo.setFile(oldFile);
  QDateTime created = fileInfo.lastModified();
  FileIOUtil::mvFile(dest, outFileName,
                     dest, outFileName + ".old" + created.toString());
}

Note: mvfile works like the unix command mv. It just moves a file to a new name.

However, this renames my project.c to project.c.old.Thu Jan 1 01:00:00 1970. I'm pretty sure the files I'm trying to rename aren't that old ;)

Any ideas why I'm getting the epoch as a result?

도움이 되었습니까?

해결책

I had to modify the following line:

QFile oldFile(outFileName);

to

QFile oldFile(dest + outFileName);

Or as @Riateche mentioned in his comment, remove oldFile and fileInfo variables completely and do:

QFileInfo(dest+outFileName).created();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top