3 #include "awindowgui.inc"
10 #include "filesystem.h"
11 #include "indexfile.h"
12 #include "quicktime.h"
13 #include "mainsession.h"
14 #include "threadindexer.h"
19 Assets::Assets(EDL *edl)
29 int Assets::load(ArrayList<PluginServer*> *plugindb,
35 //printf("Assets::load 1\n");
38 result = file->read_tag();
41 if(file->tag.title_is("/ASSETS"))
46 if(file->tag.title_is("ASSET"))
48 //printf("Assets::load 2\n");
49 char *path = file->tag.get_property("SRC");
50 //printf("Assets::load 3\n");
51 Asset_GC new_asset(new Asset(path ? path : SILENCE));
52 //printf("Assets::load 4\n");
53 new_asset->read(file);
54 //printf("Assets::load 5\n");
56 //printf("Assets::load 6\n");
60 //printf("Assets::load 7\n");
64 int Assets::save(ArrayList<PluginServer*> *plugindb, FileXML *file, char *path)
66 file->tag.set_title("ASSETS");
68 file->append_newline();
70 for (Assets_list::iterator current = assets.begin(); current != assets.end(); ++current)
72 (*current)->write(file, 0 , path);
75 file->tag.set_title("/ASSETS");
77 file->append_newline();
78 file->append_newline();
82 void Assets::copy_from(const Assets &assets)
86 for(Assets_list::const_iterator current = assets.begin();
87 current != assets.end(); ++current)
89 Asset_GC new_asset(new Asset);
90 this->assets.push_back(new_asset);
91 new_asset->copy_from(**current, 1);
95 Assets& Assets::operator=(const Assets &assets)
97 printf("Assets::operator= 1\n");
103 void Assets::update_index(Asset &asset)
105 for (Assets_list::iterator current = assets.begin(); current != assets.end(); ++current)
107 if((*current)->test_path(asset.path))
109 (*current)->update_index(asset);
114 Asset_GC Assets::update(Asset_GC asset)
116 if(! asset.get()) return Asset_GC();
118 for (Assets_list::iterator current = assets.begin(); current != assets.end(); ++current)
120 // Asset already exists.
121 if((*current)->test_path(asset->path))
127 // Asset doesn't exist.
128 Asset_GC asset_copy(new Asset(*asset));
129 assets.push_back(asset_copy);
133 int Assets::delete_all()
139 Asset_GC Assets::update(const char *path)
141 for (Assets_list::iterator current = assets.begin(); current != assets.end(); ++current)
143 if((*current)->test_path(path))
149 Asset_GC new_asset(new Asset(path));
150 assets.push_back(new_asset);
154 Asset_GC Assets::get_asset(const char *filename)
156 for (Assets_list::iterator current = assets.begin(); current != assets.end(); ++current)
158 if((*current)->test_path(filename))
167 void Assets::remove_asset(Asset_GC asset)
169 assets.remove(asset);
173 int Assets::number_of(Asset_GC asset)
176 Assets_list::const_iterator current;
178 for(i = 0, current = assets.begin();
179 current != assets.end() && *current != asset;
186 Asset_GC Assets::asset_number(int number)
188 Assets_list::iterator current = assets.begin();
189 std::advance(current, number);
193 int Assets::update_old_filename(char *old_filename, char *new_filename)
195 for(Assets_list::iterator current = assets.begin();
196 current != assets.end();
199 if(!strcmp((*current)->path, old_filename))
201 (*current)->update_path(new_filename);
210 for(Assets_list::iterator current = assets.begin();
211 current != assets.end();
223 // c-file-style: "linux"