MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / addResource

Method addResource

Source/Core/CtrlrPanel/CtrlrPanelResourceManager.cpp:282–315  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

280}
281
282Result CtrlrPanelResourceManager::addResource (const File &source, const String &name)
283{
284 if ((bool)owner.getCtrlrManagerOwner().getProperty(Ids::ctrlrOverwriteResources) == false)
285 {
286 if (getResource (source.getFileNameWithoutExtension()))
287 {
288 return (Result::fail("This resource already exists"));
289 }
290 }
291
292 File resourceDest = resourcesDirectory.getChildFile(source.getFileName());
293
294 if (resourcesDirectory.isDirectory())
295 {
296 source.copyFileTo (resourceDest);
297 }
298 else
299 {
300 return (Result::fail("Can't copy resource to resources directory:"+resourcesDirectory.getFullPathName()));
301 }
302
303 {
304 CtrlrPanelResource *newResource = new CtrlrPanelResource (*this, resourceDest, source, name);
305
306 resources.add (newResource);
307 resourceHashCodes.add (newResource->getHashCode());
308 managerTree.addChild (newResource->getResourceTree(), -1, nullptr);
309 }
310
311 // Notify the panel about the modification
312 owner.panelResourcesChanged();
313
314 return (Result::ok());
315}
316
317Result CtrlrPanelResourceManager::removeResource(CtrlrPanelResource *resourceToRemove)
318{

Callers 2

addResourceFromFileMethod · 0.80
importImageMethod · 0.80

Calls 10

copyFileToMethod · 0.80
panelResourcesChangedMethod · 0.80
getPropertyMethod · 0.45
getChildFileMethod · 0.45
getFileNameMethod · 0.45
isDirectoryMethod · 0.45
addMethod · 0.45
getHashCodeMethod · 0.45
addChildMethod · 0.45

Tested by

no test coverage detected