4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "awindowgui.inc"
31 #include "filesystem.h"
32 #include "indexfile.h"
33 #include "quicktime.h"
34 #include "mainsession.h"
35 #include "threadindexer.h"
38 Assets::Assets(EDL *edl) : List<Asset>()
48 int Assets::load(FileXML *file, uint32_t load_flags)
54 result = file->read_tag();
57 if(file->tag.title_is("/ASSETS"))
62 if(file->tag.title_is("ASSET"))
64 const char *path = file->tag.get_property("SRC");
65 if(path && path[0] != 0)
67 Asset *new_asset = new Asset(path);
68 new_asset->read(file);
69 Asset *asset = update(new_asset);
70 asset->copy_from(new_asset,1);
71 new_asset->Garbage::remove_user();
79 int Assets::save(FileXML *file, char *path)
81 file->tag.set_title("ASSETS");
83 file->append_newline();
85 for(Asset* current = first; current; current = NEXT)
92 file->tag.set_title("/ASSETS");
94 file->append_newline();
95 file->append_newline();
99 void Assets::copy_from(Assets *assets)
103 for(Asset *current = assets->first; current; current = NEXT)
106 append(new_asset = new Asset);
107 new_asset->copy_from(current, 1);
111 Assets& Assets::operator=(Assets &assets)
113 printf("Assets::operator= 1\n");
119 void Assets::update_index(Asset *asset)
122 for(Asset* current = first; current; current = NEXT)
124 if(current->test_path(asset->path))
126 current->update_index(asset);
131 Asset* Assets::update(Asset *asset)
135 for(Asset* current = first; current; current = NEXT)
137 // Asset already exists.
138 if(current->test_path(asset->path))
144 // Asset doesn't exist.
145 Asset *asset_copy = new Asset(*asset);
150 int Assets::delete_all()
159 Asset* Assets::update(const char *path)
161 Asset* current = first;
165 if(current->test_path(path))
172 return append(new Asset(path));
175 Asset* Assets::get_asset(const char *filename)
177 Asset* current = first;
182 //printf("Assets::get_asset %p %s\n", filename, filename);
183 if(current->test_path(filename))
188 current = current->next;
194 void Assets::remove_asset(Asset *asset)
196 remove_pointer(asset);
197 asset->Garbage::remove_user();
201 int Assets::number_of(Asset *asset)
206 for(i = 0, current = first; current && current != asset; i++, current = NEXT)
212 Asset* Assets::asset_number(int number)
217 for(i = 0, current = first; i < number && current; i++, current = NEXT)
223 int Assets::update_old_filename(char *old_filename, char *new_filename)
225 for(Asset* current = first; current; current = NEXT)
227 if(!strcmp(current->path, old_filename))
229 current->update_path(new_filename);
236 int Assets::dump(FILE *fp)
238 for(Asset *current = first; current; current = NEXT)