2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Copyright 2016, Rene Gollent, rene@gollent.com.
4 * Distributed under the terms of the MIT License.
7 #include "LocatableFile.h"
9 #include <AutoLocker.h>
11 #include "LocatableDirectory.h"
14 // #pragma mark - LocatableFile
17 LocatableFile::LocatableFile(LocatableEntryOwner
* owner
,
18 LocatableDirectory
* directory
, const BString
& name
)
20 LocatableEntry(owner
, directory
),
28 LocatableFile::~LocatableFile()
34 LocatableFile::Name() const
36 return fName
.String();
41 LocatableFile::GetPath(BString
& _path
) const
43 fParent
->GetPath(_path
);
44 if (_path
.Length() != 0)
51 LocatableFile::GetLocatedPath(BString
& _path
) const
53 AutoLocker
<LocatableEntryOwner
> locker(fOwner
);
55 if (fLocatedPath
.Length() > 0) {
60 if (!fParent
->GetLocatedPath(_path
))
63 _path
<< '/' << fName
;
69 LocatableFile::SetLocatedPath(const BString
& path
, bool implicit
)
71 // called with owner already locked
74 fLocatedPath
= (const char*)NULL
;
75 fState
= LOCATABLE_ENTRY_LOCATED_IMPLICITLY
;
78 fState
= LOCATABLE_ENTRY_LOCATED_EXPLICITLY
;
86 LocatableFile::AddListener(Listener
* listener
)
88 AutoLocker
<LocatableEntryOwner
> locker(fOwner
);
89 return fListeners
.AddItem(listener
);
94 LocatableFile::RemoveListener(Listener
* listener
)
96 AutoLocker
<LocatableEntryOwner
> locker(fOwner
);
97 fListeners
.RemoveItem(listener
);
102 LocatableFile::_NotifyListeners()
104 for (int32 i
= fListeners
.CountItems() - 1; i
>= 0; i
--)
105 fListeners
.ItemAt(i
)->LocatableFileChanged(this);
109 // #pragma mark - Listener
112 LocatableFile::Listener::~Listener()