MCPcopy Create free account
hub / github.com/clementgallet/libTAS / update

Method update

src/program/AutoSave.cpp:32–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30static int nb_frame_advance = 0;
31
32void AutoSave::update(Context* context, MovieFile& movie)
33{
34 /* Check if autosave is enabled */
35 if (!context->config.autosave)
36 return;
37
38 /* Check if the movie was modified */
39 if (!movie.inputs->modifiedSinceLastAutoSave)
40 return;
41
42 /* Update the frame counter and check if we must auto-save */
43 if ((++nb_frame_advance > context->config.autosave_frames) &&
44 (difftime(time(nullptr), last_time_saved) > context->config.autosave_delay_sec))
45 {
46 nb_frame_advance = 0;
47 time(&last_time_saved);
48
49 /* Build the autosave filename */
50 std::filesystem::path moviename = context->config.moviefile.stem();
51
52 /* We remove old saves here while we have the correct movie name */
53 removeOldSaves(context, moviename.string());
54
55 moviename = context->config.tempmoviedir / moviename;
56
57 char buf[32];
58 strftime(buf, 32, "_%Y%m%d-%H%M%S.ltm", localtime(&last_time_saved));
59
60 moviename += buf;
61
62 std::cout << "Autosave movie to " << moviename << std::endl;
63
64 /* Save the movie */
65 movie.saveMovie(moviename);
66
67 movie.inputs->modifiedSinceLastAutoSave = false;
68 }
69}
70
71void AutoSave::removeOldSaves(Context* context, const std::string& moviename)
72{

Callers 6

QHexViewMethod · 0.45
checkAndUpdateMethod · 0.45
ensureVisibleMethod · 0.45
focusInEventMethod · 0.45
focusOutEventMethod · 0.45
mousePressEventMethod · 0.45

Calls 2

timeFunction · 0.85
saveMovieMethod · 0.80

Tested by

no test coverage detected