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 "mainsession.h"
34 #include "threadindexer.h"
37 Assets::Assets(EDL *edl) : List<Asset>()
47 int Assets::load(FileXML *file, uint32_t load_flags)
53 result = file->read_tag();
56 if(file->tag.title_is("/ASSETS"))
61 if(file->tag.title_is("ASSET"))
63 const char *path = file->tag.get_property("SRC");
64 if(path && path[0] != 0)
66 Asset *new_asset = new Asset(path);
67 new_asset->read(file);
69 new_asset->Garbage::remove_user();
77 int Assets::save(FileXML *file, char *path)
79 file->tag.set_title("ASSETS");
81 file->append_newline();
83 for(Asset* current = first; current; current = NEXT)
90 file->tag.set_title("/ASSETS");
92 file->append_newline();
93 file->append_newline();
97 void Assets::copy_from(Assets *assets)
101 for(Asset *current = assets->first; current; current = NEXT)
104 append(new_asset = new Asset);
105 new_asset->copy_from(current, 1);
109 void Assets::update_index(Asset *asset)
112 for(Asset* current = first; current; current = NEXT)
114 if(current->test_path(asset->path))
116 current->update_index(asset);
121 Asset* Assets::update(Asset *asset)
125 for(Asset* current = first; current; current = NEXT)
127 // Asset already exists.
128 if(current->test_path(asset->path))
134 // Asset doesn't exist.
135 Asset *asset_copy = new Asset(*asset);
140 int Assets::delete_all()
149 Asset* Assets::update(const char *path)
151 Asset* current = first;
155 if(current->test_path(path))
162 return append(new Asset(path));
165 Asset* Assets::get_asset(const char *filename)
167 Asset* current = first;
172 //printf("Assets::get_asset %p %s\n", filename, filename);
173 if(current->test_path(filename))
178 current = current->next;
184 void Assets::remove_asset(Asset *asset)
186 remove_pointer(asset);
187 asset->Garbage::remove_user();
191 int Assets::number_of(Asset *asset)
196 for(i = 0, current = first; current && current != asset; i++, current = NEXT)
202 Asset* Assets::asset_number(int number)
207 for(i = 0, current = first; i < number && current; i++, current = NEXT)
213 int Assets::update_old_filename(char *old_filename, char *new_filename)
215 for(Asset* current = first; current; current = NEXT)
217 if(!strcmp(current->path, old_filename))
219 current->update_path(new_filename);
226 int Assets::dump(FILE *fp)
228 for(Asset *current = first; current; current = NEXT)