MCPcopy Create free account
hub / github.com/TypesettingTools/Aegisub / Load

Method Load

src/subs_controller.cpp:168–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166}
167
168ProjectProperties SubsController::Load(agi::fs::path const& filename, const char *charset) {
169 AssFile temp;
170
171 SubtitleFormat::GetReader(filename, charset)->ReadFile(&temp, filename, context->project->Timecodes(), charset);
172
173 context->ass->swap(temp);
174 auto props = context->ass->Properties;
175
176 SetFileName(filename);
177
178 // Push the initial state of the file onto the undo stack
179 undo_stack.clear();
180 redo_stack.clear();
181 autosaved_commit_id = saved_commit_id = commit_id + 1;
182 context->ass->Commit("", AssFile::COMMIT_NEW);
183
184 // Save backup of file
185 if (CanSave() && OPT_GET("App/Auto/Backup")->GetBool()) {
186 auto path_str = OPT_GET("Path/Auto/Backup")->GetString();
187 agi::fs::path path;
188 if (path_str.empty())
189 path = filename.parent_path();
190 else
191 path = context->path->Decode(path_str);
192 agi::fs::CreateDirectory(path);
193 agi::fs::Copy(filename, path/(filename.stem().string() + ".ORIGINAL" + filename.extension().string()));
194 }
195
196 FileOpen(filename);
197 return props;
198}
199
200void SubsController::Save(agi::fs::path const& filename, const char *encoding) {
201 const SubtitleFormat *writer = SubtitleFormat::GetWriter(filename);

Callers 2

ReadFileMethod · 0.45
DoLoadSubtitlesMethod · 0.45

Calls 7

swapMethod · 0.80
DecodeMethod · 0.80
stringMethod · 0.80
CopyFunction · 0.50
ReadFileMethod · 0.45
clearMethod · 0.45
CommitMethod · 0.45

Tested by

no test coverage detected