| 166 | } |
| 167 | |
| 168 | ProjectProperties 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 | |
| 200 | void SubsController::Save(agi::fs::path const& filename, const char *encoding) { |
| 201 | const SubtitleFormat *writer = SubtitleFormat::GetWriter(filename); |