Ticket #3928: 3928_screenshots.patch

File 3928_screenshots.patch, 964 bytes (added by Vladislav Belov, 8 years ago)

Adds a date part to the screenshot path

  • source/ps/Util.cpp

     
    236236void WriteScreenshot(const VfsPath& extension)
    237237{
    238238    // get next available numbered filename
    239     // note: %04d -> always 4 digits, so sorting by filename works correctly.
    240     const VfsPath basenameFormat(L"screenshots/screenshot%04d");
     239    wchar_t basenameBuffer[100] = { '\0' };
     240    time_t seconds;
     241    time(&seconds);
     242    struct tm* current_time = gmtime(&seconds);
     243    const size_t charsWritten = wcsftime(basenameBuffer, ARRAY_SIZE(basenameBuffer), L"screenshots/screenshot_%Y-%m-%d_%H-%M-%S_%%03d", current_time);
     244    ENSURE(charsWritten != 0);
     245
     246    const VfsPath basenameFormat(basenameBuffer);
    241247    const VfsPath filenameFormat = basenameFormat.ChangeExtension(extension);
    242248    VfsPath filename;
    243249    vfs::NextNumberedFilename(g_VFS, filenameFormat, s_nextScreenshotNumber, filename);