2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
6 #include "LocatableFile.h"
8 #include <AutoLocker.h>
10 #include "LocatableDirectory.h"
13 // #pragma mark - LocatableFile
16 LocatableFile::LocatableFile(LocatableEntryOwner
* owner
,
17 LocatableDirectory
* directory
, const BString
& name
)
19 LocatableEntry(owner
, directory
),
27 LocatableFile::~LocatableFile()
33 LocatableFile::Name() const
35 return fName
.String();
40 LocatableFile::GetPath(BString
& _path
) const
42 fParent
->GetPath(_path
);
43 _path
<< '/' << fName
;
48 LocatableFile::GetLocatedPath(BString
& _path
) const
50 AutoLocker
<LocatableEntryOwner
> locker(fOwner
);
52 if (fLocatedPath
.Length() > 0) {
57 if (!fParent
->GetLocatedPath(_path
))
60 _path
<< '/' << fName
;
66 LocatableFile::SetLocatedPath(const BString
& path
, bool implicit
)
68 // called with owner already locked
71 fLocatedPath
= (const char*)NULL
;
72 fState
= LOCATABLE_ENTRY_LOCATED_IMPLICITLY
;
75 fState
= LOCATABLE_ENTRY_LOCATED_EXPLICITLY
;
83 LocatableFile::AddListener(Listener
* listener
)
85 AutoLocker
<LocatableEntryOwner
> locker(fOwner
);
86 return fListeners
.AddItem(listener
);
91 LocatableFile::RemoveListener(Listener
* listener
)
93 AutoLocker
<LocatableEntryOwner
> locker(fOwner
);
94 fListeners
.RemoveItem(listener
);
99 LocatableFile::_NotifyListeners()
101 for (int32 i
= fListeners
.CountItems() - 1; i
>= 0; i
--)
102 fListeners
.ItemAt(i
)->LocatableFileChanged(this);
106 // #pragma mark - Listener
109 LocatableFile::Listener::~Listener()